Beginner FriendlyFoundryBridge
100 EXP
View results
Submission Details
Severity: high
Valid

Signature Replay Attack, the `withdrawTokensToL1` function does not track whether a signature has already been used.

Summary

The withdrawTokensToL1 function uses a signature for authorization, but it does not prevent replay attacks because it does not track whether a signature has already been used.

Vulnerability Details

This vulnerability exists in the L1BossBridge.sol::withdrawTokensToL1 function starting on line 91.

The withdrawTokensToL1 function uses ECDSA signatures for withdrawals but does not track nonces to ensure a signature is used only once.

function withdrawTokensToL1(address to, uint256 amount, uint8 v, bytes32 r, bytes32 s) external {
sendToL1(
v,
r,
s,
abi.encode(
address(token),
0, // value
abi.encodeCall(IERC20.transferFrom, (address(vault), to, amount))
)
);
}

Impact

An attacker could replay a signature to authorize multiple withdrawals, potentially draining funds.

POC

Test case example:

contract SignatureReplayAttackTest is DSTest {
L1BossBridge bridge;
address signer = address(1);
function setUp() public {
bridge = new L1BossBridge();
bridge.setSigner(signer, true);
}
function testReplayAttack() public {
bytes memory signature = /* signature generated off-chain */;
bridge.withdrawTokensToL1(/* parameters */, signature);
bridge.withdrawTokensToL1(/* same parameters */, signature); // This should fail
}
}

Tools Used

  • Forge

Recommendations

Implement a nonce system where each withdrawal must include a unique nonce that is tracked and invalidated after use.

Simplified example:

// Fixed example with nonce
function withdrawTokensToL1(/* parameters */, uint256 nonce) external {
require(!usedNonces[nonce], "Nonce already used");
usedNonces[nonce] = true;
// ...
}
Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

withdrawTokensToL1()/sendToL1(): signature replay

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.