{"id":"XE-13262","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"386","source_url":"https://github.com/xeprotocol/xe/issues/386","reporter_id":1787,"title":"core/quorum: orphaned conflict drop leaks staged block bodies (record and votes deleted, bodies never deleted)","area":"consensus","claimed_tier":null,"assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:05.505561+00:00","updated_at":"2026-11-21T08:11:08.206757+00:00","source_created_at":"2026-11-11T12:56:57+00:00","told_at":"2026-11-20T00:15:41+00:00","status_changed_at":"2026-11-20T00:15:29.724748+00:00","url":"https://bounty.xe.network/XE-13262","body":"## Summary\n\n`QuorumManager.dropConflictIfOrphaned` deletes the conflict record and its votes but never deletes the staged block bodies saved for that position. Once the record is gone the bodies are unreachable — `GetAllConflicts` is empty and nothing references their hashes — so they persist in the store indefinitely with attacker-chosen size. The sibling path (`cleanupResolvedConflict`) does delete staged bodies, so this is an asymmetry, not intended behaviour.\n\n## Affected code\n\n| Location | Fact |\n|---|---|\n| `core/quorum.go:446-460` | `dropConflictIfOrphaned`: `DeleteVotesForConflict` + `RemoveConflict` only — no `DeleteStagedBlock` |\n| `core/quorum.go:388-410` | `cleanupResolvedConflict` calls `DeleteStagedBlock` for the winner (391) and every loser (398) |\n| `core/quorum.go:486-518` | `conflictOrphanedByRollback`: position dead + no candidate on chain + one candidate `StatusRejected` |\n| `core/quorum.go:523-545` | `sweepStaleConflicts` drives the orphan path |\n| `core/store.go:136`, `store/badger_store.go:1074`, `store/mem_store.go:240-242` | `RejectHash` from rollback/cascade marks the losing candidate `StatusRejected` |\n| `core/types.go:21-23` | `DeleteStagedBlock` is part of `ConflictStore`, so this is not an API limitation |\n\n## Reproduction\n\n1. Two competing blocks at the same position are staged and a `Conflict` record is created.\n2. A rollback/cascade marks one candidate `StatusRejected` (`BlockUndo.RejectHash`) and the parent leaves the canonical chain, so `conflictOrphanedByRollback` returns true.\n3. `sweepStaleConflicts` → `dropConflictIfOrphaned` deletes the votes and the conflict record.\n4. The staged bodies remain. No code path can enumerate or delete them afterwards.\n\n## Executed evidence\n\nTest run against the real function on a copy of the pinned commit `89a542e`, with a fake store implementing `Store` + `ConflictStore` + `VoteStore` + `QuorumStore`:\n\n```\n--- RUN   TestOrphanDropLeaksStagedBodies\nquorum: dropping orphaned conflict aa0000000000...|0 — its chain position was rolled back (a candidate is rejected and the parent is no longer on the canonical chain)\n    orphan leak: badan staged bb0000000000 masih tersimpan setelah orphan-drop (mskeyset=0)\n    orphan leak: badan staged cc0000000000 masih tersimpan setelah orphan-drop (mskeyset=3500)\n    sisa 2 badan staged (0 pemanggilan DeleteStagedBlock) — harus 0 setelah orphan drop\n--- FAIL: TestOrphanDropLeaksStagedBodies (0.00s)\n```\n\nControl assertion that passes: the conflict record is genuinely deleted; the leak is in the bodies.\n\n## Impact\n\nPersistent, unauthenticated storage exhaustion. Every orphaned conflict permanently retains every candidate body staged for it (body size is attacker-controlled — e.g. a `multisig_update` block with a large keyset), and no operator-visible reference remains to audit or reclaim it. Repeated across accounts and positions this grows the staging store without bound, since it is never compacted.\n\n## Suggested fix\n\nIn `dropConflictIfOrphaned`, iterate `c.BlockHashes` and call `DeleteStagedBlock` for each hash, mirroring `cleanupResolvedConflict`. Optionally reject staged bodies above the block-size limit at save time.\n\n## Notes\n\n- **Duplicate check:** checked issues — no duplicate as of 2026-11-11 (closest: #226 conflict-store asymmetries, #43 swap cannot unwind lease/multisig descendants, #328/#329 conflict RMW/snapshot, #345 synchronization; none mentions staged bodies left behind by the orphan-drop path).\n- **Evidence status:** executed unit-level proof against the real function on commit `89a542e`; no badger-byte measurement before/after, and the live-testnet frequency of the orphan path is not measured.\n- **XE Address for Reward:** `b83e7e31358b8c1e1509de6cd34e7540425eb17a190e48b486909df11080033d`\n\n\n\n> Reward address updated to the official desk-bound address.\n","patch_refs":[{"id":556,"repo":"xeprotocol/xe","kind":"pr","ref":"416","title":"fix(core/quorum): delete staged block bodies when dropping orphaned conflicts (#386)","url":"https://github.com/xeprotocol/xe/pull/416","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-11-14T20:42:20.090956+00:00"}],"thread":[{"id":12909,"source":"github","source_ref":"7026049267","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have read it against the code and confirmed the behaviour it describes; it is being handled. The assessment and any award follow the fix.","created_at":"2026-11-20T00:15:41+00:00"},{"id":16452,"source":"web","source_ref":"reporter:1787:dc892c4b0f2a987d","author":"jalesfeva","team":false,"body":"Appreciate the confirmation, I'll wait for the fix and assessment","created_at":"2026-11-21T08:11:08.188331+00:00"}]}