Tadle

Tadle
DeFi
30,000 USDC
View results
Submission Details
Severity: high
Valid

user can drain entire protocol due to missing update

Summary

user can drain entire protocol due to missing update

Context
TokenManager.sol#L141

Vulnerability Details

Users can withdraw from the added balance by calling the TokenManager.sol:withdraw() function. However after a user withdraws, it doesn't update the state of the balance allowing the user to call the withdraw again multiple times and until eventually draining the contract.

function withdraw(
address _tokenAddress,
TokenBalanceType _tokenBalanceType
) external whenNotPaused {
uint256 claimAbleAmount = userTokenBalanceMap[_msgSender()][
_tokenAddress
][_tokenBalanceType];
...
}

Impact

user can drain entire protocol due to missing update

Tools Used

Manual Review

Recommendations

Update the userTokenBalanceMap of the user to 0 after getting the value, here is the recommendation:

function withdraw(
address _tokenAddress,
TokenBalanceType _tokenBalanceType
) external whenNotPaused {
uint256 claimAbleAmount = userTokenBalanceMap[_msgSender()][
_tokenAddress
][_tokenBalanceType];
+ userTokenBalanceMap[_msgSender()][_tokenAddress][_tokenBalanceType] = 0;
...
}
Updates

Lead Judging Commences

0xnevi Lead Judge 10 months 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.