Skip to content

fix(chat): make the side-panel path refusal work on Windows paths - #16461

Merged
bolichen97 merged 1 commit into
mainfrom
fix/safe-path-windows-separators-inrepo
Oct 4, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/safe-path-windows-separators-inrepo

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #10679 by @leonlaiyc

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 git
history), 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.

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 the path 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 entry in the guard compares whole segments, so nothing in the sensitive
list could ever match — and neither could ... Measured across seven sensitive
paths 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_path is Path-based and platform-aware), so
nothing 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

  • No change to the backend read refusal (security.paths.is_sensitive_path),
    which is already platform-aware and remains the authoritative gate.
  • No widening or narrowing of the sensitive-name list itself.
  • No change to DiffBlock's behaviour: its paths come from a git diff header,
    which is always /-separated.

What changed (motivation → approach → change)

  • Symptom: on Windows the side-panel open affordance and existence probe were
    offered for sensitive files and traversals that are refused on POSIX.
  • Root cause: isSafePath split on / only, so a native Windows path became a
    single segment and no segment-equality test could ever match.
  • Change: split on BOTH separators (split(/[/\\]/)). All three consumers share
    this helper, so one change fixes them at once. The guard stays
    segment-EQUALITY plus a name. prefix rule (not a substring match), so
    .envrc, .gitignore and my.env are still allowed.

Backwards compatibility

Compatible: the change only makes the guard refuse MORE (sensitive Windows
paths and Windows .. traversals that were previously allowed through); every
path 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):

  • Refuses each of seven sensitive locations on POSIX (the behaviour being
    preserved) and the same seven written with Windows separators.
  • Refuses a parent traversal on both platforms, including a UNC path.
  • Still allows ordinary source files on both platforms.
  • Does not over-refuse a name that merely contains a sensitive one (.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 on
Windows-native paths, where the whole path arrives as one backslash-joined
segment and no segment-equality or .. test can ever match. A security guard
that compares whole path segments must split on both / and \ whenever any
caller can hand it a native OS path (not only a git-diff-header path).

@iamwhatever
iamwhatever requested a review from a team October 3, 2026 09:55
@iamwhatever iamwhatever added the drive-to-green PR claimed by drive-to-green pipeline label Oct 3, 2026
@iamwhatever
iamwhatever requested a review from a team as a code owner October 3, 2026 09:55
@iamwhatever
iamwhatever requested a review from bolichen97 October 3, 2026 09:55
@iamwhatever iamwhatever self-assigned this Oct 3, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 92016d90bd446c09ca81a6f3b779baf4972efd40 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 92016d90bd446c09ca81a6f3b779baf4972efd40 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

On Windows, check that an ordinary file pill (C:\repo\src\app.ts) still shows its Open affordance and only credential paths lose it.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 92016d90bd446c09ca81a6f3b779baf4972efd40 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (2 items) — 2 justified

Intent: Windows users should not be offered the side-panel "open" button or the existence probe for credential files or .. traversals. FIX (#16493).

  1. Side-panel open affordances (tool-call file pill, app-sdk file chip, DiffBlock Open) now refuse sensitive and .. paths written with backslashes — justified
  2. New vitest suite pairing POSIX/Windows cases for isSafePath — justified

[FIRST-PRINCIPLES-REVIEWED] 92016d9

Description read

[DESCRIPTION-READ] cc8152ddeb12959624b66074a601615cfb7732510dd560ac993a1fef8ceb60c9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 92016d90bd446c09ca81a6f3b779baf4972efd40 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 92016d9

Verdict parsed from the review's SHA-scoped output markers for commit 92016d90bd446c09ca81a6f3b779baf4972efd40.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 92016d90bd446c09ca81a6f3b779baf4972efd40: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 92016d90bd446c09ca81a6f3b779baf4972efd40 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 92016d9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 92016d90bd446c09ca81a6f3b779baf4972efd40: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the fix/safe-path-windows-separators-inrepo branch from 9a4b570 to dd99017 Compare October 3, 2026 10:58
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
`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>
@iamwhatever
iamwhatever force-pushed the fix/safe-path-windows-separators-inrepo branch from dd99017 to 92016d9 Compare October 3, 2026 18:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 3, 2026
@bolichen97
bolichen97 merged commit c551c27 into main Oct 4, 2026
101 of 102 checks passed
@bolichen97
bolichen97 deleted the fix/safe-path-windows-separators-inrepo branch October 4, 2026 03:12
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 4, 2026
@dwu96 dwu96 removed the drive-to-green PR claimed by drive-to-green pipeline label Oct 4, 2026
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.

isSafePath: side-panel open guard is inert on Windows paths (splits on '/' only)

4 participants