-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AA-101: validate gasLimit to leave more than callGasLimit to call (#163)
* AA-101: validate gasLimit to leave more than callGasLimit to target call. Fix vulnerability reported by Richard Meisner in PR #162 The added tests should show the scenario where a user operation with a high callGasLimit is submitted. In this case it is important that the gasLimit is correctly set, else it is possible to use the 1/64th rule of EIP-150 to make the user operation fail and the account pays for it. If this is possible it could be used as an attack vector. The attacker would submit a bundle with the high gas usage tx with a too low gas value. Even when the user estimated everything correctly the transaction would fail because not enough gas is available. The costs for the execution would still be deducted from the account. Therefore the submitter could perform a denial of service attack for which the account that is being attacked would pay. The first tests below shows that high gas transaction can be executed and refunded. The second test checks that the transaction is reverted in case the gas limit is set too low, to avoid the attack described above.
- Loading branch information
1 parent
65eb17c
commit 4fef857
Showing
4 changed files
with
46 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
== gas estimate of direct calling the account's "execFromEntryPoint" method | ||
the destination is "account.nonce()", which is known to be "hot" address used by this account | ||
it little higher than EOA call: its an exec from entrypoint (or account owner) into account contract, verifying msg.sender and exec to target) | ||
- gas estimate "simple" - 31033 | ||
- gas estimate "simple" - 31045 | ||
- gas estimate "big tx 5k" - 127295 | ||
╔════════════════════════════════╤═══════╤═══════════════╤════════════════╤═════════════════════╗ | ||
║ handleOps description │ count │ total gasUsed │ per UserOp gas │ per UserOp overhead ║ | ||
║ │ │ │ (delta for │ (compared to ║ | ||
║ │ │ │ one UserOp) │ account.exec()) ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple │ 1 │ 77987 │ │ ║ | ||
║ simple │ 1 │ 78043 │ │ ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple - diff from previous │ 2 │ │ 43461 │ 12428 ║ | ||
║ simple - diff from previous │ 2 │ │ 43517 │ 12472 ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple │ 10 │ 469401 │ │ ║ | ||
║ simple │ 10 │ 469937 │ │ ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple - diff from previous │ 11 │ │ 43620 │ 12587 ║ | ||
║ simple - diff from previous │ 11 │ │ 43664 │ 12619 ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple paymaster │ 1 │ 77999 │ │ ║ | ||
║ simple paymaster │ 1 │ 78055 │ │ ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple paymaster with diff │ 2 │ │ 43473 │ 12440 ║ | ||
║ simple paymaster with diff │ 2 │ │ 43505 │ 12460 ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple paymaster │ 10 │ 469401 │ │ ║ | ||
║ simple paymaster │ 10 │ 469937 │ │ ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ simple paymaster with diff │ 11 │ │ 43632 │ 12599 ║ | ||
║ simple paymaster with diff │ 11 │ │ 43640 │ 12595 ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ big tx 5k │ 1 │ 179730 │ │ ║ | ||
║ big tx 5k │ 1 │ 179774 │ │ ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ big tx - diff from previous │ 2 │ │ 144806 │ 17511 ║ | ||
║ big tx - diff from previous │ 2 │ │ 144874 │ 17579 ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ big tx 5k │ 10 │ 1488505 │ │ ║ | ||
║ big tx 5k │ 10 │ 1489029 │ │ ║ | ||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ | ||
║ big tx - diff from previous │ 11 │ │ 146311 │ 19016 ║ | ||
║ big tx - diff from previous │ 11 │ │ 146355 │ 19060 ║ | ||
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝ | ||
|
This file contains 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
This file contains 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