10% of CDS depositors profit are stuck in the treasury during withdrawal without a way to retrieve them
When a user withdraws from the CDS, 10% of their profit is sent to the treasury and recorded, but no function exists to withdraw or use those funds. As a result, that portion of profit remains permanently stuck in the treasury.
0x37 Follow with Audinarey, almurhasan and 1 other
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/526
Found by
0x37, Audinarey, almurhasan, valuevalk
Summary
During withdrawal from the CDS, 10% of the USDa profit of the user are sent to the treasury. However there is no way to withdraw these funds from the treasury and as such they are stuck forever.
Root Cause
File: CDS.sol
334: @> uint256 optionFees = ((cdsDepositDetails.normalizedAmount * omniChainData.lastCumulativeRate) /
335: (CDSLib.PRECISION * CDSLib.NORM_PRECISION)) - cdsDepositDetails.depositedAmount;
343: uint256 currentValue = cdsAmountToReturn( // @audit-info value to return (i.e depositedAmount ± profit)
344: msg.sender,
345: index,
346: omniChainData.cumulativeValue,
347: omniChainData.cumulativeValueSign,
348: excessProfitCumulativeValue
349: ) - 1; //? subtracted extra 1 wei
350:
351: cdsDepositDetails.depositedAmount = currentValue;
352: uint256 returnAmount = cdsDepositDetails.depositedAmount + optionFees;
353: @> cdsDepositDetails.withdrawedAmount = returnAmount;
currentValueis the user'sdepositedAmount ± profitandreturnAmountis thedepositedAmount ± profit + optionFeeswhich is now thecdsDepositDetails.withdrawedAmount
params.usdaToTransfer is the amount of USDa that is finally transferred to the user but not all the cdsDepositDetails.withdrawedAmount above is transferred because 10% of this amount is transferred to the treasury and recorded as usdaCollectedFromCdsWithdraw by calling updateUsdaCollectedFromCdsWithdraw()
File: CDSLib.sol
800: //Calculate the usda amount to give to user after deducting 10% from the above final amount @audit HIGH: the remaining 10% is stuck in the treasury!
801: params.usdaToTransfer = calculateUserProportionInWithdraw(params.cdsDepositDetails.depositedAmount, returnAmountWithGains);
802: //Update the treasury data
803: @> interfaces.treasury.updateUsdaCollectedFromCdsWithdraw(returnAmountWithGains - params.usdaToTransfer);
File: Treasury.sol
493: function updateUsdaCollectedFromCdsWithdraw(
494: uint256 amount
495: ) external onlyCoreContracts {
496: @> usdaCollectedFromCdsWithdraw += amount;
497: }
The problem is that unfortunately, this amount is never removed from the treasury by any means or used anywhere.
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
10% of profit during withdrawa are stuck in the treasury forever
PoC
No response
Mitigation
Consider implementing a function to withdraw this usdaCollectedFromCdsWithdraw from the treasury or better still account for it elsewhere.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The treasury records the 10% cut in a variable but provides no function to withdraw or otherwise use those funds.
Impact
10% of the profit from each withdrawal is permanently stuck in the treasury, reducing the funds available to users.
What the attacker needed
None
The fix
A function should be added to withdraw the collected amount from the treasury, or the funds should be accounted for elsewhere.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When someone takes their money out of a savings pool, a small cut of their profit is moved to a central fund called the treasury. The report says there is no way to take money out of that fund, so that cut is lost forever.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.