openai / openai/codex-security

Malformed complete multiscan receipts permanently block campaign resume

Open
#133 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:bulk-scan area:reports bug priority:p2
Dominant language
TypeScript
Stars
10.8k
Forks
801
Avg merge
1d 8h
Merged PRs (30d)
257

Description

Summary

Multiscan receipt recovery handles only one corruption shape: a final line without a terminating newline.

Relevant code: readReceipts lines 312-335.

The complete ledger is read into memory and split. Every newline-terminated line is passed directly to JSON.parse, cast to MultiscanReceipt, and immediately accessed through receipt.id.toLowerCase().

Consequently, any of the following throws on every future resume:

  • malformed JSON in the middle of the ledger;
  • a malformed final line that does end with a newline;
  • valid JSON that is not an object;
  • a receipt with a missing or non-string id;
  • structurally invalid attempt, status, or path fields.

The ledger also has no total-size or per-line limit.

Why this matters

A crash, disk fault, partial external write, or manual damage to one durable record can wedge the entire campaign until the user edits internal state. The current recovery behavior may give users the impression that receipt-ledger interruption is generally recoverable, although only a torn final line is repaired.

Expected behavior

Receipt loading should either recover safely from invalid durable records or stop with an actionable corruption diagnostic and a supported recovery path. It should never fail with an incidental JSON/type exception indefinitely.

Suggested direction

Stream the ledger with a maximum line and total size, schema-validate every receipt, and distinguish a recoverable tail from corruption of committed history. Invalid committed lines could be moved to a quarantine file before resuming, with the original ledger retained for diagnosis.

Add tests for malformed newline-terminated JSON, non-object JSON, missing IDs, invalid attempts/statuses, and oversized lines.

Found by static audit of upstream main at 9c7634b.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sdk/typescript/src/multiscan.ts, especially readReceipts at lines 312-335, and inspect how complete ledgers are split and parsed. Add coverage for malformed JSON, non-object values, missing or invalid receipt fields, and oversized lines. Done means resume either recovers safely or reports actionable corruption rather than throwing incidental JSON or type errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.