The withdraw()
function in the TokenManager contract does not verify if the actual amount of tokens transferred matches the intended withdrawal amount. This could lead to discrepancies between the recorded and actual token balances.
The current implementation of the withdraw()
function does not check if the amount of tokens actually transferred matches the amount that was supposed to be withdrawn:
While the transfer
function returns a boolean indicating success or failure, it doesn’t guarantee that the exact amount was transferred. Some tokens may have transfer fees or other mechanisms that could result in a smaller amount being received than expected.
This vulnerability could lead to inconsistencies between the recorded token balances in the contract and the actual token balances. In the worst case, it could be exploited by malicious token contracts to drain more funds than intended from the TokenManager.
manual code review
Implement a balance check before and after the transfer to verify the exact amount transferred:
Use OpenZeppelin's SafeERC20
library for safer token transfers:
Consider implementing a tolerance threshold for tokens with transfer fees:
This way the contract will ensure that the actual amount of tokens transferred matches the expected amount, preventing potential exploits and maintaining accurate balance records.
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.