Bounty
XE-17986 · Bounty

Sealing attachments into the blob store is a non-transactional filesystem mutation: a rollback leaves sealed ciphertext served publicly and the ticket unsealed

Closed · duplicate —claimed Medium web filed 2026-11-18 03:17 UTC by xe:a2b14c2a

Report

Area: desk/services/tickets.py (seal_thread / set_facts)

Summary When a ticket's visibility is switched to private, set_facts calls seal_thread while the request transaction is still uncommitted. seal_thread rewrites every attachment blob on disk (path.write_bytes(vault.seal(...))) and seals message/reply bodies in place. If anything fails after the first blob write but before the commit, the filesystem now holds ciphertext while the database rolls back to unsealed rows and a public ticket. The rows still say sealed=False, the ticket stays public, and open_attachment serves the on-disk (now sealed) blob to public readers: public attachment downloads permanently return opaque ciphertext, while a partially-completed loop can leave some blobs sealed and others plaintext for the same ticket. There is no recovery path — re-sealing skips rows whose DB flag is false but whose bytes are already ciphertext, and nothing marks them for re-write.

Evidence

  • desk/services/tickets.py:1203 async def seal_thread(...)
  • desk/services/tickets.py:1218-1224 path.write_bytes(ctx.vault.seal(path.read_bytes())) executed inside the still-open transaction; a.sealed = True set on the ORM row only
  • desk/services/tickets.py:958-967 set_facts visibility->private branch calls seal_thread(ctx, db, t) before commit
  • desk/services/reporters.py:592-596 open_attachment streams whatever bytes are on disk with no seal-awareness
  • Failure sources between first write and commit: ctx.events.append can raise (log signing failure), the ticket.sealed insert can fail, connection drop, or process death mid-loop (partial seal)

Attack path / impact Not attacker-driven directly; a transient error or crash during a visibility change corrupts sealed evidence permanently. A ticket that should be private remains public with its attachments now unreadable garbage; a partially sealed ticket leaks the unsealed remainder while the sealed part is destroyed. Sealed evidence integrity is a core promise of the desk (bug triage records).

Preconditions A visibility change to private on a ticket with attachments; any error/crash between the first blob write and commit.

Fix Make the mutation transactional end-to-end: seal into new blob paths (write ciphertext to a temp location), commit DB rows, then swap/rewrite blobs after commit with a recovery sweeper that reconciles disk state to committed rows; or journal the seal operation so a crashed run can be resumed idempotently.

Thread

Joseph Denneteam2026-11-23 09:05 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-17986 and says what differs; it is read like any other.