-
Notifications
You must be signed in to change notification settings - Fork 0
Koolex - Possible loss of funds if the minimum gas limit is set too high on deposit #85
Comments
Maybe looked as:
Or
Interested in sponsor thoughts, also see: #71 |
Sponsor comment: |
User Mistake, agree with Low |
Escalate for 10 USDC. I agree that an issue caused by a user error is low. However, this issue above is not caused by a user error. Protocols that have advanced on-chain computation such as Jumbo or dHEDGE platform need to set the gas limit to the block gas limit (or close to it) to ensure the transactions succeed. Have a look at this discussion where Jumbo transactions failed when the block gas limit was 15M. This is just to show that some protocols might need to use up to the block gas limit. |
You've created a valid escalation for 10 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 rejected Valid low
|
This issue's escalations have been rejected! Watsons who escalated this issue will have their escalation amount deducted from their next payout. |
Koolex
high
Possible loss of funds if the minimum gas limit is set too high on deposit
Summary
if the minimum gas is set too high on deposit then
L2CrossDomainMessenger.relayMessage
transaction will not be processed. Eventually, causing loss of funds for depositors.Vulnerability Detail
in
L2CrossDomainMessenger.relayMessage
method,callWithMinGas
was introduced to make sure the minimum gas limit specified by the user is guaranteed.Basically the following is checked at Safe Call with minimum gas
As there is no check for the maximum gas limit in
depositTransaction
, if the minimum gas limit provided is too high exceeding the L2 block gas limit thenL2CrossDomainMessenger.relayMessage
transaction will not be processed. Eventually, causing loss of funds sincerelayMessage
is reverting if you provided gas is less.A possible scenario:
gasLimit
from SystemConfig contract. Let's say it's 40M.callWithMinGas
, the relayer has to provide gas as follows:The gas provided already exceeded the block gas limit 40M. So it won't be processed. if the relayer provides less than that, the
L2CrossDomainMessenger.relayMessage
will revert. Thus, resulting in loss of funds.Please note that this calculation is just right before callWithMinGas call. We still need to count the gas used before and after it. So it even gets bigger than 40635123.
Impact
Deposits with too high L2 gas limit can not be relayed on L2. causing loss of funds for the depositors.
Code Snippet
https://github.com/sherlock-audit/2023-03-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol#L360-L362
https://github.com/sherlock-audit/2023-03-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/libraries/SafeCall.sol#L64
Tool used
Manual Review
Recommendation
On depositTransaction, check if the gaslimit is too high (e.g. gasLimit > SystemConfig.gasLimit-1M) then revert.
The text was updated successfully, but these errors were encountered: