The TokenManager::withdraw function fails to update users' claimable balances after withdrawal, allowing malicious users to drain the entire CapitalPool balance of a specific token.
In the withdraw function:
The claimable amount is fetched from TokenManagerStorage::userTokenBalanceMap.
Funds are transferred from CapitalPool to the user.
Crucially, userTokenBalanceMap is not updated post-transfer.
Without updating the balance it allows repeated withdrawals until the CapitalPool is drained of the specific token.
Users can withdraw more tokens than they're entitled to.
Potential for complete drainage of specific tokens from CapitalPool.
Loss of funds for other users with legitimate balances.
Foundry
Follow CEI and update the user's balance in userTokenBalanceMap before transferring funds:
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.