-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signature Malleability in ERC721 Permit #145
Comments
MikeHathaway marked the issue as sponsor confirmed |
Picodes marked the issue as satisfactory |
Picodes marked the issue as unsatisfactory: |
Unfortunately, the contract was clearly out of scope in the README.md of the contest. Although the finding is technically valid we can't include it in the price pool as audits are priced according to the number of LOC in scope. So it's up to the sponsor to reward this independantly. |
@MikeHathaway regarding #147, #141, #143 and this issue please see my comment above regarding out of scope findings. |
Lines of code
https://github.com/code-423n4/2023-05-ajna/blob/fc70fb9d05b13aee2b44be2cb652478535a90edd/ajna-core/src/base/PermitERC721.sol#L97-L110
Vulnerability details
Impact
Replay attacks are possible thanks to signature malleability
Proof of Concept
The ecrecover EVM opcode has a limitation that allows for non-unique signatures, which means that different signatures can produce the same output.
According to EIP-2, any transaction signatures with an s-value greater than secp256k1n/2 are considered invalid. However, validating such signatures by passing them to the _verify function is still possible.
To create a malleable signature, one can flip the s value from s to secp256k1n - s and also flip the v value (27 -> 28, 28 -> 27). Surprisingly, the resulting signature would still be valid.
https://github.com/code-423n4/2023-05-ajna/blob/fc70fb9d05b13aee2b44be2cb652478535a90edd/ajna-core/src/base/PermitERC721.sol#L97-L110
Even though ERC721 permit could be out of scope, I've confirmed the issue with the sponsor and after discussing with the C4 team we agreed to fill it in: since the scope section in the audit repo isn't 100% clear here. So ultimately this will end up being a call the judge makes.
Tools Used
Manual Review
Discussion/confirmation with the Ajna Protocol team.
Recommended Mitigation Steps
To address this issue, OpenZeppelin has taken measures to handle malleable signatures. You can find more information on how they tackled this problem at this GitHub link: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol#L125.
Assessed type
Access Control
The text was updated successfully, but these errors were encountered: