Skip to content

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

Closed
leonlaiyc wants to merge 1 commit into
kirodotdev:mainfrom
leonlaiyc:fix/safe-path-windows-separators
Closed

leonlaiyc wants to merge 1 commit into
kirodotdev:mainfrom
leonlaiyc:fix/safe-path-windows-separators

Conversation

@leonlaiyc

@leonlaiyc leonlaiyc commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the shared side-panel path refusal work for Windows and UNC paths as it already does for POSIX paths.

website/src/utils/safePath.ts refuses paths that a side-panel "open this file"
affordance must not offer — parent traversals, and credential locations (.aws,
.ssh, .env, .git, .kube, .docker, .npmrc, .netrc, …). Three
surfaces share it: DiffBlock's Open button, ToolCallLine's file pill, and the
app-sdk ChatMessageList file chip.

It splits on one separator:

const segments = p.toLowerCase().split('/')
if (segments.some(seg => seg === '..')) return false
…
return !segments.some(seg => sensitive.some(s => seg === s || seg.startsWith(s + '.')))

Two of the three consumers hand it the path a tool call actually operated on —
extractToolFilePath reads path / file_path / filePath straight out of the
tool's JSON input (messageRenderers.tsx:179, ToolCallLine.tsx:626). On Windows
that is a native path, C:\Users\me\.aws\credentials, which split('/') turns
into one segment. Every check in the guard compares a whole segment, so no
entry in the list can match, and neither can ...

Measured against the guard on main — same file, two spellings:

POSIX Windows
.aws/credentials refused allowed
.ssh/id_rsa refused allowed
proj/.env refused allowed
proj/.env.local refused allowed
proj/.git/config refused allowed
.kube/config refused allowed
../../etc/passwd (traversal) refused allowed

7 of 7. The guard is not weaker on Windows — it is inert.

Why it matters

What actually happens, stated precisely. The backend still refuses the read:
security.paths.is_sensitive_path is Path-based with a documented
symlink/casefold matching contract, not string splitting, so it holds on Windows.
Nothing is disclosed by this bug. I checked that before writing this, because
the alternative framing would have been alarming and wrong.

What is broken is the layer in front of it, in two ways:

  1. The affordance. A Windows user sees an "Open in side panel" control on a
    .aws\credentials or .env tool-call pill. The product's own answer to "may
    this be opened?" is yes, and only a later server refusal says otherwise.
  2. The probe. DiffBlock's existing suite states the guard's observable
    directly — "the guard's observable is that the existence probe never fires" —
    and on Windows it always fires, sending the sensitive path to /api/file-read
    on every render of such a pill.

A defence-in-depth guard that silently does nothing on an entire platform is worth
fixing on its own terms: it is the layer that is supposed to still be standing
when something behind it is wrong.

The traversal half has the same shape and no separate justification needed.

Not a goal

  • No change to backend file-read policy or individual consumers.
  • No substring matching or file-explorer warning-banner migration.

What changed (motivation → approach → change)

The side-panel guard misses Windows-sensitive segments because it splits only on /. website/src/utils/safePath.ts splits on both separators so the existing traversal and sensitive-segment rules run on native Windows, UNC and mixed paths. Segment equality and the name. prefix rule stay intact. The frontend conventions document records the shared owner and its contract.

Current main still has the defect. Sibling #10667 is closed without merging and changes a separate file-explorer warning predicate; it has not completed this guard's work. normalizeWindowsPath only handles drive/UNC absolute paths, so it would leave relative backslash traversals unchecked and is not the right owner for this predicate.

Backwards compatibility

Breaking: previously offered Windows-sensitive and traversal file-open actions are refused, matching the existing POSIX refusal contract. Writer/consumer sweep on origin/main @ 296969b:

Reader: website/src/components/DiffBlock.tsx:isSafePath -- entry: chat -- both the probe and Open action use the shared guard; ordinary diff paths stay allowed.
Reader: website/src/pages/chat/ToolCallLine.tsx:isSafePath -- entry: chat -- tool-file probe gating uses the shared guard; ordinary native paths stay allowed.
Reader: website/src/app-sdk/messageRenderers.tsx:isSafePath -- entry: app -- extractToolFilePath returns null for refused paths; ordinary file chips stay allowed.

Tests

37 tests pass in safePath.test.ts and DiffBlock.test.tsx. The helper tests pair POSIX and Windows sensitive paths, cover UNC and relative/mixed-separator traversal, and retain ordinary-file and over-refusal controls (.envrc, .environment, .gitignore, my.env, ...). Focused ESLint passes. The local Vite test wrapper only permits the shared dependency junction's resolved path; it is not committed.

Manual verification

Verified the refetched main's shared guard and all current consumers. Windows and UNC sensitive paths plus both traversal spellings are refused by the branch. Ordinary paths and the over-refusal controls remain allowed. No consumer is patched.

Screenshots / video

N/A: this diff changes the shared path predicate and regression tests, without adding a frontend surface, string or layout. Existing consumer tests verify the omitted Open action and absence of a sensitive-file probe; the established POSIX presentation is preserved on Windows.

Related Issues

Closes #16493

The existing issue describes this exact defect. It has bug and area: dashboard labels but no recognized triage verdict; maintainer triage is required. No new issue or verdict label was created.

Pattern harvest

Rule candidate: review-prompt
Pattern: a segment-based guard over tool-produced native paths must test both separators, including relative traversal, and retain over-refusal controls.

Checklist

  • At most two commits (one logical commit), with a Conventional Commits title
  • Focused tests pass and regression controls cover the defect
  • Self-review completed; code follows project style guidelines
  • Documentation updated
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

@leonlaiyc
leonlaiyc requested review from a team and CrysisDeu September 14, 2026 03:24
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 08c24c1e155a045e9585cba0976aa6a12d2f0109 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 08c24c1

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 08c24c1e155a045e9585cba0976aa6a12d2f0109 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Check that ordinary files in a Windows tool call still show the side-panel file pill.

[UX-REVIEWED] 08c24c1

Description read

[DESCRIPTION-READ] bc186281639fcdc5c85e29d42d561f2b4bcba6189f2cfcd503befac202870766

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 Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 08c24c1e155a045e9585cba0976aa6a12d2f0109 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 08c24c1

Description read

[DESCRIPTION-READ] 3618d437432f70093a73ba80e21fc6ce422b4ed3dad522a9de95bff994f49fc7

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 Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 08c24c1e155a045e9585cba0976aa6a12d2f0109 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 08c24c1

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 08c24c1e155a045e9585cba0976aa6a12d2f0109 via the fork AI-review pipeline — 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

Check before merge: website/src/apps/file-explorer/utils.ts:60 SENSITIVE_PATTERNS has the same /-only cause, and ## Not a goal defers it. It is the one unfixed sibling.

Not justified as shipped

  • Item 3 — rides along: the new ## Security: side-panel file paths section in website/docs/frontend-conventions.md repeats what the new code comment and the safePath.test.ts docstrings already say about the contract.

What this change ships

Inventory (4 items) — 3 justified

Intent: Windows users should not see side-panel "open" controls or file probes for credential files or traversal paths, the same as POSIX users today. This is a FIX.

  1. Windows, UNC and mixed-separator paths to sensitive locations (.aws, .ssh, .env, …) no longer get an Open control or an existence probe — justified
  2. Backslash .. traversals (src\..\secret.txt, C:\…\..\..) are refused like POSIX ones — justified
  3. Frontend conventions doc gains a section naming safePath.ts as owner and stating its contract — rides along
  4. New safePath.test.ts pairing POSIX and Windows spellings, with checks that it does not refuse too much — justified

[FIRST-PRINCIPLES-REVIEWED] 08c24c1

Description read

[DESCRIPTION-READ] 46787f84c0d06eea54028603cd7a74c7f44fe092d609fa261a31c5590ee9c27a

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 added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 14, 2026
@NicholasRBowers NicholasRBowers added the needs-pr-triage PR scanner: awaiting automated triage label Sep 21, 2026
@chenmingwei23 chenmingwei23 added drive-to-green PR claimed by drive-to-green pipeline and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: chenmingwei23]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author.

Assessment: Frontend-only diff (safePath). Backend Tests + Coverage Gate reds are inherited from main. Fix: rebase onto current main to clear the inherited backend reds; verify safePath tests pass.

If you'd prefer I don't touch this PR, add the pr-no-autofix label.

`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>
@leonlaiyc
leonlaiyc force-pushed the fix/safe-path-windows-separators branch from 3909ccb to 08c24c1 Compare October 3, 2026 14:25
@leonlaiyc
leonlaiyc requested a review from a team as a code owner October 3, 2026 14:25
@leonlaiyc

Copy link
Copy Markdown
Contributor Author

Verified current main versus head 08c24c1 using each production isSafePath source. Windows/UNC and relative/mixed traversal are red before and refused after; ordinary paths and all over-refusal controls stay allowed. Focused safePath + DiffBlock tests: 37 passed. ESLint, TypeScript/Vite build, docs lint and current PR description checker passed. Local GPT preflight found no blockers (requested gpt-6.1-sol; served model unverified). Local Opus was unavailable in this interface; the exact-head server Opus review remains authoritative.

[
  {
    "name": "posix ssh",
    "path": "/home/dev/.ssh/id_rsa",
    "expected": false,
    "before": false,
    "after": false
  },
  {
    "name": "windows ssh",
    "path": "C:\\Users\\dev\\.ssh\\id_rsa",
    "expected": false,
    "before": true,
    "after": false
  },
  {
    "name": "unc ssh",
    "path": "\\\\share\\team\\.ssh\\id_rsa",
    "expected": false,
    "before": true,
    "after": false
  },
  {
    "name": "posix traversal",
    "path": "src/../secret",
    "expected": false,
    "before": false,
    "after": false
  },
  {
    "name": "windows traversal",
    "path": "src\\..\\secret",
    "expected": false,
    "before": true,
    "after": false
  },
  {
    "name": "mixed traversal",
    "path": "src/..\\secret",
    "expected": false,
    "before": true,
    "after": false
  },
  {
    "name": "ordinary",
    "path": "C:\\Users\\dev\\src\\main.ts",
    "expected": true,
    "before": true,
    "after": true
  },
  {
    "name": ".envrc",
    "path": "C:\\repo\\.envrc",
    "expected": true,
    "before": true,
    "after": true
  },
  {
    "name": ".environment",
    "path": "C:\\repo\\.environment",
    "expected": true,
    "before": true,
    "after": true
  },
  {
    "name": ".gitignore",
    "path": "C:\\repo\\.gitignore",
    "expected": true,
    "before": true,
    "after": true
  },
  {
    "name": "my.env",
    "path": "C:\\repo\\my.env",
    "expected": true,
    "before": true,
    "after": true
  },
  {
    "name": "...",
    "path": "C:\\repo\\...",
    "expected": true,
    "before": true,
    "after": true
  }
]

@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you for this fix, @leonlaiyc! 🙏

To get it merged cleanly against current main, your change has landed via an in-repo replacement PR: #16461. Your commit was carried over with its original authorship preserved — your name stays in the git history (Leon <leon.lai.yc@gmail.com>, with your Co-Authored-By trailer intact), and you'll be credited in the README Contributors list.

#16461 is fully green (all CI and review lanes, including PR Readiness) and references the backing issue #16493.

Closing this one in favor of #16461. Thanks again for catching the Windows path-separator gap in the side-panel refusal!

@iamwhatever iamwhatever closed this Oct 3, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 3, 2026
@mbriones98 mbriones98 removed the drive-to-green PR claimed by drive-to-green pipeline label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

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)

5 participants