Closed github-actions[bot] closed 1 year ago
Comment from Optimism
Description: hard-coded gas amount specified in CrossDomainMessenger
Reason: This is untrue and the current implementation is a design decision. The minGasLimit specified by the user is considered for a remote tx gasleft() is provided to the subsequent call.
unforgiven
medium
[Medium] hard-coded gas amount specified in CrossDomainMessenger and it can cause cross domain messages to revert if Ethereum gas cost changes or contracts in other chain get updated
Summary
Function
sendMessage()
in CrossDomainMessanger Sends a message to some target address on the other chain and to make sure that message has enough gas that user specified contract add a constant gas to user specified gas. but as other chain gas cost schema can change or the bridge contract can be updated and gas usage can be change in the future the hard coded value won't be enough in the future and it would cause users withdrawal or deposits to fail and users would lose funds even so they are using CrossDomainMessanger.Vulnerability Detail
This is
sendMessage()
code:As you can see to specify the minimum gas limit for other chain transaction code use function
baseGas(_message, _minGasLimit)
and this function code is:to make sure that transaction in the other chain have enough gas to process bridge contracts code,
MIN_GAS_CONSTANT_OVERHEAD
is added to required gas in the other chain. but this value is constant and this can cause issue in the future where:Impact
withdraw or deposit messages between CrossDomainMessangers would be broken and users funds would be lost.
Code Snippet
https://github.com/ethereum-optimism/optimism/blob/3f4b3c328153a8aa03611158b6984d624b17c1d9/packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol#L372-L395
https://github.com/ethereum-optimism/optimism/blob/3f4b3c328153a8aa03611158b6984d624b17c1d9/packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol#L202-L234
Tool used
Manual Review
Recommendation
give admin access to change increase the MIN_GAS_CONSTANT_OVERHEAD.