# The shortOrder verification bug on the RedemptionFacet::proposeRedemption() allows an attacker to leave a small shortOrder on the order book, leading to the protocol's bad debt

proposeRedemption loads shortOrder by attacker-supplied shortOrderId and only validates it inside the minShortErc branch, letting a redeemer keep a dust shortOrder alive and create unliquidatable bad-debt shortRecords.

- Payout: Audit contest
- Severity: medium
- Program: DittoETH
- Found by: serial-coder
- Disclosed: 2024-06-25
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-03-dittoeth-findings/issues/262
- Library page: https://bugbountylibrary.com/r/c4%3A2024-03-dittoeth%3AM-01
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic vuln:liquidation

**Target:** DittoETH RedemptionFacet::proposeRedemption / short order book
**Root cause:** The shortOrder loaded from s.shorts[asset][p.shortOrderId] is validated against shortRecordId and shorter only after the `shortOrder.ercAmount < minShortErc` condition, so a mismatched order id skips both validation and cancellation.
**Steps:**
1. Attacker creates a partially-filled shortRecord whose shortOrder.ercAmount < minShortErc (possible via DUST_FACTOR partial match in bidMatchAlgo).
2. Attacker uses a Sybil account to call `proposeRedemption(asset, proposalInput, redemptionAmount, maxRedemptionFee)` targeting that shortRecord.
3. In proposalInput set `shortOrderId` to a different shortOrder id whose ercAmount >= minShortErc.
4. Condition `currentSR.status == SR.PartialFill && shortOrder.ercAmount < minShortErc` is false, so the InvalidShortOrder check and `LibOrders.cancelShort` are skipped.
5. Targeted small shortOrder stays on the book; when matched again the shortRecord.ercDebt falls below minShortErc.
**How found:** Code reading of proposeRedemption: noticed shortOrder is fetched by user-supplied id and the identity check sits inside the minShortErc branch, so a mismatched id skips validation entirely.
**Exploitation:** Redeemer/Sybil proposes redemption against own dust shortRecord while pointing shortOrderId at an unrelated healthy order, bypassing cancellation; the dust shortRecord persists, is not liquidated (too small to incentivize) and cannot be redeemed, leaving bad debt.
**Escalation:** Place many small shortOrders to grief large Bid matches (gas exhaustion) and accumulate unliquidatable bad-debt positions.
**Insight:** When a function loads a user-supplied id and validates it only inside a conditional branch, check whether an attacker can pick an id that makes the branch false and skips both validation and the corrective action.

## Proof of concept (copied exactly from the original report)

**proposeRedemption shortOrder verification bypass code**

```
STypes.Order storage shortOrder = s.shorts[asset][p.shortOrderId]; //@audit -- The shortOrder is loaded from storage according to the attacker's p.shortOrderId param
@2          if (currentSR.status == SR.PartialFill && shortOrder.ercAmount < minShortErc) { //@audit -- The attacker can leave their target partially-filled shortOrder (corresponding to the redeeming shortRecord) with ercAmount < minShortErc alive by specifying the p.shortOrderId param to another shortOrder's id with ercAmount >= minShortErc
@3              if (shortOrder.shortRecordId != p.shortId || shortOrder.addr != p.shorter) revert Errors.InvalidShortOrder(); //@audit -- The root cause is that the proposeRedemption() verifies the loaded shortOrder against the legitimate shortRecordId and shorter params only after the condition in @2 was met
                LibOrders.cancelShort(asset, p.shortOrderId);
```

