Skip to content

fix(mac): scrub every held secret from the support bundle - #1267

Draft
iamfatness wants to merge 13 commits into
mainfrom
fix/mac-support-bundle-secrets
Draft

iamfatness wants to merge 13 commits into
mainfrom
fix/mac-support-bundle-secrets

Conversation

@iamfatness

@iamfatness iamfatness commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes secret scrubbing in the macOS support bundle only. No crash report, crash upload or telemetry-sending code (#1254 is untouched).

Leaked on main (each proven by a failing test with fake secrets)

As free text in logs, warnings or snapshots (shapes the pattern rules cannot know):

  • SRT passphrase and SRT Stream ID
  • Zoom OAuth access and refresh tokens
  • passcodes in the join link and in recent meetings
  • the control API token

Also:

  • JSON-escaped and URL-encoded copies of any held secret, including the ones main did hold
  • held secrets in dictionary keys that need JSON escaping
  • the remainder of a secret that contains or overlaps another
  • a literal quoted in manifest.txt, which was never re-checked
  • the headless export had no literals at all
  • two quadratic pattern rules (someKey=value, JWT) let one long unbroken line stall the export
  • on very long segments ICU can give up silently, leaving the rest of a string unfiltered

Change

  • SupportBundleSecrets is the single list of held secrets. It covers the editable and every streamed destination (Stop does not forget them), meeting passcodes on any host, the Zoom, YouTube and Twitch sign-ins, the Zoom environment secrets the core inherits, the control token, and a valid HLS ingest URL.
  • LiteralScrubber matches each character raw, percent-encoded, JSON-escaped (nested) or in a canonically equivalent Unicode spelling. It is a state-set matcher, not a regex, and never normalizes the scanned text.
  • Never less than main, by construction. The app passes main's exact literal list as a floor, and main's pipeline over that list is replayed as one view. The output removes the union of that view, the rules on the untouched text, and the rules on text with every spelling removed. Further views can only remove more. Tests compare against a verbatim copy of main's redactor with seeded random differentials.
  • Dictionary keys are filtered like values (main did not filter keys). Colliding keys are numbered. No key exemption list: no real diagnostic key name in the sources has the opaque-token shape.
  • If the matcher gives up, the whole string is dropped.
  • Multi-line secrets: the whole log text is searched before it is split into lines, so short lines go with the intact value. Each line with at least 4 non-whitespace characters is also a literal; blank lines never are.
  • A secret holding U+0000 (from a crafted ?pwd=...%00) no longer crashes the export. It is still matched whole, through a bounds-checked search; its long enough sides are literals too, and the floor stays main's list unchanged.

Known residuals

  • "Never less than main" rests on construction plus testing, not a proof. The floor view uses a tracked replay of main's replace and the rewritten (equivalent in differentials, now linear) rules, and the whole-file final pass is not a replay of main's. The reviewer found no case of visible text main removed with single-line secrets. A multi-line secret that does not appear intact (log line prefixes, LF against CRLF, a tail cut inside it, an indented line logged without its indent) can leave short or indented lines. One random NUL/U+FEFF/U+200D sample left an extra invisible U+FEFF that belongs to neither secret; not diagnosed.

  • Secrets changed, cleared, rotated or signed out earlier (other than streamed destinations) are not literals. The shell log persists across launches.

  • Values under 4 characters, and Stream IDs under 6 characters or equal to a common word, are not matched.

  • Encodings not matched: JSON-escaped then URL-encoded, form + encoded twice, HTML entities, singleton code points that only a non-held spelling would produce (except where Foundation's search equates them).

  • Per-join ZAK, OAuth broker token and Twitch device code are not retained, so only pattern rules cover them.

  • Pre-existing: the final pass edits JSON files as text, so a numeric secret can make invalid JSON; a log tail with no newline keeps its partial first line.

  • A plain-word secret that is not excluded can over-redact diagnostics.

  • The headless export now reads the app's own Keychain items; a differently signed build could be prompted.

Test plan

  • New bundle-secrets/* cases, fake secrets and in-memory Keychain only; the first set was red on unfixed main (105 failures)
  • Mutation checks: 53 on the code up to 92893f42, then 10 on the multi-line fix and 6 on the NUL follow-ups, each red once its test gap (two survivors) was closed. The earlier set was not rerun after the last changes. The quadratic someKey=value mutation last ran on an earlier commit (73 s against a 5 s limit)
  • Full shell suite, release: 13067 checks, 2 failures, both the known .m4a duration cases. One earlier run also failed the audio sync nudge case, which alone then failed 1 of 3 runs (flaky)
  • Redaction self-check, design lint, camera extension version gate
  • Large inputs: the slowest synthetic 1 MB shape is about 8 s; one 2 MB line with 60k literal hits is about 4 s
  • Independent security review given the diffs: five rounds, then a fresh reviewer on the multi-line fix and its two follow-ups; no must-fix on 81107b6a
  • Merged current origin/main (docs only)
  • CI on the head commit

🤖 Generated with Claude Code

John Wallace and others added 13 commits November 27, 2026 08:14
…ort bundle

The known-literal layer omitted the SRT passphrase and Stream ID, the Zoom
OAuth tokens, join-link passcodes and the control API token, and matched a
literal only as typed, so JSON-escaped and URL-encoded copies survived.
Dictionary keys were not scrubbed, overlapping literals left a remainder,
the manifest was never re-checked, and the headless export had no literals.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the bundle scrub

- NFC, NFD, mixed and partly composed spellings of a held secret match, in
  every escaped form; the scanned text is never normalized.
- Include the destinations frozen at Start, the Zoom secrets the core reads
  from the environment, ?pwd= on any host or in a pasted invite, the HLS URL.
- Do not blank long diagnostic dictionary keys; skip a Stream ID that is one
  of the bundle's own words.
- Anchor the someKey=value rule to the start of a run: it was quadratic.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Only a valid HLS playlist URL is a literal (a half-typed one disabled the
  user:password rule), plus its path/stem prefix as the core does.
- Keep every destination streamed this session, so Stop does not forget it.
- Cut join-link passcodes free of surrounding punctuation; handle &amp; and
  wrapped links.
- Make the JWT rule linear without changing its matches.
- Cover secrets whose first character is escaped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Drop the opaque-token exemption for keys: no real diagnostic key has that
  shape, and an unheld token used as a key survived.
- Run Foundation's literal replace after the matcher, as main did: it also
  equates singleton code points in the text.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ives up

- On a line with a literal hit, remove the union of: every literal
  occurrence, what the rules remove from the untouched text, and what a
  plain replace followed by the rules removes. A literal can no longer take
  away the anchor a rule needs.
- ICU gives up silently on very long segments: drop the whole string then.
- Keep the as-held form beside the trimmed one; hold an HLS path only when
  it has a distinctive part; decode pasted links word by word.
- Tests compare against a verbatim copy of main's redactor, with a seeded
  random differential.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…iteral

- Pass the list the bundle has always replaced through as a floor, replayed
  exactly: the output can then never show more than before, whatever the
  longer list or the other views do.
- Run the rules on text with every secret spelling removed, so a rule an
  escaped secret had stopped reaches its neighbour.
- A literal holding U+0000 (from ?pwd=...%00) crashed the export.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Main matched such a value only in its whole-file pass; a rule taking part of
it in the per-line pass left a rest that pass no longer recognised. Tests
now compare markers by code unit, not by grapheme.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…k line a literal

- A line under 4 characters of a multi-line secret stayed once its other
  line was replaced, which main's whole-file pass would have removed.
  redactLines now searches the whole text first and gives each line its share.
- A whitespace-only line (or NUL piece) became a literal and shredded all
  indentation and the pretty-printed JSON.
- The differential against main now covers multi-line secrets with short and
  blank lines.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Splitting it on U+0000 (to keep it away from Foundation's search, which
traps) lost the match main made when the pieces were short. The whole value
now goes to the byte matcher only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Replaying the NUL-split sides could remove an anchor main's rules still saw,
and a whole NUL value never reached Foundation's search. It now does, only
through the bounds-checked occurrences().

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant