Potential integer overflow vulnerability in the relayCalls() function. The function does not check for the maximum value of the _gasLimit parameter, and if it is set to a value greater than the maxGasLimit, it will cause an integer overflow.
Integer overflow bug in the processCalls() function. Specifically, the _maxSubmissionCost parameter is being used as a multiplier and can therefore potentially overflow if a large _maxSubmissionCost is passed.
Proof of Concept
An attacker can call the relayCalls() function with a _gasLimit parameter greater than the maxGasLimit, causing an integer overflow. This would cause the function to revert and could lead to a denial of service attack.
A malicious actor could exploit this bug by passing an excessively large _maxSubmissionCost parameter to the processCalls function.
This could result in an Integer overflow which could cause the entire transaction to fail.
In the following exploit, an attacker can send a value of 2^256 - 1 for the _maxSubmissionCost parameter. This will cause _maxSubmissionCost to overflow, resulting in a cost of 0:
function exploit(address _inbox, uint256 _maxGasLimit) public {
CrossChainRelayerArbitrum relayer = new CrossChainRelayerArbitrum(_inbox, _maxGasLimit);
CallLib.Call[] memory _calls = new CallLib.Call[](1);
_calls[0] = {destination: msg.sender, data: 0};
relayer.processCalls(0, _calls, msg.sender, _maxGasLimit, 2**256 - 1, 0);
}
Tools Used
Slither, Echidna, MythX, and Manticore.
Recommended Mitigation Steps
Add require(_gasLimit <= _maxGasLimit, "Relayer/GasLimitTooHigh"); statement at the beginning of relayCalls() function;
Add require(_maxSubmissionCost <= maxGasLimit, "Relayer/max-submission-cost-overflow"); statement at the beginning of processCalls() function;
Lines of code
https://github.com/pooltogether/ERC5164/blob/5647bd84f2a6d1a37f41394874d567e45a97bf48/src/ethereum-arbitrum/EthereumToArbitrumRelayer.sol#L67-L87 https://github.com/pooltogether/ERC5164/blob/5647bd84f2a6d1a37f41394874d567e45a97bf48/src/ethereum-arbitrum/EthereumToArbitrumRelayer.sol#L101-L132
Vulnerability details
Impact
Potential integer overflow vulnerability in the
relayCalls()
function. The function does not check for the maximum value of the_gasLimit
parameter, and if it is set to a value greater than themaxGasLimit
, it will cause an integer overflow.Integer overflow bug in the
processCalls()
function. Specifically, the_maxSubmissionCost
parameter is being used as a multiplier and can therefore potentially overflow if a large_maxSubmissionCost
is passed.Proof of Concept
relayCalls()
function with a_gasLimit
parameter greater than themaxGasLimit
, causing an integer overflow. This would cause the function to revert and could lead to a denial of service attack._maxSubmissionCost
parameter to theprocessCalls
function. This could result in an Integer overflow which could cause the entire transaction to fail._maxSubmissionCost
parameter. This will cause_maxSubmissionCost
to overflow, resulting in a cost of 0:Tools Used
Slither, Echidna, MythX, and Manticore.
Recommended Mitigation Steps
require(_gasLimit <= _maxGasLimit, "Relayer/GasLimitTooHigh")
; statement at the beginning of relayCalls() function;require(_maxSubmissionCost <= maxGasLimit, "Relayer/max-submission-cost-overflow");
statement at the beginning ofprocessCalls()
function;