Repository navigation
fix(subagent): let a drive-root cwd allow-list entry admit its subtree - #24504
Conversation
Sensitive change reviewHead: e96bb14
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Reusing the sandbox's existing [DESIGN-REVIEWED] 4b78802 Description read[DESCRIPTION-READ] f591f150e191d1e983059ae96c04354775f22bb975787bb90ba11ec3648b2d24 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: this is a mechanism-level fix that reuses What this change shipsInventory (3 items) — 3 justifiedIntent: let a Windows or POSIX user allow a whole drive (
[FIRST-PRINCIPLES-REVIEWED] 4b78802 Description read[DESCRIPTION-READ] 2e16b36f58548be8eb5c5f7fc65577370d5daba2d7c3b7f20affd2731a8d43a2 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: |
e96bb14 to
32c2969
Compare
|
Sensitive change reviewHead: 32c2969
|
|
CI note: |
32c2969 to
150f808
Compare
Sensitive change reviewHead: 150f808
|
|
CI note: |
150f808 to
4b78802
Compare
Sensitive change reviewHead: 4b78802
|
|
HOLD (policy-sensitive) at The change itself looks sound: It is held only because it widens what the sub-agent — crew-pr-reviewer (r130) |
…le (#24694) * fix(terminal): count paths under a drive-root project as agent-writable The completion probe's _within tested `real.startswith(root + os.sep)`. realpath keeps the separator a drive root already ends in (H:\, or /), so with the project directory or workspace root at a drive root the prefix became H:\\ and no PATH entry below it counted as agent-writable, and _sanitized_path no longer dropped them for being agent-writable. Route the test through sandbox_plan.path_within, which already treats a root ending in a separator as its own prefix: the helper #24504 routes validate_cwd through for the same defect. Part of #24475 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(name-grant): count paths under a drive-root project as agent-writable name_grant._within compared against root + os.sep, the same test the previous commit replaced in terminal_commands._within, over the same agent_writable_roots(). A drive root (H:\ or /) already ends in a separator, so no path below it counted as inside, and a program planted under a drive-root project was honoured by a name grant instead of being refused as agent-tree. Route it through sandbox_plan.path_within so one containment rule serves both sites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
bolichen97
left a comment
There was a problem hiding this comment.
LGTM. validate_cwd built its boundary as root + os.sep, so a root that already ends in a separator (H:\, /) matched nothing below it. Routing it through the existing sandbox_plan.path_within, which strips the trailing separator first, fixes the cause reported in #24475. For every other root the prefix test is unchanged, so the allow-list only widens for entries the operator listed as a filesystem root.
Verified: main still has the old startswith(root + os.sep) in agent_policy.validate_cwd, so this is not already done. No other open PR touches validate_cwd. #24694, #24743 and #24742 fix the same pattern in other modules (terminal, steering, file API), so they are siblings, not duplicates. test_filesystem_root_entry_admits_a_directory_below_it runs the real validate_cwd, and the author reports it goes red when the fix is reverted. The 9 ntpath/posixpath cases pin the -extra sibling and other-drive refusals. All AI lanes pass at this head, the First Principles finding was answered as fixed, and checks are green.
The open maintainer HOLD only asks for human sign-off on a widened permission boundary. This review is that sign-off.
AI-assisted review (Kiro), posted for bolichen.
Problem / Motivation
Goal: A drive root such as
H:\(or/on Linux and macOS) inagent.subagent_cwd_allowed_rootsadmits every directory below it as a sub-agentcwd.With
"subagent_cwd_allowed_roots": ["~/workspace", "H:\\"], aspawn_runwithcwd="H:\\REPL\\project"(an existing directory) is refused withcwd is not under any allowed root: ['~/workspace', 'H:\\']. Nothing below a drive root can match.Why it matters
A Windows user who keeps projects on a second drive cannot allow that drive with one entry; the only workaround is to list every top-level folder by hand. The same entry shape (
/) is refused on POSIX too.Not a goal
realpathalready returns one spelling per path on the host, and the refusal reported here is the separator, not the case.What changed (motivation → approach → change)
validate_cwdtestedresolved.startswith(root + os.sep).os.path.realpath("H:\\")isH:\, which already ends in the separator, so the prefix becameH:\\and no path below the drive matched.validate_cwdnow uses the boundary check the sandbox already has,sandbox_plan.path_within, which strips a trailing separator before adding one. A sibling likeH:\REPL-extrais still refused for rootH:\REPL, and a different drive is still refused.sandbox_planjoins the names thesubagentfacade (src/kiro_crew/subagent.py) binds foragent_policy.Backwards compatibility
Compatible: every root that does not end in a separator gets the same
root + sepprefix as before; only roots that already end in one (a filesystem root) change, from matching nothing below them to matching their subtree.Removes nothing: no key, function or accepted input is removed; the validator accepts more, never less.
Tests
In
test/test_subagent_cwd.py:TestCwdRootBoundary::test_boundary(9 cases): runssandbox_plan.path_withinwithntpathandposixpathswapped in, soH:\REPL\projectunderH:\and/srv/projectunder/are checked on any host, and a-extrasibling or another drive is refused.TestValidateCwd::test_filesystem_root_entry_admits_a_directory_below_it: on the real host, an allow-list holding only the filesystem root oftmp_pathadmitstmp_path/project.Proof: not provable -- other: prove.py's throwaway checkout errored at collection; a manual revert of
validate_cwdtostartswith(root + os.sep)turnstest_filesystem_root_entry_admits_a_directory_below_itred and the fix turns it green (head 32c2969)Determinism: the 10 boundary node ids ran green 20 times at
-n0and 10 times at-n 2 --dist loadgroupbesidetest/test_subagent_coverage.py; the whole file ran green in shuffled order (seed 4411).Manual verification
Not run on a Windows host. The Windows cases run
path_withinwithntpath, the comparisonvalidate_cwdmakes on Windows afterrealpath. Local gates green on Linux:test_subagent_cwd.py,test_subagent_coverage.py,test_subagent_parts_composition_contract.py,test_facade_mirror_guards.py(321 passed, with the sandbox_plan tests), black, isort, flake8, mypy, semgrep, flake-pattern ratchet.Related Issues
Closes #24475
Sibling sweep
Swept: git grep -nE "startswith((root|rootn|root_cf|root_resolved|root_folded)[^)]*+ *os.sep" -- src/
Sibling: src/kiro_crew/subagent_parts/agent_policy.py:942 -- changed here
Sibling: src/kiro_crew/dashboard/terminal_commands.py:472 -- not affected -- roots are agent-writable folders, and a filesystem root there over-refuses, it never admits
Sibling: src/kiro_crew/name_grant.py:534 -- not affected -- roots are grant folders under the crew home, never a filesystem root
Sibling: src/kiro_crew/apps/agent_launch.py:221 -- not affected -- roots are app install folders, never a filesystem root
Sibling: src/kiro_crew/apps/module_loader.py:199 -- not affected -- roots are app source folders, never a filesystem root
Sibling: src/kiro_crew/dashboard/file_api/path_complete.py:266 -- not affected -- refuses on a failed match, so a drive root over-refuses rather than admits
Sibling: src/kiro_crew/dep_sync.py:789 -- not affected -- root is a resolved repository folder, never a filesystem root
Sibling: src/kiro_crew/apps/builtins/md_notebook/server_paths.py:546 -- not affected -- root is the notebook folder, never a filesystem root
Pattern harvest
Rule candidate: semgrep
Pattern: a path-prefix boundary built as
root + os.sepwithout checking whetherrootalready ends in a separatorChecklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)