The withdrawTokens function is designed to allow the owner to withdraw ERC20 tokens from the hook contract to a specified address. The function calls IERC20(token).transfer(to, amount) to perform the transfer and emits an event to log the withdrawal.
However, the function does not check the return value of the transfer call. Some ERC20 tokens (notably USDT) return false instead of reverting when a transfer fails. This means the withdrawal could silently fail while the contract emits a TokensWithdrawn event, creating a false record of a successful transfer when no tokens were actually moved.
Likelihood:
The owner attempts to withdraw tokens using a non-standard ERC20 implementation that returns false on failure rather than reverting
The transfer fails due to insufficient balance or other conditions, but the function continues execution
Impact:
The TokensWithdrawn event is emitted even though no tokens were transferred, creating misleading on-chain logs
The owner believes tokens were successfully withdrawn when they remain locked in the contract
Accounting discrepancies between expected and actual token balances could lead to operational issues
Alternatively, use OpenZeppelin's SafeERC20 library for more robust handling:
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.