Closed sherlock-admin closed 1 year ago
See #85
Sponsor comment: This report is true, but it is a duplicate of #115 from the first challenge and not a concern of the team. To avoid confusion and inform users of the contracts, we have a ticket open to document this caveat. In addition, there was already a known maximum value for the minimum gas limit that is < the L1 block gas limit due to the gas consumed around the external call performed by the OptimismPortal or XDM.
User Mistake, agree with Low
Koolex
high
finalizeWithdrawalTransaction
transaction will not be processed if the minimum gas is set too highSummary
if the minimum gas is set too high then
finalizeWithdrawalTransaction
transaction will not be processed. Eventually, causing loss of funds for withdrawers.Vulnerability Detail
In the new Optimism update,
callWithMinGas
was introduced to make sure the minimum gas limit specified by the user is guaranteed. Basically the following is checkedPlease note that 200 is added to minimum gas limit. However, 51 will be used between
GAS
opcode andCALL
opcode For a clearer picture, check this link Safe Call with minimum gasLet's deduct 51 from 200, we have 149 gas. This means: minimum gas limit + 149 is guaranteed to be passed to the sub-call
L1CrossDomainMessenger.relayMessage
. However, there is no check for the maximum. Therefore, if the gas provided is too high exceeding the block gas limit thenfinalizeWithdrawalTransaction
transaction will not be processed. Eventually, causing loss of funds sincefinalizeWithdrawalTransaction
is reverting if you provide less gas.Imagine the following scenario:
callWithMinGas
, the relayer has to provide gas as follows:As noticed, the gas provided already exceeded the block gas limit. So it won't be processed. if the relayer provides less than that, the
finalizeWithdrawalTransaction
method will revert.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 30476393.
Impact
Withdrawals with too high gas limit can not be finalized. causing loss of funds for the withdrawer.
Code Snippet
https://github.com/sherlock-audit/2023-03-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/libraries/SafeCall.sol#L64
Tool used
Manual Review
Recommendation
check if _minGas is too high then set it for example to 29M as a max.