RebateFi Hook

First Flight #53
Beginner FriendlyDeFi
100 EXP
View results
Submission Details
Severity: medium
Valid

Unchecked Return Value in `withdrawTokens` Function

Description:
withdrawTokens calls IERC20(token).transfer(to, amount) and ignores the boolean return value.

For standard OpenZeppelin-style ERC-20 tokens this is usually safe, but:

  • Some tokens return false on failure instead of reverting.

  • In that case, the contract:

    • will emit TokensWithdrawn, suggesting success,

    • but the token transfer will not actually happen.

Additionally, there is no guard against to == address(0), so the owner can accidentally burn protocol-owned tokens.

Impact:

  • For non-standard tokens:

    • Potential silent failure of withdraws, leading to discrepancies between logs and real balances.

  • For all tokens:

    • Owner can accidentally burn hook-held tokens by sending them to the zero address.

Proof of Concept:

Conceptual PoC (no extra mock required):

  1. Deploy a non-standard ERC-20 that:

    • returns false in transfer,

    • does not revert.

  2. Transfer some of those tokens to the hook.

  3. Call withdrawTokens(address(token), recipient, amount):

    • Transaction succeeds, TokensWithdrawn is emitted.

    • Token balance of recipient remains unchanged.

This demonstrates that ignoring the return value can mislead monitoring and the owner.

Mitigation:
Use OpenZeppelin's SafeERC20 library or explicitly check the return value.

+ using SafeERC20 for IERC20;
function withdrawTokens2(address token, address to, uint256 amount) external onlyOwner {
+ require(to != address(0), "to = zero");
- IERC20(token).transfer(to, amount);
+ IERC20(token).safeTransfer(to, amount);
emit TokensWithdrawn(to, token , amount);
}

Optionally, restrict token to a known set of allowed tokens to reduce the risk of interacting with misbehaving ERC-20s.

Updates

Lead Judging Commences

chaossr Lead Judge 11 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Not using safe transfer for ERC20.

Support

FAQs

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

Give us feedback!