If a redemption has N disputable shorts, it is possible to dispute N-1 times the redemption to maximize the penalty
The redemption dispute mechanism allowed a disputer to split a single dispute into multiple smaller disputes, each applying a penalty based on a higher collateral ratio difference, resulting in a larger total penalty than disputing the whole proposal at once. An attacker could exploit this to extract more funds from the redeemer as a disputer reward.
Submitted by Infect3d
Ditto is a decentralized CDP protocol allowing users to get stablecoins (called dUSD here) against LST (Liquid Staking Tokens like stETH or rETH) collateral. Depositing LST grant dETH, a shares representing the value deposited in ETH. Users can then open different kind of positions: bids, asks or shorts, each one having its own orderbook.
Ditto implemented a mechanism called Redemption, idea borrowed from Liquity. Redemption allows anyone to redeem dUSD for a value of exactly 1 USD by calling out shorts with very bad CR (collateral ratio) and closing them. This helps the protocol to keep a healthy global market CR, shorters to not be liquidated, and dUSD holders to redeem dUSD with no loss in case of dUSD trading below 1 USD.
Users can propose multiple shorts to be redeemed at once if they meet certain conditions (see Constraints in doc). The shorts must be sorted from lowest CR to highest CR, and all CRs must be below a CR of 2. If a proposal do not properly follow these rules, anyone can dispute the proposal by showing a proof-short: all proposal shorts with a CR higher than the proof become invalid.
For each invalid short, a penalty is applied to the redeemer (and awarded to the disputer) The penalty calculation is based on the CR difference between the disputeCR (proof) and the the currentProposal.CR (lowest invalid CR):
Note: please see scenario in warden’s original submission.
The issue is located in this part of the mechanism and is pretty easy to understand. Let’s imagine 4 shorts in a list of shorts: … < CR1 < CR2 < CR3 < CR4 < … CR1 = 1.1, CR2 = 1.2, CR3 = 1.3, CR4 = 1.4, and all have an ercDebt of 1 ETH.
Redeemer propose [CR2, CR3, CR4] to redeem.
Disputer sees that there is in fact CR1 that is lower than all the proposed shorts.
Disputer could dispute the proposal by giving CR1 as a proof, and CR2 as the invalid CR, which would also invalid all higher CRs in the proposal. This would give (let’s take callerFeePct value from tests, 0.005 or 0.5%):
penaltyPct =min( max(0.005, (1.2 - 1.1)/1.2 ), 0.33) = min( max(0.005, 0.091), 0.33) = 0.091.penaltyAmt =(1 + 1 + 1)ETH * 0.091 = 3 * 0.091 = 0.273 ETH.
The vulnerability lies in the fact that the disputer can dispute this proposal 3 times:
- 1st: dispute CR4 with CR1.
- 2nd: dispute CR3 with CR1.
- 3rd: dispute CR2 with CR1.
By doing this, the disputer will get penalty applied 3 times, and in some case, the total penalty using this trick will be higher than the penalty when disputing the whole proposal at once, as shown in the coded proof of concept.
For CR1:
penaltyPct =min( max(0.005, (1.4 - 1.1)/1.4 ), 0.33) = 0.214.penaltyAmt =1 ETH * 0.214 = 0.214 ETH.
For CR2:
penaltyPct =min( max(0.005, (1.3 - 1.1)/1.3 ), 0.33) = 0.142.penaltyAmt =1 ETH * 0.214 = 0.142 ETH.
For CR3:
penaltyPct =min( max(0.005, (1.2 - 1.1)/1.2 ), 0.33) = 0.091.penaltyAmt =1 ETH * 0.091 =0.091 ETH.
sum of penaltyAmt = 0.447 ETH.
We can see here how more beneficial it to adopt the second strategy.
Impact
Higher penalty than expected for redeemer, higher reward for disputer.
Proof of Concept
Copy this gist to test/Redemption.t.sol and run the tests by executing forge test -vvv --mt AuditDisputeRedemption.
You’ll get that output, showing that disputing redemptions one by one give a higher penalty:
Running 2 tests for test/Redemption.t.sol:RedemptionTest
[PASS] test_AuditDisputeRedemptionAllAtOnce() (gas: 2213036)
Logs:
redeemer reward: 7.69230769230769231e21
[PASS] test_AuditDisputeRedemptionOneByOne() (gas: 2250699)
Logs:
redeemer reward: 3.846153846153846155e21
redeemer reward: 4.166666666666666665e21
Recommended Mitigation Steps
If a user gives N as the incorrectIndex in the disputed proposal, knowing that the proposal is sorted from lowest to highest CR, ensure that proposal[N-1].CR <= disputeCR (revert in that case).
Assessed type
Math
ditto-eth (DittoETH) confirmed, but disagreed with severity and commented:
Really good find. Looks like the formula can be exploited to give a higher fee than intended. That said, I’m leaning more towards low/medium because the only effect is a higher fee for the disputer, incorrect proposals should happen very rarely from an honest user, and this doesn’t affect the redemption from working properly.
hansfriese (judge) decreased severity to Medium and commented:
I agree Medium is more appropriate.
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
Likely the dispute function does not verify that the provided proof short is the lowest collateral ratio among the invalid shorts, allowing multiple disputes on the same proposal with the same proof.
Impact
The redeemer pays a higher penalty than expected, and the disputer receives a higher reward; the redemption itself still works, and the issue is unlikely to occur with honest users.
What the attacker needed
A redemption proposal with multiple disputable shorts; The disputer must have a valid proof short with lower CR
How it was found
- Create a redemption proposal with shorts that have higher collateral ratios than an existing lower one.
- Dispute the proposal multiple times, each time using the lower collateral ratio short as proof and a different invalid short from the proposal.
- Observe that the total penalty from multiple disputes exceeds the penalty from a single dispute of the whole proposal.
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.
In this system, users can propose to redeem stablecoins by closing certain risky positions. If the proposal is invalid, someone can dispute it and earn a penalty from the proposer. The bug is that instead of disputing the whole proposal once, a disputer can dispute it multiple times, each time targeting a smaller part, and each dispute calculates a penalty based on a larger difference, so the total penalty becomes bigger than intended.
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.