code-423n4 / 2024-03-taiko-findings

3 stars 2 forks source link

Signatures can be replayed in `withdraw()` to withdraw more tokens than the user originally intended. #60

Open c4-bot-4 opened 7 months ago

c4-bot-4 commented 7 months ago

Lines of code

https://github.com/code-423n4/2024-03-taiko/blob/f58384f44dbf4c6535264a472322322705133b11/packages/protocol/contracts/team/TimelockTokenPool.sol#L170

Vulnerability details

Impact

Signatures can be replayed in withdraw() to withdraw more tokens than the user originally intended.

Vulnerability Details

In the TimelockTokenPool.sol contracts, users can provide a signature to allow someone else to withdraw all their withdrawable tokens on their behalf using their signature. TimelockTokenPool.sol#L170)

    function withdraw(address _to, bytes memory _sig) external {
        if (_to == address(0)) revert INVALID_PARAM();
        bytes32 hash = keccak256(abi.encodePacked("Withdraw unlocked Taiko token to: ", _to));
 @>     address recipient = ECDSA.recover(hash, _sig);
        _withdraw(recipient, _to);
    }

As seen from above, the signature provided does not include a nonce and this can lead to signature replay attacks. Due to the lack of a nonce, withdraw() can be called multiple times with the same signature. Therefore, if a user provides a signature to withdraw all his withdrawable tokens at one particular time, an attacker can repeatedly call withdraw() with the same signature to withdraw more tokens than the user originally intended. The vulnerability is similar to Arbitrum H-01 where user's signatures could be replayed to use up more votes than a user intended due to a lack of nonce.

Tools Used

Manual Review

Recommended Mitigation Steps

Consider using a nonce or other signature replay protection in the TimelockTokenPool contract.

Assessed type

Invalid Validation

c4-pre-sort commented 7 months ago

minhquanym marked the issue as primary issue

c4-pre-sort commented 7 months ago

minhquanym marked the issue as sufficient quality report

dantaik commented 7 months ago

Valid bug report, trying to fix it in this PR: https://github.com/taikoxyz/taiko-mono/pull/16611/files

c4-sponsor commented 7 months ago

dantaik (sponsor) confirmed

c4-judge commented 7 months ago

0xean marked the issue as satisfactory

c4-judge commented 7 months ago

0xean marked the issue as selected for report