# Can manipulate the C.SHORT_STARTING_ID ShortRecord of the TAPP

Transferring a ShortRecord NFT to the TAPP overwrites its C.SHORT_STARTING_ID record, corrupting TAPP debt accounting and blocking liquidation of risky debt.

- Payout: Audit contest
- Severity: medium
- Program: DittoETH
- Found by: klau5
- Disclosed: 2024-06-25
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-03-dittoeth-findings/issues/236
- Library page: https://bugbountylibrary.com/r/c4%3A2024-03-dittoeth%3AM-02
- Tags: area:web3 domain:web3 impact:integrity kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic

**Target:** DittoETH PrimaryLiquidationFacet / LibShortRecord / ShortRecord NFT transfer
**Root cause:** LibShortRecord.fillShortRecord reuses C.SHORT_STARTING_ID without removing it from the reusable-ID list, and transferShortRecord calls createShortRecord which reuses that same ID, overwriting the TAPP's active ShortRecord.
**Steps:**
1. Liquidate a short partially so TAPP absorbs leftovers into C.SHORT_STARTING_ID via fillShortRecord.
2. Fully liquidate the TAPP short so deleteShortRecord moves C.SHORT_STARTING_ID to the reusable ID list.
3. Trigger another partial liquidation so fillShortRecord recreates C.SHORT_STARTING_ID but leaves it in the reusable list.
4. Attacker mints a ShortRecord NFT (`diamond.mintNFT(asset, 2, 0)`) and transfers it to the TAPP (`diamond.transferFrom(attacker, tapp, 1)`).
5. createShortRecord reuses C.SHORT_STARTING_ID, overwriting TAPP's collateral/ercDebt values.
**How found:** Noticed that deleteShortRecord pushes C.SHORT_STARTING_ID to the reusable ID list while fillShortRecord recreates it without removing it from that list, then reasoned that transferShortRecord's createShortRecord would reuse the same ID and overwrite TAPP state.
**Exploitation:** Attacker mints a ShortRecord NFT and transfers it to the TAPP address, causing createShortRecord to reuse the stale C.SHORT_STARTING_ID and overwrite the TAPP's ShortRecord fields (collateral, ercDebt, ercDebtRate). This corrupts TAPP debt accounting so risky debts are not liquidated and accumulate.
**Insight:** When a contract maintains a free-list of reusable IDs, check every path that recreates an ID (fill/absorb) to confirm it is removed from the free-list; otherwise any external createShortRecord (e.g. NFT transfer) can collide with a privileged sentinel ID.

