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

Replay Attack on sendToL1 function

Summary

The sendToL1 function is susceptible to replay attacks due to the absence of nonce verification in the transaction processing logic. A replay attack occurs when an attacker resubmits a previously signed transaction to the contract, leading to unintended and potentially malicious consequences.

Vulnerability Details

The vulnerability stems from the lack of nonce validation, allowing an attacker to replay a signed message with the same parameters, leading to the re-execution of the transaction. The absence of a unique identifier for each transaction opens the door for unauthorized re-execution of valid transactions.

address signer = ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(keccak256(message)), v, r, s);

Impact

The replay attack vulnerability poses a significant threat to the integrity and security of the sendToL1 function. An attacker could repeatedly execute valid transactions, causing unintended side effects such as multiple transfers of assets or unauthorized interactions with other contracts.

Tools Used

Manual

Recommendations

Introduce a nonce mechanism to ensure that each transaction is unique. Check the nonce of incoming transactions against the sender's current nonce to prevent replay attacks.

function sendToL1(uint8 v, bytes32 r, bytes32 s, bytes memory message, uint256 nonce) public nonReentrant whenNotPaused {
address signer = ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(keccak256(abi.encodePacked(message, nonce))), v, r, s);
if (!signers[signer]) {
revert L1BossBridge__Unauthorized();
}
require(nonce > nonces[signer], "Invalid nonce");
nonces[signer] = nonce;
(address target, uint256 value, bytes memory data) = abi.decode(message, (address, uint256, bytes));
(bool success,) = target.call{ value: value }(data);
if (!success) {
revert L1BossBridge__CallFailed();
}
}
Updates

Lead Judging Commences

0xnevi Lead Judge almost 2 years 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.