During withdrawing, the balance is not updated, providing an easy opportunity for a malicious user to withdraw multiple of times to drain the protocol.
When withdrawing, the balance is not updated. So it is possible to withdraw multiple of times to drain the protocol.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L137
In the following test, it is assumed that the capital pool holds $10k and the attacker holds $1k. Then the attacker creates an ask offer to buy 1 point for $1k. Then the attacker closes her offer. By doing so, the attacker can withdraw her deposited amount. Since during withdrawal, the attacker's balance is not updated, the attacker calls this function 11 times to drain the capital pool. The output shows the attacker's balance before and after.
The output is:
draining the protocol.
The balance should be updated:
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L137
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.