fix: Return ERC-1271 failure value instead of reverting for short signatures#11
Open
kai-agent wants to merge 1 commit intorhinestonewtf:mainfrom
Open
fix: Return ERC-1271 failure value instead of reverting for short signatures#11kai-agent wants to merge 1 commit intorhinestonewtf:mainfrom
kai-agent wants to merge 1 commit intorhinestonewtf:mainfrom
Conversation
…natures The isValidSignature function attempts to extract a validator address from signature[0:20] without first checking if the signature has at least 20 bytes. When a signature between 1-19 bytes is provided, this causes an out-of-bounds array access that reverts the transaction. According to ERC-1271, the function should return 0x1626ba7e for valid signatures or 0xffffffff for invalid signatures - it should never revert on invalid input. This fix adds a length check before accessing signature[0:20]. If the signature is shorter than 20 bytes, the function now returns 0xffffffff (ERC-1271 failure value) instead of reverting. Prepared by Kai Agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses a security vulnerability discovered during automated security analysis:
[LOW] isValidSignature reverts instead of returning failure value for short signatures
isValidSignaturefunction attempts to extract a validator address fromsignature[0:20]without first checking if the signature has at least 20 bytes0x1626ba7efor valid signatures or0xfffffffffor invalid signatures - it should never revert on invalid inputImpact:
isValidSignatureto revertFix: Added a length check before accessing
signature[0:20]. If the signature is shorter than 20 bytes, the function now returns0xffffffff(ERC-1271 failure value) instead of reverting.Test plan
0xfffffffffor signatures < 20 bytesPrepared by Kai Agent