Skip to content

fix(crash-reporting): redact file:// URLs in crash reports - #20852

Open
OrcaWin wants to merge 1 commit into
mainfrom
fix/crash-stack-frame-redaction
Open

OrcaWin wants to merge 1 commit into
mainfrom
fix/crash-stack-frame-redaction

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​149 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​149
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

What this fixes

One lookbehind in the crash-report path redactor fails in opposite directions on the two shapes a file:// URL can take.

PATH_PATTERNS rule 5 is (?<![A-Za-z0-9./])\/[A-Za-z0-9._-]+\/…. Its lookbehind rejects a slash preceded by a slash.

  • POSIX — file:///Users/alice/…. The path's leading slash sits behind the scheme's third slash, so the rule never fires and nothing is redacted at all.
  • Windows — file:///C:/Users/alice/…. The drive letter interposes, the leading slash is preceded by :, and the rule fires.

So Windows file URLs were redacted and POSIX ones were not.

ELI5

When Orca sends a crash report it scrubs file paths so your username and folders don't leave your machine. The scrubber had a blind spot shaped exactly like a file:// link — and it only had it on Mac and Linux. Those reports were shipping real home directories. One shipped a developer's account name 96 times.

Now one rule covers every form of file:// link, on every platform.

Fix evidence

The leak, on real data. Three payloads in a 326-file corpus carry a real account name — 25 occurrences, 13, and one with 48 path prefixes holding the name twice each. Replaying those payloads' actual leaking lines through both versions:

before after
account-name occurrences 134 13

The residual 13 are one payload's Vite dev-server vector (http://localhost:5173/@fs/…), which has no file:// scheme and is documented below as unfixed. A replay of all 31,497 payload lines in the corpus leaves exactly those 13.

Differential fuzz against the pre-commit baseline: zero regressions.

round cases regressions
3 604,800 grammar + 272,571 realistic 0
4 575,526 further 0

No ReDoS. Worst adversarial shape: 2.9 ms per 200k chars, linear.

Trade-offs

  • darwin and linux stacks lose the frame :line:col offsets they currently keep — they were only keeping them by not being redacted at all. Windows output is byte-identical; it already lost them.
  • The cost is smaller than it first looks. All 62 frame lines of an 8000-char stack survive, along with the complete ordered minified function-name sequence, the component-stack names, and boundary_id / surface. The function-name sequence is the primary fingerprint crash aggregators group on. And redaction shortens output enough to escape the 4000-char cap that was silently truncating these: five real payloads that shipped at exactly 4003 chars (the truncation marker) now ship at 899–1499, untruncated.
  • Follow-up, measured: preserving the :line:col alone, with no basename, would restore the offset axis everywhere with no leak surface — digits carry nothing. Of the 17 payloads whose stack holds the minified fix: improve scrollbar and file explorer scroll behavior #185 string, 13 carry offsets, and clustering on the innermost three frames gives exactly 2 shapes. (The full ordered sequence gives 9 — outer frames drift per build. Stated precisely because the distinction matters.)

Residuals — one of them new

  • NEW: redaction happens before truncation, so collapsing a long URL makes room under the length cap for content that previously fell past it. Net leakage falls in every case measured this way, but a constructed name-sparse-before / name-dense-after input can raise it. Nothing newly exposed was ever redacted by the old code, and no corpus payload has the required shape.
  • Pre-existing: the Vite /@fs/ vector; ~user/, .../Users/, webpack:///Users/; unquoted paths containing a literal space.
  • Out of scope and much larger: diagnostic bundles aren't sanitized by this code at all — ~274–282 of 321 expose ~210 distinct usernames across roughly 800,000 occurrences. Separate pipeline, four orders of magnitude bigger than the payload leak this fixes.

Adversarial review: 4 rounds

round what it found
1 The change originally also preserved stack-frame basenames so minified stacks stayed clusterable. That preserved the basename of any .js with an offset — bob-divorce-settlement.js included.
2 The "bundler content hash" gate meant to fix that was really a "last 8 characters are not all lowercase" gate: tax-return-20241231.js leaked, every capitalised 8-letter dictionary word passed, and 691,200 fuzz cases leaked something the old code redacted. The pass also broke the quoted-path rules' anchor and made the regex quadratic (64 s at 200k chars, on an unclamped breadcrumb path).
3 Removing that pass was round 2's own recommendation, and round 3 confirmed the remainder: zero regressions in 877k cases, anchor break structurally impossible, ReDoS resolved. Verdict: merge.
4 Re-confirmed on byte-identical code, 575,526 further cases, zero regressions, real-payload result exact at 134 → 13. Verdict: merge.

Three properties review found load-bearing but untested — the i flag (an uppercase scheme was previously redacted by nothing at all), the quoted rule's inability to cross a newline, and quote-adjacency — are now pinned, along with single-quote and backtick forms.

One change post-dates the final review round and carries a round less scrutiny: the unquoted rule required a separator where a URL authority can appear, so file://localhost/…, file://host/share/… and file://Users/… escaped every rule in the list. A test added for those found it. It now takes everything after the scheme — strictly more redaction — with the + keeping the bare token in prose intact, verified against the full corpus replay.

One lookbehind in the path redactor fails in opposite directions on the two
shapes a `file://` URL can take.

`PATH_PATTERNS` rule 5 is `(?<![A-Za-z0-9./])\/[A-Za-z0-9._-]+\/…`. Its
lookbehind rejects a slash preceded by a slash.

  - On POSIX a frame reads `file:///Users/alice/…`. The path's own leading slash
    sits behind the scheme's third slash, so the rule never fires and NOTHING is
    redacted — the account name and full filesystem layout ship in the report.

  - On Windows the same frame reads `file:///C:/Users/alice/…`. The drive letter
    interposes, the leading slash is preceded by `:`, and the rule fires.

So Windows file URLs were redacted and POSIX ones were not. Three payloads in a 326-file corpus carry a real account name: 25 occurrences,
13, and one with 48 path prefixes holding the name twice each — 96 literal
occurrences of a developer's account in a single submitted report, via
`/home/<name>/src/<name>/`.

Replaying those three payloads' actual leaking lines through both versions:
134 account-name occurrences before, 13 after. The 13 are payload C, whose
vector is a Vite dev-server URL this change does not address (below).

This adds two rules at the head of `PATH_PATTERNS`: a quoted `file://` URL, then
an unquoted one. Quoted first, so a URL holding spaces is taken whole rather
than truncated at the first one — that case previously leaked the entire path.

WHAT THIS DELIBERATELY DOES NOT DO

An earlier revision also preserved a stack frame's asset name and `:line:col`
while redacting its directory, because those offsets are the only axis a
minified React stack can be clustered on, and Windows loses all of them: across
17 minified React #185 payloads, darwin and linux kept 130 of 130 frames and
win32 kept 0 of 40.

That half is withdrawn. Gating on "ends in .js with a line and column" preserved
the basename of any user file with that shape. Gating instead on "carries a
bundler content hash" only narrowed it, because the shape it actually tests is
"the last 8 characters are not all lowercase letters" — which admits YYYYMMDD
dates, `_v2` suffixes, and every capitalised eight-letter dictionary word.
A grammar fuzz found 691,200 inputs where a user-identifying basename survived
the new code and did not survive the old, including
`tax-return-20241231.js` and `therapy-journal-20250101.js`. Against 5,000
ordinary basenames from this repo's node_modules, 99.3% become gate-passing once
one common date or version suffix is appended.

Two further defects went with it: running the frame pass first destroyed the
quoted-path rules' anchor, so a quoted region beginning with a frame fell
through to the unquoted rules and leaked from the first space onward; and its
two lookaheads made the regex quadratic on adversarial input — 4.1s at 50k
chars, 64s at 200k, on the unclamped breadcrumb path in the main process. With
the pass removed, 100k chars of the worst shape cost 0.10ms.

Preserving build frames is worth doing and needs a gate that constrains the
whole basename rather than its last 8 characters. It is not worth rushing into
the code path that decides what leaves a user's machine.

COST, STATED PLAINLY — AND IT IS SMALLER THAN IT FIRST LOOKS

darwin and linux stacks lose the frame `:line:col` offsets they currently keep,
because they were only keeping them by not being redacted at all. Windows is
byte-identical — it already lost them.

What survives on every platform: all 62 frame lines of an 8000-char stack, the
complete ordered minified function-name sequence (`_i, Ac, zv, Ll, kt, …`), the
component-stack component names, and `boundary_id` / `surface`. The function-name
sequence is the primary fingerprint crash aggregators group on; `line:col` is
the build-specific, weaker key. So these reports do not become unclusterable.

And redaction shortens the output enough to escape the 4000-char stack cap that
was silently truncating these. Measured on five real payloads (4 darwin, 1
linux) that previously shipped at exactly 4003 chars — the truncation marker:
they now ship at 899 / 1428 / 1476 / 1476 / 1499 chars, untruncated, with the
minified function-name sequence identical to the input in all five. Frame counts
come out equal rather than higher (37/37, 56/56, 57/57), because every over-cap
stack in the corpus is already one of the old code's truncated artifacts, so its
pre-truncation frame count is unrecoverable. The headroom gain is real and
measured; a frame-count gain is plausible but not demonstrable from this corpus.

A follow-up worth doing, and measured: preserving the `:line:col` alone — with
no basename — would restore the offset axis on every platform with no leak
surface at all, since digits carry nothing. Of the 17 payloads whose error_stack
holds the minified #185 string, 13 still carry offsets, and clustering those on
the INNERMOST THREE frames gives exactly 2 shapes (8 and 5). Stated precisely
because it matters: the full ordered offset sequence gives 9 clusters, since
outer frames drift per React build and the app-bundle frame moves every release.
The innermost frames are the stable part.

RESIDUALS — ONE OF THEM NEW

  - A Vite dev-server frame `http://localhost:5173/@fs/Users/<name>/…` still
    ships the account name. Not the `?v=` query or the `.tsx` extension, as an
    earlier draft of this message claimed: nothing anchors inside an `http://`
    URL at all, because every separator in `/@fs/Users/` is preceded by an
    alphanumeric. One corpus payload leaks a name 13 times this way.
  - `~user/…`, `.../Users/…` and `webpack:///Users/…` are unhandled.
  - An UNQUOTED path containing a literal space still stops at the space. Worst
    case is a Windows profile folder from a domain display name, leaving surname
    and employer. Quoted `file://` URLs holding spaces are now taken whole,
    which is new.
  - NEW, and the one thing here that is not pre-existing: redaction happens
    BEFORE truncation, so collapsing a long `file://` URL to `[redacted-path]`
    makes room under the length cap for content that previously fell past it. In
    a constructed dev-mode stack mixing `file://` frames with `/@fs/` frames, the
    old output truncated away all ten `/@fs/` frames and the new one ships all
    ten. Net leakage falls in every case measured this way (37→10, 34→10, 30→10,
    20→10 name occurrences) — but that does not generalise: a constructed input
    whose old output was name-sparse and whose newly-reachable tail is name-dense
    can raise the count, worst observed 5→515. Nothing newly exposed is content
    the old code redacted; it is unredacted residual whose reachability
    increased. No corpus payload contains both shapes.
  - Diagnostic BUNDLES, as opposed to crash payloads, are not sanitized by this
    code at all: roughly 274-282 of 321 expose 210-212 distinct home-directory
    usernames across some 800,000 occurrences (the range is definition-sensitive). That is a separate pipeline, and roughly four orders of
    magnitude larger than the payload leak this commit fixes.

No test covered a `file://` URL, which is how this shipped. There are now 49 in
this file: a per-platform frame case for darwin, linux, win32 URL and win32
backslash; nine document-shaped fixtures, each carrying a real `:line:col`, kept
so a future attempt to preserve frames has to clear the counterexamples that
killed this one; and three pinning the properties review found load-bearing but
untested — the `i` flag (an uppercase scheme was previously redacted by nothing
at all), the rule's inability to cross a newline, and quote-adjacency, which is
what stops it stealing an opening quote the way the withdrawn revision did.

One change post-dates the final review round and carries a round less scrutiny
than the rest: the unquoted rule was `file:\/\/\/?(?:[A-Za-z]:)?[\\/]…`, which
required a separator where an authority can appear, so `file://localhost/…`,
`file://host/share/…` and `file://Users/…` escaped every rule in the list. A
test added for those found it. It now takes everything after the scheme, which
is strictly more redaction; the `+` keeps the bare token in prose intact, and a
replay of all 31,497 payload lines leaves the same 13 residual account-name
prefixes, all Vite.

Review: four rounds. Round 1 found the frame pass preserved any `.js` basename;
round 2 found the hash gate meant to fix that was really a "last 8 characters are
not all lowercase" gate, with 691,200 leaking fuzz cases, and that the pass also
broke the quoted rules' anchor and made the regex quadratic. Removing the pass
was round 2's own recommendation. Round 3 fuzzed the remainder against the
pre-commit baseline over 604,800 grammar cases and 272,571 realistic cases and
found zero regressions, confirmed the anchor break is structurally impossible for
these two rules, and measured the worst adversarial shape at 2.9ms per 200k
chars against the removed pass's 64 seconds.
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4a876e83-9166-4234-b134-fd2c54d0112c

📥 Commits

Reviewing files that changed from the base of the PR and between caa465d and 4057dd3.

📒 Files selected for processing (2)
  • src/shared/crash-report-redaction.ts
  • src/shared/crash-reporting.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The redaction rules now match quoted and unquoted file:// URLs. Quoted URLs can contain spaces, while unquoted URLs stop at whitespace or quote characters. The rules are case-insensitive. Regression tests cover JavaScript paths, stack frames, URL variants, token boundaries, rule ordering, and non-path text.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 4057d

The file URL redaction change includes coverage for quoted, unquoted, platform-specific, and boundary cases. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives detailed context, scope, rationale, test evidence, trade-offs, and known residuals. However, it omits the required Linked Issue entry and does not include the required template s… Add a linked issue after “Fixes #”. Include the required template sections, mark Visual Proof as N/A with a reason if applicable, record testing and platform coverage, complete the Agent skill boundary section, and update the checklist conf…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: redacting file:// URLs in crash reports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives detailed context, scope, rationale, test evidence, trade-offs, and known residuals. However, it omits the required Linked Issue entry and does not include the required template sections or checklist confirmations, including Visual Proof/N/A and explicit test checklist status.

Resolution

Add a linked issue after “Fixes #”. Include the required template sections, mark Visual Proof as N/A with a reason if applicable, record testing and platform coverage, complete the Agent skill boundary section, and update the checklist confirmations.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — verified the file:// redaction fix and its new tests against the real code path, and reproduced the leak, the fix, and the absence of leak regressions independently.

  • Two new file:// path rules (src/shared/crash-report-redaction.ts:28-40) — a quoted rule taken whole (spaces allowed, no newline crossing) and an unquoted rule that consumes everything after the scheme. Placed ahead of the existing quoted/unquoted rules so a URL with spaces is not truncated at the first one, and so the unquoted POSIX rule's (?<![A-Za-z0-9./]) lookbehind can no longer miss file:///Users/….
  • Pinned regression tests (src/shared/crash-reporting.test.ts:407-554) — counterexamples that killed the withdrawn basename-preservation attempt, the i flag on both rules, single-quote/backtick forms, no-newline crossing, bare-token prose, rule ordering, per-platform frames, and the no-directory URL fall-through.

Independent checks this run: vitest run src/shared/crash-reporting.test.ts → 58 passed and src/main/crash-reporting → 340 passed; a differential fuzz of old vs new patterns over 300k realistic path-shaped cases found 0 leak regressions and 0 remaining file:// leaks; both new rules stay linear on 200k-char adversarial inputs (worst ~4 ms); oxlint is clean on both files.

ℹ️ Nitpicks

  • The PR description's "Windows output is byte-identical; it already lost them" is not accurate. Before this change the unquoted-POSIX rule redacted file:///C:/Users/alice/… only from /Users/ onward, leaving at _i (file:///C:[redacted-path]); the new unquoted rule removes the file:///C: prefix too, producing at _i ([redacted-path]). The change is strictly more redaction (safe direction) — only the evidence claim is off, so no code action is needed.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

This branch has not been deployed

No deployments
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