RebateFi Hook

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

Unsafe IERC20 transfer in `ReFiSwapRebateHook::withdrawTokens`

Root + Impact

Description

  • The withdrawTokens function calls IERC20(token).transfer(to, amount) and ignores the returned boolean. Many ERC‑20 tokens are non‑standard (e.g. some older stablecoins) and either (a) return nothing (not bool), (b) return false on failure, or (c) have unusual behavior. Calling transfer without checking its return value or using a compatibility wrapper can allow token transfers to silently fail or behave unpredictably.

function withdrawTokens(address token, address to, uint256 amount) external onlyOwner {
//@audit-issue return value of transfer not checked, unsafe
@> IERC20(token).transfer(to, amount);
emit TokensWithdrawn(to, token , amount);
}

Risk

Likelihood:

Occurs in real usage when interacting with non‑standard or edge‑case ERC‑20 tokens. Typical scenarios include:

  • Using older or popular tokens that omit a boolean return (examples: legacy stablecoins historically deployed with different semantics).

  • Interacting with tokens that return false on failed transfers rather than reverting.


Impact:

  • Token withdrawals appearing successful while recipient receives no tokens, producing inconsistent bookkeeping.


Recommended Mitigation

  • Adopt OpenZeppelin’s SafeERC20 and use safeTransfer for all ERC‑20 interactions:

    • Add: import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; using SafeERC20 for IERC20;

    • Replace: IERC20(token).transfer(to, amount); with IERC20(token).safeTransfer(to, amount);

+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
+ using SafeERC20 for IERC20;
function withdrawTokens(address token, address to, uint256 amount) external onlyOwner {
- IERC20(token).transfer(to, amount)
+ IERC20(token).safeTransfer(to, amount);
emit TokensWithdrawn(to, token , amount);
}
Updates

Lead Judging Commences

chaossr Lead Judge 12 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!