-
Notifications
You must be signed in to change notification settings - Fork 10
GalloDaSballo - Optimism Portal can run out of gas due to incorrect overhead estimation #138
Comments
Comment from Optimism Severity: medium Reason: see 109 |
Escalate for 250 USDC This report should not be a duplicate of #109. For an issue to be judged as High, it requires the Watson to (a) understand the exploit and (b) provide a report with an adequate burden of proof for a High Severity Finding. This report does neither. While the same underlying root cause is identified as #109, the Watson does not see the possibility that this could be used to brick legitimate withdrawals. Instead, it's seen merely as something that might happen accidentally. As a result, the Watson files the report as a Medium Severity, which is appropriate for what he found. As a example, if you look at #109, you'll see:
For this issue, we see:
I understand that Optimism's team simply lumped them together because they address the same issue. But based on Sherlock's rules, issues of different severity should not be dup'd together. For that reason, we believe this should be dedup'd from #109 and live as its own issue. |
You've created a valid escalation for 250 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Escalation accepted. Labeling as a unique medium (instead of duplicate high) It's clear that the Watson didn't understand the full impact of the issue. |
This issue's escalations have been accepted! Contestants' payouts and scores will be updated according to the changes made on this issue. |
GalloDaSballo
medium
Optimism Portal can run out of gas due to incorrect overhead estimation
Summary
In contrast to
CrossDomainMessenger
which has a 5k gas buffer, the Optimism Portal doesn't, meaning all its relayed calls will have 5k+ less gas than intended.This forces integrations (e.g. Bridges) to spend more gas by default, because of a logic flaw.
For this reason am filing the finding as Medium Severity:
Vulnerability Detail
CrossDomainMessenger
will compute the gas-required, adding a 5k gas bufferhttps://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol#L318-L324
It will then pass the remainder of the gas, minus the buffer as it's assumed to have been spent for the SSTORE
Optimism Portal on the other hand will not do that
Impact
By only checking that
The check will ensure that before the SSTORE + Call the buffer is available
However, the following SSTORE will consider 5k+ (5k for SSTORE, hundreds of gas for overhead)
This will leave the SafeCall with less gas than intended
SafeCall
will have less gas than intended, meaning that every integrator that estimates their TXs accurately will have their tx revert.Code Snippet
https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/L1/OptimismPortal.sol#L310-L328
Tool used
Manual Review
Recommendation
Recompute the buffer to add the extra 5k + the overhead of the SSTORE (in the few hundreds of gas)
To ensure the call has enough gas, you may also consider swapping positions between the SSTORE and the require
The text was updated successfully, but these errors were encountered: