Skip to content

fix(apps): refuse a drive-qualified app name in the path gate - #33053

Merged
bolichen97 merged 1 commit into
mainfrom
crew/issue-triage/32772-drive-name-gate
Nov 13, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
crew/issue-triage/32772-drive-name-gate

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On Windows, the shared app-name gate refuses a drive-qualified name such as D:x, so no app verb builds a path on another drive. The refusal is Windows-only, per @bolichen97's review: #33053 (comment)

_check_path_safety in src/kiro_crew/apps/manager_tree.py tests only for .., / and \. A drive spec such as D:x has none of them, so it passes. On Windows, joined onto a data-home path it changes the drive: POST /api/apps/Q:probe/dev with {"enabled": false} asks to create Q:probe.lock outside the data home, and C:foo takes the record lock of the real app foo.

Why it matters

Every app verb (install, uninstall, enable, disable, dev mode, builtin adoption, the dashboard routes) relies on this one gate to keep a name to one path component. The CLI already refuses drive specs, but the core helper and the dashboard route do not, so on Windows a dashboard caller can create or lock a stray .lock file on any drive.

Not a goal

  • Refusing a drive-qualified name on Linux or macOS. There D:x is one plain path component, and the gate keeps accepting it as main does.
  • ab:c style names that name an NTFS alternate data stream (Design Review note). They stay accepted here.
  • Refusing "" or . in the helper. Main allows them here and callers handle them.
  • Changing the CLI's own _refuse_unsafe_app_name check, which already covers drive specs.
  • Reordering the lock-before-lookup in set_dev_mode, enable_app or disable_app.

What changed (motivation → approach → change)

A drive spec has no separator, so the gate's separator test cannot see it. When os.name == "nt", _check_path_safety now returns False if ntpath.splitdrive finds a drive in the name. On other hosts the gate decides exactly as before. Using the standard library's Windows path parser, not a regex, matches how Windows itself reads the name. The import is at call time so the apps.manager facade does not start serving ntpath.

Backwards compatibility

Compatible: on Linux and macOS nothing changes. On Windows only names with a drive spec are newly refused, and KEBAB_RE in src/kiro_crew/apps/manifest_names.py admits no :, so no installed or installable app has such a name.

Removes nothing: the gate refuses one more unsafe spelling on Windows; no app, record or route that works today stops working.

Tests

test/test_app_path_safety_drive.py:

Rows Expectation
D:x, C:probe, Q: on this host os.name != "nt"
same names with os.name forced to "nt" refused
probe, my-app, ab:c, app.v2 allowed
d:foo\bar, C:..\x, ./a:b, .., a/b, a\b, /etc/passwd, C:\x, UNC path refused on every host

The forced-nt rows let Linux CI check the Windows branch.

Proof: PROVEN test/test_app_path_safety_drive.py::test_drive_qualified_name_refused_on_windows[D:x], test/test_app_path_safety_drive.py::test_drive_qualified_name_refused_on_windows[C:probe], test/test_app_path_safety_drive.py::test_drive_qualified_name_refused_on_windows[Q:] (head 84c44a0)

Manual verification

N/A — unit coverage sufficient: the change is one pure predicate, tested row by row with os.name forced to "nt"; ntpath parses the same way on every host.

Related Issues

Fixes #32772

Sibling sweep

Swept: git grep -nE '".." not in [a-z_]+ and "/" not in' -- src/
Sibling: src/kiro_crew/apps/manager_tree.py -- changed here
Sibling: src/kiro_crew/apps/builtins/code_review_sage/sage_lib/learning.py -- not affected -- its _NS_NAME_RE admits no colon
Sibling: src/kiro_crew/cli_commands_app.py -- not affected -- _refuse_unsafe_app_name already checks both path flavours

Pattern harvest

Rule candidate: review-prompt
Pattern: a "single path component" check that tests only for separators and .. misses a Windows drive spec such as C:x.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 8, 2026 09:11
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 84c44a0bea6d25c242895bc2cda4ea19cd01410a touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 84c44a0bea6d25c242895bc2cda4ea19cd01410a — 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 does not.

First-Principles-Verdict: PASS

This is a one-predicate fix at the shared gate that every app verb goes through. It is backed by issue #32772 and by tests that force the Windows branch.

Notes

  • Item 1 — symptom-level sibling: cli_commands_app.py:243 checks for a drive spec itself (PureWindowsPath(...).name == app_name) before calling _check_path_safety. On Windows the gate now refuses drive specs too, so for that case the CLI's own check is a second copy. Subtraction: once this merges, shrink _refuse_unsafe_app_name to its ""/. checks plus the gate call. This stays a deferred note, because ## Not a goal excludes the CLI check and because the CLI also refuses drive names on POSIX, which the gate deliberately does not.

What this change ships

Inventory (2 items) — 2 justified

Intent: stop a dashboard or API caller on Windows from naming an app D:x so that an app verb creates or locks files on another drive. This is a FIX.

  1. On Windows, app verbs and dashboard routes now refuse an app name with a drive spec (D:x, C:foo); on other hosts nothing changes — justified
  2. A new test file pins the gate's decision on drive names, separators and traversal, with nt forced for the Windows rows — justified

[FIRST-PRINCIPLES-REVIEWED] 84c44a0

Description read

[DESCRIPTION-READ] 86244d8ce103b01f47178cb907590d1f6ff6686b6c4b10d6c6b6f66dceffb89c

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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 84c44a0bea6d25c242895bc2cda4ea19cd01410a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 84c44a0

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 84c44a0bea6d25c242895bc2cda4ea19cd01410a false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 84c44a0bea6d25c242895bc2cda4ea19cd01410a — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 84c44a0

Verdict parsed from the review's SHA-scoped output markers for commit 84c44a0bea6d25c242895bc2cda4ea19cd01410a.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 84c44a0bea6d25c242895bc2cda4ea19cd01410a false-positive: <reason, 20 to 500 characters>

@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 Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 84c44a0bea6d25c242895bc2cda4ea19cd01410a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is a small, Windows-only tightening of one shared check, it uses the standard library's own Windows path parser, and no name the app-name rules accept is newly refused.

Notes

  • "Manual verification: N/A" does not trigger the platform BLOCK. ntpath parses names the same way on every host. The test forcing os.name to "nt" covers the Windows branch on Linux CI, and test_drive_qualified_name_follows_host checks the real Windows behaviour on the Windows CI legs (security-scope-review.yml matrix).

[DESIGN-REVIEWED] 84c44a0

Description read

[DESCRIPTION-READ] 450b8cee2a0bb4f5a98657c55386a7cdd3add40c5c659d911a5d7260653a22bf

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 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 Nov 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Review-ready at head 607cb40c398a: pr_status.py exits 0 (96 checks, 0 failing, readiness: passed, MERGEABLE). Design and First Principles lanes PASS; GPT and Opus markers fresh, no findings to answer. The earlier reds were GitHub download outages (HTTP 504/502 and an HTTP2 framing error on the jq release download); each was rerun with --failed and no code changed. Waiting on human review.

buluoray
buluoray previously approved these changes Nov 8, 2026

@buluoray buluoray 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.

Reviewed head 607cb40. App names with a drive prefix such as D:x are now refused, with tests.

@bolichen97 bolichen97 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.

Requesting changes on 607cb40.

The change adds a new refusal to the existing _check_path_safety gate: any name where ntpath.splitdrive finds a drive (D:x, Q:, C:probe) now returns False on every host, including Linux and macOS, where such a name could be accepted before. This review lane does not take added refusals on an existing path, even when they harden security. The same call was made on #32811 and #32221.

The Windows case is real. On Windows, apps_dir() / "D:x" resolves onto drive D. If the owner wants this hardening, they can accept it directly. Otherwise, a version that doesn't change what the gate accepts would pass here.

Separately, Sensitive Change Review is red on this head.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 8, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Follow-up to my change request on 607cb40, narrowing what I'm asking for.

On Windows, refusing a drive-qualified name keeps the app inside apps_dir(). That restores the gate's own boundary, so that part is fine.

The one change I'm asking for: run the ntpath.splitdrive check only on Windows (for example behind os.name == "nt"). On Linux and macOS, D:x is a plain single path component that main accepts today, and it should stay accepted there. The test rows for drive-qualified names would then expect False on Windows and True elsewhere (Q:, C:probe, D:x). Rows that already contain a separator stay False everywhere.

Once the check is Windows-only and checks are green, I'll approve.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Maintainer decision: I accept the new refusal of drive-qualified names (D:x, C:probe, Q:) on every host. On Windows such a name escapes onto another drive; the cost on Linux/macOS is negligible. @bolichen97 please re-review with this in mind.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Update, superseding my comment above: we will take @bolichen97's narrower ask from 13:18Z. The drive-qualified check will run only on Windows (os.name == "nt"). On Linux and macOS, D:x, Q: and C:probe stay accepted, as main does today. The ab:c alternate-data-stream note from Design Review stays out of scope here.

@iamwhatever
iamwhatever force-pushed the crew/issue-triage/32772-drive-name-gate branch from 607cb40 to aa760ef Compare November 9, 2026 07:16
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 9, 2026
@github-actions github-actions Bot added 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 readiness: checking Automated validation is still running labels Nov 9, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/32772-drive-name-gate branch from aa760ef to e7c28a6 Compare November 9, 2026 16:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 9, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/32772-drive-name-gate branch from e7c28a6 to c1ed787 Compare November 13, 2026 02:25
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 13, 2026
On Windows, _check_path_safety let a drive spec such as D:x through: it
has no separator, yet joining it onto a data-home path changes the
drive. On Windows, refuse any name ntpath.splitdrive finds a drive in.
Elsewhere such a name is one plain component and stays accepted.
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/32772-drive-name-gate branch from c1ed787 to 84c44a0 Compare November 13, 2026 03:27
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

@bolichen97 ready for re-review at head 84c44a0bea6d. Per your 2026-11-08 13:18Z ask, the ntpath.splitdrive check in _check_path_safety now runs only when os.name == "nt"; on Linux and macOS D:x, C:probe and Q: stay accepted as on main. The tests derive the drive-row expectation from os.name, and separate rows force os.name to "nt" so Linux CI checks the Windows branch. All checks pass (readiness: passed); Design and First Principles PASS.

@bolichen97 bolichen97 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.

Approve at 84c44a0. This applies main's existing path rule to a Windows path shape that slipped past it. It isn't a new kind of refusal.

On main, _check_path_safety (apps/manager_tree.py:99-106) exists "to prevent directory traversal when the path is used as a key in file-system lookups (e.g. apps_dir() / name)", and it refuses .., / and \. On Windows a name such as D:x has none of those, yet apps_dir() / "D:x" resolves on drive D, outside the apps directory. That is the same escape the rule exists to stop. The new check refuses a name only when ntpath.splitdrive(path)[0] is non-empty, and only when os.name == "nt". Off Windows D:x is one plain component and is still accepted, as the tests pin. Every other row (ab:c, app.v2, separators, .., UNC) keeps main's verdict.

No regex. Nothing is live red (the cancelled runs are superseded by newer passes).

@bolichen97
bolichen97 merged commit ab2b676 into main Nov 13, 2026
158 of 164 checks passed
@bolichen97
bolichen97 deleted the crew/issue-triage/32772-drive-name-gate branch November 13, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

3 participants