The TokenManager contract manages user token balances through the userTokenBalanceMap mapping. This mapping is crucial for tracking user balances across different token types and balance categories. The withdraw() function in TokenManager.sol allows users to withdraw their tokens:
The critical issue is that after a successful withdrawal, the userTokenBalanceMap is not updated to reflect the withdrawn amount. This allows users to withdraw the same amount multiple times, draining the entire CapitalPool. This can be repeated for any token by simply depositing a small amount of each token present in CapitalPool, leading to a complete depletion of the CapitalPool.
Users can withdraw their entire balance multiple times, depleting the CapitalPool of funds.
An attacker can exploit this vulnerability to steal all tokens from the CapitalPool, even if they only deposited a small amount initially.
Add this PoC to test/PreMarkets.t.sol and run forge test --mt test_PoC_unlimited_withdrawals -vvvv:
Update the userTokenBalanceMap after each 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.