OpenZeppelin / OpenZeppelin/openzeppelin-contracts
Security considerations regarding `SignatureChecker.isValidERC1271SignatureNow`
Nobody has claimed this yet.
- Dominant language
- Solidity
- Stars
- 27.2k
- Forks
- 12.4k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 33
Description
📝 Details
After a small discussion I wanted to collect some thoughts on SignatureChecker.isValidERC1271SignatureNow. It largely assumes that the signer contract is trusted when verifying ERC-1271 signatures.
Signatures are often used by relayers to perform actions on behalf of users with their permission. Therefore it should be assumed that signers can be malicious and additional security considerations might come into play. Two observations are:
-
signer.staticcalldoes not include a gas limit -
(bool success, bytes memory result) = signer.staticcallcopies the entirety of the returned data, making it susceptible toreturndatabomb attacks -
is partially addressed in the EIP:
Since there are no gas-limit expected for calling the isValidSignature() function, it is possible that some implementation will consume a large amount of gas. It is therefore important to not hardcode an amount of gas sent when calling this method on an external contract as it could prevent the validation of certain signatures.
However, general security concerns for relayers still apply (call to the unknown): Relayers might not be aware that a fixed gas limit should be set or that relayed transactions should be discarded if they cost more than X. This could be a bad scenario if relayers are sponsored, use a fixed fee, or if the maximum gas is not debited upfront.
- is not much of a concern when there is no fixed gas limit in the call to the
signer. The worst scenario might be confusion if the call reverts in the caller's context instead of thesignercontract.
Potential solutions:
- Add general security consideration advice to
SignatureChecker.isValidERC1271SignatureNow. - Only load 32 bytes from
returndatavia assembly. - Add
gasLimitparameter toSignatureChecker.isValidERC1271SignatureNowand implement 2. - Do nothing.
Considering that the most simple solution might be the best, 4. or 1. might be the most sensible, though I'm interested if anyone has some more thoughts on this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the linked SignatureChecker.sol implementation and the ERC-1271 security guidance cited in the issue. Compare the four proposed options, including returndata handling and gas-limit implications; done requires a maintainer decision on the intended behavior and corresponding implementation or security documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity
- Domain
- blockchain, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100