The L1Sender
and L2TokenReceiver
set unlimitted approval of tokens. That can lead to a significant financial loss.
The L1Sender::L1Sender__init
function calls L1Sender::setDepositTokenConfig
that calls the functions L1Sender::_replaceDepositToken
and L1Sender::_replaceDepositTokenGateway
. The last two functions make approve of maximum value of type uint256
for unwrappedToken_
and newToken_
:
Also, the L2TokenReceiver::L2TokenReceiver__init
calls the function L2TokenReceiver::_editParams
that approves the maximum value of type uint256
for tokenIn
and tokenOut
:
These unlimited allowances can lead to a significant financial loss.
The L1Sender
contract sets an unlimited allowance for the IGatewayRouter
contract to spend a ERC20
token on its behalf.
If the IGatewayRouter
contract is compromised, this could lead to a loss of all stETH
tokens held in the L1Sender
contract. The malicious user can call the transferFrom
function of the ERC20
token, specifying the L1Sender
contract as the from
address, their own address as the to
address, and the full balance of the L1Sender
contract as the amount
. Since the allowance is set to type(uint256).max
, the ERC20
token contract allows the transfer, and the attacker drains all the tokens from the L1Sender
contract.
Also, the L2TokenReceiver::_editParams
function sets the approval for tokenIn
and tokenOut
to the maximum possible value for the router
and nonfungiblePositionManager
contracts using TransferHelper.safeApprove
. This means that these contracts are allowed to transfer an unlimited amount of the tokenIn
and tokenOut
tokens on behalf of the L2TokenReceiver
contract. And again if the router
or nonfungiblePositionManager
contracts are compromised, a malicious user can exploit them to drain the approved tokens from the L2TokenReceiver
contract.
Manual Review
Instead of setting the maximum possible allowance, add a function that set the allowance to the exact amount needed for each transaction. This function should be called before each transfer operation, and it should revoke the previous approval, if there is any, and set a new one for the exact amount to be transferred.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.