The TokenManager::withdraw
function does not follow the Check-Effects-Interactions (CEI) pattern. After calculating the amount to claim, the user’s balance is not updated, allowing the user to repeatedly call the function and drain the contract's balance.
The vulnerability is present in the TokenManager::withdraw
function:
The user’s userTokenBalanceMap
is not updated after the calculation. As a result, the funds associated with each token are at risk. The user can repeatedly call the withdraw
function and still retain the same balance in userTokenBalanceMap
. This issue is demonstrated in the following proof of concept (PoC):
All funds in the protocol can be drained. If a user has a balance for a token, they can repeatedly withdraw until the entire balance of the contract is depleted.
Manual code review
Foundry
Update the userTokenBalanceMap
to zero immediately after calculating the claimable amount and before the transfer. Follow the Check-Effects-Interactions pattern.
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.