cds owners can withdraw more than expected via manipulating excessProfitCumulativeValue
The withdraw function accepts a signed excessProfitCumulativeValue that is used to compute a depositor's profit, but the signature and value can be replayed across different withdrawals. A malicious CDS owner could reuse a smaller valid value from on-chain data to withdraw more profit than they are owed.
0x37 Follow with 0x73696d616f, 0xAristos and 17 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/469
Found by
0x37, 0x73696d616f, 0xAristos, Galturok, John44, Kral01, Laksmana, PeterSR, RampageAudit, Ruhum, Waydou, ZanyBonzy, newspacexyz, pashap9990, super_jack, t.aksoy, theweb3mechanic, tjonair, valuevalk, volodya
Summary
excessProfitCumulativeValue in withdraw() can be manipulated. Malicious users can manipulate this excessProfitCumulativeValue to withdraw more than expected.
Root Cause
In CDS.sol:withdraw, cds owners can withdraw their usda deposit.
In withdraw(), there is one parameter excessProfitCumulativeValue, we will use this parameter excessProfitCumulativeValue to calculate the cds owner's possible profit. Although this parameter excessProfitCumulativeValue is signed by the admin, the signature and excessProfitCumulativeValue can be replayed. When different cds owners withdraw, they will get the different excessProfitCumulativeValue and signature from the protocol's backend server. Malicious users can choose any valid excessProfitCumulativeValue, nonce and signature from on-chain data.
Malicious users can choose one smaller excessProfitCumulativeValue to trigger withdraw() function. Malicious users can get more profit than expected.
function withdraw(
uint64 index, // deposit index.
uint256 excessProfitCumulativeValue,
uint256 nonce,
bytes memory signature
) external payable nonReentrant whenNotPaused(IMultiSign.Functions(5)) {
if (!_verify(FunctionName.CDS_WITHDRAW, excessProfitCumulativeValue, nonce, "0x", signature)) revert CDS_NotAnAdminTwo();
function cdsAmountToReturn(
address _user,
uint64 index,
uint128 cumulativeValue,
bool cumulativeValueSign,
uint256 excessProfitCumulativeValue
) private view returns (uint256) {
...
uint256 profit = (depositedAmount * (valDiff - excessProfitCumulativeValue)) / 1e11;
...
}
Internal pre-conditions
N/A
External pre-conditions
N/A
Attack Path
N/A
Impact
Malicious users can withdraw more profit than expected via manipulating the excessProfitCumulativeValue and signauture.
PoC
N/A
Mitigation
Enhance the signature check. One signature can only be used for one cds owner's specific deposit index.
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 signature over excessProfitCumulativeValue is not bound to a specific user or deposit index, so valid signed values can be replayed.
Impact
A malicious CDS owner could withdraw more profit than expected by replaying a signed value.
What the attacker needed
A CDS deposit to withdraw; access to on-chain signed values
The fix
The signature check should be enhanced so that one signature can only be used for one CDS owner's specific deposit index.
How it was found
- Observe valid excessProfitCumulativeValue, nonce and signature pairs in on-chain data
- Pick a smaller excessProfitCumulativeValue with its matching signature
- Call withdraw with that value, nonce and signature to receive a larger profit
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 this contract, the amount of profit they get depends on a number the protocol's server signs. The contract only checks that the signature is valid, not that it belongs to this particular withdrawal, so a user can pick an older signed number that makes their payout bigger.
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.