A malicious user can use the L1BossBridge::depositTokensToL2
function to transfer tokens from arbitrary address that has approved tokens to his own address set in l2Recipient
parameter.
The function L1BossBridge::depositTokensToL2
has input parameter from
that can be any address. Then the function calls the safeTransferFrom()
function that uses this from
parameter to transfer the amount
to the vault
. Also, the function depositTokensToL2
is external and can be called by anyone. In that way a malicious user can set the from
parameter to be any address that has approved tokens to L1BossBridge
contract.
Let's consider the following scenario:
If Alice has approved the L1BossBridge
contract to spend her tokens, then Bob could indeed call the depositTokensToL2
function with Alice's address as the from
parameter and his own address as the l2Recipient
parameter. This would result in Alice's tokens being transferred to the vault and the corresponding tokens being minted on L2 for Bob. The following test demonstrates this scenario. The test can be added to the file L1TokenBridge.t.sol
and executed with the command: forge test --match-test testAttackerCanDepositTokensFromAnotherAddress
. Of course, in the setUp()
function of the file should be created addresses for alice and attacker.
VS Code, Foundry
The depositTokensToL2
function could be modified to use msg.sender
as the from
parameter, ensuring that only the owner of the tokens can initiate the deposit. Alternatively, an additional authorization check could be added to ensure that the caller of the depositTokensToL2
function is the same as the from
address.
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.