Repository navigation
fix(chat): make the side-panel path refusal work on Windows paths - #16461
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 92016d9 Description read[DESCRIPTION-READ] 76a740ad9a884ac0465e2a968d252834cbc5d02f4a5b32ac18f0569def280d95 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS On Windows, check that an ordinary file pill ( [UX-REVIEWED] 92016d9 Description read[DESCRIPTION-READ] 1cfedd74bbc8bc57b22bc53ce9b505036b916489a2762441e7411a9eea1a4157 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (2 items) — 2 justifiedIntent: Windows users should not be offered the side-panel "open" button or the existence probe for credential files or
[FIRST-PRINCIPLES-REVIEWED] 92016d9 Description read[DESCRIPTION-READ] cc8152ddeb12959624b66074a601615cfb7732510dd560ac993a1fef8ceb60c9 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
9a4b570 to
dd99017
Compare
`isSafePath` gates three "open this file in the side panel" affordances: DiffBlock's Open button, ToolCallLine's file pill, and the app-sdk chat message list's file chip. It refuses parent traversals and credential locations -- .aws, .ssh, .env, .git, .kube and the rest. It split on `/` only. Two of the three consumers feed it the path a tool call actually operated on, taken from the tool's JSON input, so on Windows it arrives native: `C:\Users\me\.aws\credentials`. That is one segment, and every test in the guard compares whole segments, so no entry in the list could ever match and neither could `..`. Measured across seven sensitive paths plus a traversal: refused on POSIX, allowed on Windows, 7 of 7. The effect is that the Open affordance is offered for a credentials file and the existence probe fires for it -- the probe the DiffBlock suite describes as the guard's whole observable. The backend still refuses the read (`security.paths.is_sensitive_path` is Path-based and platform aware), so nothing is disclosed; what is broken is the defence in depth and the affordance the user is shown. Splitting on both separators fixes all three consumers at once, since they share this helper. DiffBlock is unaffected either way: its paths come from a git diff header, which is always `/`-separated. The guard stays segment-equality plus a `name.` prefix rule rather than a substring match, so `.envrc`, `.gitignore` and `my.env` are still allowed; the new suite pins that in both spellings. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
dd99017 to
92016d9
Compare
Fixes #16493
This is an in-repo re-open of #10679 so the fork's review and merge lanes can
run against this repository. The author's commit is preserved with its original
authorship (Rebase-and-merge keeps
Leon <leon.lai.yc@gmail.com>in the githistory), and they will be credited in the README Contributors list.
Problem / Motivation
Goal: Make the side-panel "open this file" refusal reject sensitive paths and parent traversals on Windows, not just POSIX.
isSafePathgates three "open this file in the side panel" affordances:DiffBlock's Open button, ToolCallLine's file pill, and the app-sdk chat message
list's file chip. It refuses parent traversals and credential locations
(
.aws,.ssh,.env,.git,.kube, and the rest).It split the path on
/only. Two of the three consumers feed it the path atool call actually operated on, taken from the tool's JSON input, so on Windows
it arrives native:
C:\Users\me\.aws\credentials. That is one segment, andevery entry in the guard compares whole segments, so nothing in the sensitive
list could ever match — and neither could
... Measured across seven sensitivepaths plus a traversal: refused on POSIX, allowed on Windows, 7 of 7.
Why it matters
On Windows the "Open" affordance was offered for a credentials file and the
existence probe fired for it — the probe the DiffBlock suite describes as the
guard's whole observable behaviour. The backend still refuses the actual read
(
security.paths.is_sensitive_pathis Path-based and platform-aware), sonothing is disclosed; what is broken is the defence-in-depth layer and the
affordance the Windows user is shown. Leaving it unfixed keeps a security guard
silently inert on an entire platform.
Not a goal
security.paths.is_sensitive_path),which is already platform-aware and remains the authoritative gate.
which is always
/-separated.What changed (motivation → approach → change)
offered for sensitive files and traversals that are refused on POSIX.
isSafePathsplit on/only, so a native Windows path became asingle segment and no segment-equality test could ever match.
split(/[/\\]/)). All three consumers sharethis helper, so one change fixes them at once. The guard stays
segment-EQUALITY plus a
name.prefix rule (not a substring match), so.envrc,.gitignoreandmy.envare still allowed.Backwards compatibility
Compatible: the change only makes the guard refuse MORE (sensitive Windows
paths and Windows
..traversals that were previously allowed through); everypath accepted today on POSIX is still accepted, and ordinary source files on
both platforms stay allowed.
Removes nothing: no path, record, key, validator contract or public function is
removed, renamed or narrowed in a way that strips an existing capability — the
only behavioural change is that a previously-inert refusal now fires on Windows.
Tests
Adds
website/src/test/safePath.test.ts(vitest):preserved) and the same seven written with Windows separators.
.envrc,.environment,.gitignore,my.env, and a file literally named...).Manual verification
N/A — unit coverage sufficient. The change is a pure string-splitting fix in a
shared helper, fully exercised by the paired POSIX/Windows cases in the new
suite.
Pattern harvest
Rule candidate: a path-segment guard that splits on
/only is inert onWindows-native paths, where the whole path arrives as one backslash-joined
segment and no segment-equality or
..test can ever match. A security guardthat compares whole path segments must split on both
/and\whenever anycaller can hand it a native OS path (not only a git-diff-header path).