withdrawTokens ignores transfer return value, causing silent failures and incorrect event emission for non-reverting tokensDescribe the normal behavior in one or more sentences
Explain the specific issue or problem in one or more sentences
Likelihood:
Occurs when withdrawing non-reverting ERC20 tokens
Owner performs routine token withdrawals/recovery. Transfer fails (insufficient balance, paused token, etc.) but function succeeds
Impact:
Tokens remain stuck in contract despite successful function execution, TokensWithdrawn event misleads off-chain systems and users
Owner may not realize withdrawal failed until checking balances manually
Repeated attempts waste gas without recovering tokens
This test demonstrates how withdrawTokens silently fails when using non-reverting ERC20 tokens. A mock token is created that returns false instead of reverting on transfer failure, simulating real-world tokens with non-standard behavior. When the owner attempts to withdraw tokens, the function completes successfully and emits the TokensWithdrawn event, but the actual transfer fails. The tokens remain stuck in the hook contract while the owner believes the withdrawal succeeded based on the emitted event and successful transaction.
Use OpenZeppelin's SafeERC20 library which provides safeTransfer() to handle both reverting and non-reverting ERC20 tokens correctly. The safeTransfer() function checks the return value and reverts if the transfer fails, ensuring tokens are actually transferred before emitting the event. This prevents silent failures where non-compliant tokens (like USDT) return false instead of reverting on failure, which would otherwise allow the function to complete successfully despite no tokens being transferred.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.