Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: high
Valid

User can drain all funds from the protocol

Summary

Malcious user can drain all funds from the protocol

Vulnerability Details

Funds are added to a user's userTokenBalanceMap through various ways by respective contracts, either from sale of points or getting collateral anything.

https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/TokenManager.sol#L113-L129

The issue stems from when a malicious user tries to withdraw with TokenManager.withdraw() , their accounting balance isn't decuted or set to zero, so they can keep coming back and keep withdrawing until all protocol funds are drained.

https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/TokenManager.sol#L137-L189

Impact

All protocol funds are drained or lost

Tools Used

Manual review

Recommendations

After a user is done withdrawing set the userTokenBalanceMap to zero in TokenManager.sol since there is no option to withdraw part of funds

Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-TokenManager-withdraw-userTokenBalanceMap-not-reset

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)

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.