-
Notifications
You must be signed in to change notification settings - Fork 38
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
fix: [CL ALCHEMY-002] use correct validation function for running hooks in executeUserOp #289
Conversation
67305ea
to
3973328
Compare
src/account/ModularAccountBase.sol
Outdated
// The struct must sign over the user op validation function, nonce, deadline, and the deferred action. | ||
// Note that while the declared type of the UO validation is `ValidationConfig`, the flags are | ||
// interpretted as validation selection flags, not validation installation flags. | ||
ValidationConfig uoValidation = ValidationConfig.wrap(bytes25(userOp.signature[:25])); |
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.
Since it's not technically a ValidationConfig, would it make sense just to use a raw bytes25?
// Decode stack vars for the deadline and nonce. | ||
// The deadline, nonce, inner validation, and deferred call selector are all at fixed positions in the | ||
// encodedData. | ||
uint256 nonce = uint256(bytes32(encodedData[:32])); | ||
uint48 deadline = uint48(bytes6(encodedData[32:38])); | ||
|
||
ValidationConfig uoValidation = ValidationConfig.wrap(bytes25(encodedData[38:63])); | ||
ValidationConfig defActionSigValidation = ValidationConfig.wrap(bytes25(encodedData[38:63])); | ||
bool isGlobalSigValidation = defActionSigValidation.isGlobal(); |
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.
@adamegyed is this what you were referring to previously-- in that we treat this like a ValidationConfig when in reality it should be a ModuleEntity + validationFlags (where 0b00000001 is isGlobal)?
But in reality the flags are different.
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.
Yes, exactly.
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.
Wdyt if we made this a bytes25 instead too?
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.
Update to bytes25
here and in ModuleSignatureUtils!
3973328
to
6180cf4
Compare
Summary by OctaneNew ContractsNo new contracts were added in this PR. Updated Contracts
🔗 Commit Hash: 412583f |
Contract sizes: | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
|-------------------------------|------------------|-------------------|--------------------|---------------------|
| AccountFactory | 4,814 | 5,239 | 19,762 | 43,913 |
| AllowlistModule | 9,553 | 9,580 | 15,023 | 39,572 |
| ExecutionInstallDelegate | 5,714 | 5,760 | 18,862 | 43,392 |
-| ModularAccount | 21,931 | 28,634 | 2,645 | 20,518 |
+| ModularAccount | 21,975 | 28,678 | 2,601 | 20,474 |
| NativeFunctionDelegate | 434 | 461 | 24,142 | 48,691 |
| NativeTokenLimitModule | 4,449 | 4,476 | 20,127 | 44,676 |
| PaymasterGuardModule | 1,845 | 1,872 | 22,731 | 47,280 |
-| SemiModularAccountBytecode | 23,233 | 29,936 | 1,343 | 19,216 |
-| SemiModularAccountStorageOnly | 23,727 | 30,430 | 849 | 18,722 |
+| SemiModularAccountBytecode | 23,277 | 29,980 | 1,299 | 19,172 |
+| SemiModularAccountStorageOnly | 23,771 | 30,474 | 805 | 18,678 |
| SingleSignerValidationModule | 3,646 | 3,673 | 20,930 | 45,479 |
| TimeRangeModule | 2,000 | 2,027 | 22,576 | 47,125 |
| WebAuthnValidationModule | 7,854 | 7,881 | 16,722 | 41,271 | Code coverage:
|
OverviewOctane AI analysis has finished. No vulnerabilities were found. Cheers! 🎉🎉🎉 🔗 Commit Hash: 412583f |
Motivation
Addresses CL ALCHEMY-002.
When a deferred action is used, the validation-associated exec hooks, which run within
executeUserOp
, load the wrong set of hooks by reading from the first 24 bytes ofuserOp.signature
, which refers to the validation of the deferred action, rather than the user op.Solution
When using deferred actions, switch the encoding locations of the validation for the user op and the validation for the deferred action. This results in
executeUserOp
loading and running the correct set of hooks.Note that while the locations are switched, the contents of the EIP-712 struct for deferred actions remains the same, so the "outer" user op validation remains what is signed over.
Also add a test to verify this behavior.