Anyone can keep withdrawing to drain the CapitalPool
as the balances have not been reset.
Alice creates an ASK offer for 1000 points and 1000 collateral
Bob accepts and creates an order to buy 1000 points
Alice is credited with 1000 SalesRevenue
Alice can keep spamming withdraw
to drain the pool, each call will get her 1000 collateral tokens
The issue is that balances are not subtracted when withdrawing here:
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L148
POC, run forge test --via-ir --match-test forge test --via-ir --match-test test_h1_withdrawal_drain -vv
:
Impact: High (total loss of funds, the vault is drained)
Likelihood: High (anyone can do it without pre-conditions)
Risk: Critical
Manual Review
In TokenManager
:
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L148
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.