PositionManager & PermitERC721 Failure to comply with the EIP-4494
The PositionManager and PermitERC721 contracts do not comply with the EIP-4494 standard for permit-based ERC-721 approvals. This means third-party tools and contracts cannot detect or correctly use the permit functionality, and nonces cannot be tracked, leading to invalid or future signatures.
The contract PositionManager.sol inherits from PermitERC721.sol, but both contracts incorrectly implement the EIP-4494 standard, which is an important part of the contract. This leads to the following issues:
PositionManager & PermitERC721 are not EIP-4494 compliant
Automatic tools will not be able to determine that this contract has a permit for ERC721
Third-party contracts will not be able to determine that this is EIP-4494
Inability to correctly track which nonces are currently relevant, leading to the creation of invalid signatures/signatures for the future
No support for compact signatures
Proof of Concept
According to the specifications of the standard EIP-4494, the following violations were found:
EIP-4494 requires the implementation of IERC165 and the indication of support for the interface 0x5604e225, which is not implemented
EIP-4494 requires the presence of the function function nonces(uint256 tokenId) external view returns(uint256);which is missing
EIP-4494 requires the function function permit(address spender, uint256 tokenId, uint256 deadline, bytes memory sig) external;, which is incorrectly declared as
Hi @Picodes - The ajna-core/src/base/PermitERC721.sol is indeed out of scope, which subsequently makes points 1 and 3 out of scope as well. However, I’d like you to take another look at point 2.
EIP-4494 necessitates the inclusion of the function: function nonces(uint256 tokenId) external view returns(uint256); which is currently absent.
We can see that PermitERC721 is an abstract contract which only partially implements EIP-4494, and it does so incorrectly, thereby making this part out of scope. However, it also imposes a requirement (abstract contract with abstract _getAndIncrementNonce() method) on PositionManager to implement nonces method on its end, which is within scope. This conclusion can be drawn from the following method:
File: ajna-core/src/base/PermitERC721.sol
29: /** @dev Gets the current nonce for a token ID and then increments it, returning the original value */
30: function _getAndIncrementNonce(uint256 tokenId_) internal virtual returns (uint256);
This suggests that the nonces method must be implemented in PositionManager, PermitERC721 transfers this responsibility to descendants. And according to point 2, PositionManager is the final contract that violates the EIP-4494 standard, which is indeed within scope. According to EIP-4494 documentation, the nonces declaration is stated under Three new functions MUST be added to ERC-721:, which, in my opinion, can’t be simply dismissed as function incorrect as to spec. According to the practice I’ve observed, any violation of the standard with MUST label is usually rated as Medium.
@Haipls - your point is valid: PositionManager should implement nonces. I was reluctant to give this Medium severity as there are issues in PermitERC721 so the contract couldn’t implement the EIP anyway, but, after reflection and discussing it with another judge, the problem is significant enough to justify Medium severity.
The original report as published on Code4rena, by Haipls. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the contracts did not fully implement the required functions and interface declarations of EIP-4494, such as the nonces function and ERC-165 support.
Impact
Third-party contracts and tools cannot detect or correctly use the permit functionality, and nonces cannot be tracked, which could lead to invalid or future signatures being created.
What the attacker needed
None
The fix
The contracts should be corrected to fully comply with EIP-4494, or references to the standard should be removed and a reference to the Uniswap V3 implementation provided.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
EIP-4494 is a standard for allowing someone to approve another person to use a specific NFT without paying gas, using a signature. This report says the contracts that implement this standard do not follow its rules, so other programs cannot tell that the feature exists or use it properly.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.