A malicious user can withdraw all the assets from the capital pool.
When a user wants to withdraw assets from the protocol, TokenManager.withdraw()
is being called. Internally the function checks what amount the user is able to withdraw.
The state var userTokenBalanceMap
is used to track how much a user can claim for each token and balance type. However claimAbleAmount
value is never reduced which leads to that a user is able to withdraw as long as there are assets of a particular ERC20 token in the CapitalPool.
Steps:
1) Before running the test modify TokenManager. There is another bug there(allowance is not updated properly) in the withdraw functionality which prevents the poc from working. This bug will be reported separately.
Changes needed:
TokenManager::_transfer(), modify
2) Paste the file in PreMarkets.t.sol
3) Run: forge test --mt test_infinite_withdraw_POC -vvvvv
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L141-L143
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L247
A malicious user can steal all the ERC20 assets stored inside CapitalPool
Manual review, foundry
Reduce the claimable amount at the end of TokenManager.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.