An attacker can drain the CapitalPool() contract of any collateral token because the withdraw() function in TokenManager() doesn't update balance information in userTokenBalanceMap prior to transferring tokens.
An attacker can call createOffer() to create an offer. Once a taker calls createTaker() on their offer, the attacker's SalesRevenue TokenBalance will be non-zero (note, attack could even do this themself from another address). Now the attacker can repeatedly call the withdraw() function passing in TokenBalanceType.SalesRevenue to drain the CapitalPool() contract of the collateral tokens that they used in their original offer.
Here's a POC (add to PreMarket.t.sol) showing the CapitalPool.sol contract being drained:
Loss of funds.
Manual Review / Foundry
Update the userTokenBalanceMap prior to transfer tokens in withdraw()
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.