The withdraw
function in TokenManager.sol
contains a vulnerability that allows a single user to repeatedly withdraw claimable tokens until the pool is drained. This occurs because the function does not reset the user's balance to zero after a withdrawal, enabling reentrancy attacks.
Location: TokenManager.sol::withdraw
The withdraw
function is designed to allow users to withdraw claimable tokens. However, it does not reset the userTokenBalanceMap
for the user after the tokens are withdrawn. As a result, a malicious user can call the withdraw
function multiple times in quick succession, draining the token pool.
The user's claimable amount is fetched and used for the withdrawal, but it is not reset to zero afterwards, allowing the same amount to be withdrawn multiple times.
This vulnerability allows a single user to drain the entire pool of tokens by repeatedly withdrawing the same claimable amount. This can lead to a complete depletion of the token reserves, causing significant financial loss to the contract and its users.
Manual review
Reset User Balance After Withdrawal:
Update the withdraw
function to reset the user's balance to zero after a successful withdrawal.
Valid critical severity finding, the lack of clearance of the `userTokenBalanceMap` mapping allows complete draining of the CapitalPool contract. Note: This would require the approval issues highlighted in other issues to be fixed first (i.e. wrong approval address within `_transfer` and lack of approvals within `_safe_transfer_from` during ERC20 withdrawals)
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.