core/types: fix panic on invalid signature length #33647#1979
core/types: fix panic on invalid signature length #33647#1979AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
Conversation
Replace panic with error return in decodeSignature to prevent crashes on invalid inputs, and update callers to propagate the error.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes a panic vulnerability in signature validation by converting the decodeSignature function to return an error instead of panicking when an invalid signature length is provided.
Changes:
- Modified
decodeSignatureto return an error instead of panicking for invalid signature lengths - Updated all callers of
decodeSignatureacross multiple signer implementations to properly handle and propagate the error - Added a test case to verify that invalid signature lengths produce errors instead of panics
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/types/transaction_signing.go | Updated decodeSignature to return error and modified all signer implementations (pragueSigner, londonSigner, eip2930Signer, EIP155Signer, FrontierSigner) to handle the error |
| core/types/tx_setcode.go | Updated SignSetCode function to handle error from decodeSignature |
| core/types/transaction_signing_test.go | Added test case TestSignatureValuesError to verify proper error handling for invalid signatures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Proposed changes
Replace panic with error return in decodeSignature to prevent crashes on invalid inputs, and update callers to propagate the error.
Ref: ethereum#33647
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that