Repository navigation
fix(apps): refuse a drive-qualified app name in the path gate - #33053
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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
What this change shipsInventory (2 items) — 2 justifiedIntent: stop a dashboard or API caller on Windows from naming an app
[FIRST-PRINCIPLES-REVIEWED] 84c44a0 Description read[DESCRIPTION-READ] 86244d8ce103b01f47178cb907590d1f6ff6686b6c4b10d6c6b6f66dceffb89c That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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
[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 |
|
Review-ready at head |
bolichen97
left a comment
There was a problem hiding this comment.
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.
|
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 The one change I'm asking for: run the Once the check is Windows-only and checks are green, I'll approve. |
|
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. |
|
Update, superseding my comment above: we will take @bolichen97's narrower ask from 13:18Z. The drive-qualified check will run only on Windows ( |
607cb40 to
aa760ef
Compare
aa760ef to
e7c28a6
Compare
e7c28a6 to
c1ed787
Compare
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.
c1ed787 to
84c44a0
Compare
|
@bolichen97 ready for re-review at head |
bolichen97
left a comment
There was a problem hiding this comment.
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).
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_safetyinsrc/kiro_crew/apps/manager_tree.pytests only for..,/and\. A drive spec such asD:xhas none of them, so it passes. On Windows, joined onto a data-home path it changes the drive:POST /api/apps/Q:probe/devwith{"enabled": false}asks to createQ:probe.lockoutside the data home, andC:footakes the record lock of the real appfoo.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
.lockfile on any drive.Not a goal
D:xis one plain path component, and the gate keeps accepting it as main does.ab:cstyle names that name an NTFS alternate data stream (Design Review note). They stay accepted here.""or.in the helper. Main allows them here and callers handle them._refuse_unsafe_app_namecheck, which already covers drive specs.set_dev_mode,enable_appordisable_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_safetynow returns False ifntpath.splitdrivefinds 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 theapps.managerfacade does not start servingntpath.Backwards compatibility
Compatible: on Linux and macOS nothing changes. On Windows only names with a drive spec are newly refused, and
KEBAB_REinsrc/kiro_crew/apps/manifest_names.pyadmits 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:D:x,C:probe,Q:on this hostos.name != "nt"os.nameforced to"nt"probe,my-app,ab:c,app.v2d:foo\bar,C:..\x,./a:b,..,a/b,a\b,/etc/passwd,C:\x, UNC pathThe forced-
ntrows 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.nameforced to"nt";ntpathparses 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 asC:x.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)