Closing a SR during a wrong redemption proposal leads to loss of funds
A redemption proposal can list short records that are later closed before anyone disputes it, and the dispute logic then adds the penalty collateral to the already-closed record instead of returning it. This means the proposer's funds are effectively lost when a wrong proposal is disputed after one of its short records has been closed.
Submitted by Cosine, also found by klau5
Impact
When a user creates a redemption proposal with the proposeRedemption function the user has to provide a list of the short records (SRs) with the lowest collateral ratios (CR) in the system ascending.
To prevent users from creating proposals with a wrong SR list, anyone is allowed to dispute proposals with the disputeRedemption function. This function allows the disputer to prove that a SR with a lower CR was not included in the proposal and for doing so the disputer receives a penalty fee from the proposer.
If between these flows of creating a wrong proposal and disputing it a SR is closed (liquidation, exiting, transfer, …) the collateral is added to the closed SR and can not be recovered.
Proof of Concept
The following POC can be implemented in the Redemption.t.sol test file:
function test_dispute_on_non_existing_sr() public {
// setup shorts
makeShorts({singleShorter: true});
_setETH(1000 ether);
skip(1 hours);
STypes.ShortRecord memory sr1 = diamond.getShortRecord(asset, sender, C.SHORT_STARTING_ID);
STypes.ShortRecord memory sr2 = diamond.getShortRecord(asset, sender, C.SHORT_STARTING_ID+1);
STypes.ShortRecord memory sr3 = diamond.getShortRecord(asset, sender, C.SHORT_STARTING_ID+2);
uint256 cr1 = diamond.getCollateralRatio(asset, sr1);
uint256 cr2 = diamond.getCollateralRatio(asset, sr2);
uint256 cr3 = diamond.getCollateralRatio(asset, sr3);
// CRs are increasing
assertGt(cr2, cr1);
assertGt(cr3, cr2);
// user creates a wrong proposal
MTypes.ProposalInput[] memory proposalInputs =
makeProposalInputsForDispute({shortId1: C.SHORT_STARTING_ID + 1, shortId2: C.SHORT_STARTING_ID + 2});
address redeemer = receiver;
vm.prank(redeemer);
diamond.proposeRedemption(asset, proposalInputs, DEFAULT_AMOUNT * 3 / 2, MAX_REDEMPTION_FEE);
// on of the SRs in the proposal is closed
fundLimitAskOpt(DEFAULT_PRICE, DEFAULT_AMOUNT / 2, extra);
exitShort(C.SHORT_STARTING_ID + 2, DEFAULT_AMOUNT / 2, DEFAULT_PRICE, sender);
// SR is now closed
sr3 = diamond.getShortRecord(asset, sender, C.SHORT_STARTING_ID+2);
assertEq(uint(sr3.status), uint(SR.Closed));
uint88 collateralBefore = sr3.collateral;
// another user disputes the wrong proposal
address disputer = extra;
vm.prank(disputer);
diamond.disputeRedemption({
asset: asset,
redeemer: redeemer,
incorrectIndex: 0,
disputeShorter: sender,
disputeShortId: C.SHORT_STARTING_ID
});
// SR is still closed and collateral increased
sr3 = diamond.getShortRecord(asset, sender, C.SHORT_STARTING_ID+2);
assertEq(uint(sr3.status), uint(SR.Closed));
assertGt(sr3.collateral, collateralBefore);
}
Recommended Mitigation Steps
Opening up the SR again if it’s closed would be a solution, but it could probably be misused to avoid liquidations. Therefore, carefully think about the implications of changes in this context.
Assessed type
Context
ditto-eth (DittoETH) confirmed
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 logic credits the penalty to the short record without checking whether that record is still open, so collateral is added to a closed record that can no longer be withdrawn.
What the attacker needed
A redemption proposal exists; a listed short record is closed; another user disputes the proposal
The fix
The dispute logic should check whether the short record is still open before crediting the penalty, and the report warns that simply reopening closed records could be misused to avoid liquidations.
How it was found
- Create a redemption proposal that omits a short record with a lower collateral ratio.
- Close one of the short records included in the proposal, for example by exiting it.
- Have another user dispute the proposal, pointing at the omitted lower-ratio short record.
- Observe that the closed short record's collateral increases and the funds cannot be recovered.
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.
A short record is a position in the protocol that holds collateral. A user can propose redeeming against a list of these positions, and anyone can challenge the proposal if the list is wrong, paying a penalty to the proposer. The bug is that if one of the listed positions is closed before the challenge happens, the penalty money goes into that closed position and cannot be taken out again.
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.