Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of signature replay protection in TimelockTimePool.sol withdraw function #178

Closed
c4-bot-4 opened this issue Mar 25, 2024 · 2 comments
Closed
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-60 🤖_60_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@c4-bot-4
Copy link
Contributor

Lines of code

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

Vulnerability details

Lack of signature replay protection in TimelockTimePool.sol withdraw function

Line of code

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

Proof of concept

In TimelockTokenPool.sol,

Line of code

  /// @notice Withdraws all withdrawable tokens.
  /// @param _to The address where the granted and unlocked tokens shall be sent to.
  /// @param _sig Signature provided by the grant recipient.
  // @audit
  // replay protection is missing
  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);
  }

Impact

there is lack of validation for signature replay,

then once the recipient sign a signature, anyone can replay the signature to trigger withdraw repeatedly

Line of code

  function _withdraw(address _recipient, address _to) private {
        Recipient storage r = recipients[_recipient];

        (,,, uint128 amountToWithdraw, uint128 costToWithdraw) = getMyGrantSummary(_recipient);

        r.amountWithdrawn += amountToWithdraw;
        r.costPaid += costToWithdraw;

        totalAmountWithdrawn += amountToWithdraw;
        totalCostPaid += costToWithdraw;

        IERC20(taikoToken).transferFrom(sharedVault, _to, amountToWithdraw);
        IERC20(costToken).safeTransferFrom(_recipient, sharedVault, costToWithdraw);

And this will let the sharedVault recipient replay the amountToWithdraw several times,

and force the _recipient to pay the costToWithdraw several times to drain the fund

that remain static in the _recipient wallet

Recommendation

mark the hash as used and do not allow signature reuse.

Assessed type

Token-Transfer

@c4-bot-4 c4-bot-4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Mar 25, 2024
c4-bot-3 added a commit that referenced this issue Mar 25, 2024
@c4-bot-11 c4-bot-11 added the 🤖_60_group AI based duplicate group recommendation label Mar 27, 2024
@c4-pre-sort
Copy link

minhquanym marked the issue as duplicate of #60

@c4-judge
Copy link
Contributor

0xean marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-60 🤖_60_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants