-
Notifications
You must be signed in to change notification settings - Fork 12.4k
ERC7579: prevent installing/uninstalling without proper initData #5971
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
ERC7579: prevent installing/uninstalling without proper initData #5971
Conversation
|
Walkthrough
Possibly related PRs
Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
test/account/extensions/AccountERC7579.behavior.js (1)
170-263: Consider adding tests for signature validation with short signatures.While the test coverage for fallback module data validation is thorough, consider adding tests for
isValidSignaturewith signatures shorter than 20 bytes to fully exercise the newERC7579InvalidModuleSignatureerror path in_extractSignatureValidator.Example test:
it('should handle short signatures gracefully in isValidSignature', async function () { const hash = ethers.randomBytes(32); const shortSig = '0x1234'; // Less than 20 bytes // Should return 0xffffffff (invalid signature magic value) await expect(this.mock.isValidSignature(hash, shortSig)) .to.eventually.equal('0xffffffff'); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
certora/specs/Account.spec(1 hunks)contracts/account/extensions/draft-AccountERC7579.sol(3 hunks)test/account/extensions/AccountERC7579.behavior.js(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
test/account/extensions/AccountERC7579.behavior.js (1)
test/helpers/erc7579.js (1)
MODULE_TYPE_FALLBACK(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: tests-foundry
- GitHub Check: tests-upgradeable
- GitHub Check: slither
- GitHub Check: coverage
- GitHub Check: tests
- GitHub Check: halmos
🔇 Additional comments (6)
contracts/account/extensions/draft-AccountERC7579.sol (3)
71-75: LGTM! Clear error declarations for input validation.The new error declarations are well-documented and appropriately scoped:
ERC7579CannotDecodeFallbackData: Used when initData/deInitData is too short to extract a 4-byte selectorERC7579InvalidModuleSignature: Used when signature is too short to extract a 20-byte module address
393-394: LGTM! Defensive input validation for signature parsing.The length check ensures at least 20 bytes are available before extracting
address(bytes20(signature)). WhileisValidSignaturealready guards this call (line 192), the added check makes_extractSignatureValidatormore robust since it'sinternal virtualand could be called from derived contracts without the outer guard.
409-410: LGTM! Essential input validation for fallback data decoding.The check prevents attempting to extract a selector from data shorter than 4 bytes. Without this guard,
bytes4(data)would pad with zeros (yielding an incorrect selector) anddata.slice(4)would cause an out-of-bounds access. The explicit validation provides a clear error message.certora/specs/Account.spec (1)
208-208: LGTM! Spec correctly guards selector extraction.The updated assertion now requires
initData.length >= 4before evaluatinggetDataSelector(initData), aligning with the contract's new validation in_decodeFallbackData. This prevents undefined behavior in formal verification when initData is too short to contain a selector.test/account/extensions/AccountERC7579.behavior.js (2)
170-179: LGTM! Comprehensive test coverage for installation validation.The test correctly verifies that installing a fallback module with initData shorter than 4 bytes (both empty
0xand 3-byte0x123456) reverts withERC7579CannotDecodeFallbackData, ensuring the new validation logic works as expected.
254-263: LGTM! Comprehensive test coverage for uninstallation validation.The test correctly verifies that uninstalling a fallback module with initData shorter than 4 bytes reverts with
ERC7579CannotDecodeFallbackData, providing symmetric coverage with the installation tests.
Followup to #5961
PR Checklist
npx changeset add)