Repository navigation
fix(kas): answer a spec's shell.allowedCommands at the gate, after Crew's checks - #25539
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The new condition sits on the existing Notes
[DESIGN-REVIEWED] c5ff7cc Description read[DESCRIPTION-READ] 1655459cafccf8f48273b997aea4511cf37de099c2d45ca87df53c01d0822c40 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. The new regex-subset parser repeats one this module already has, and the 64-entry cap rests on no measured cost. Notes
What this change shipsInventory (7 items) — 4 justifiedIntent: an agent author's
[FIRST-PRINCIPLES-REVIEWED] c5ff7cc Description read[DESCRIPTION-READ] 3646b859d282d2e607c5d9ee4af1ad3d02d1c71199b7b720b18c05416c5c3fd6 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: |
ff888ef to
35222ae
Compare
35222ae to
32f8608
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: review dispositions for ff888ef, all fixed in 32f8608:
|
Sensitive change review
|
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: Nothing in the shell deny composite ( TIGHTENING: Strictly, nothing got stricter. The new limits are on how far the new grant reaches. The command must pass ADJUDICATED: 14 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: The rows are the shapes kiro-cli's docs and this PR's tests show for allowedCommands.
The patch assumes a little about platforms. UNADJUDICATED:
[SCOPE-REVIEWED] c5ff7cc |
32f8608 to
d03ceed
Compare
Sensitive change review
|
d03ceed to
92d8e8d
Compare
…ew's checks
kiro-cli runs a command an allowedCommands entry matches without a prompt.
KAS gets no shell allow rule, so every command reaches Crew's gate as a
permission request. The projection now records the spec's patterns
(compiled as Python, kiro-cli's \z read as \Z) when the governance ceiling
permits the shell grant, the session handle stamps them on its own
requests, and the spec-builtin-grant row approves a shell call whose
recovered command fullmatches one -- after every deny row and governance,
and never for a command holding ; & | < > $ ` ( ) { } or a newline.
Refs #25320
92d8e8d to
c5ff7cc
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: GPT 6.1 security-class finding on d03ceed (
|
Sensitive change review
|
Backports these main PRs to release/0.11.0, in pick order. Each was a `git cherry-pick -x` of its squash commit on main: - fix(memory): read memory.db off the writer lock, split background pool (#24290) (cherry picked from commit fed830c) - fix(dashboard): bound the pre-prompt build's wait to enter the memory pool (#24414) (cherry picked from commit 520cf2c) - fix(memory): keep the shared -wal when another process closes the memory store (#25852) (cherry picked from commit dc63bb6) - fix: read the page-cache prefetch in a child to keep sqlite locks (#26302) (cherry picked from commit 81dde23) - perf(memory): score facts from a term index and prebuild after restart (#25328) (cherry picked from commit 6824348) - fix(desktop): retry a failed netstat before Windows recovery gives up (#25792) (cherry picked from commit 043dd9f) - fix(cli): say a gateway still serves the port when restart's replacement is refused (#25366) (cherry picked from commit 2e13127) - fix(cli): refuse to stop or restart a gateway the desktop app supervises (#25705) (cherry picked from commit bbf0910) - fix(hooks): approve kiro-cli read-only file searches after the deny tiers (#25150) (cherry picked from commit a0c0bd4) - fix(settings): refuse a config save that config.local.json overrides (#26216) (cherry picked from commit 7f8688e) - fix(workflows): write non-finite floats as null so runs open (#26085) (cherry picked from commit 3591282) - fix(approvals): give each background tool approval its own id (#25905) (cherry picked from commit 51ef3bb) - fix(chat): record file changes for kiro-cli v3 write tools (#25650) (cherry picked from commit 5369270) - fix(sandbox): stop blaming a host-wide OOM kill on a per-tree limit (#25647) (cherry picked from commit 791d2a2) - fix(acp): replay history when a KAS resume restores no turns (#25521) (cherry picked from commit 47c71cb) - fix(kas): auto-approve granted built-ins after Crew's own checks (#25339) (cherry picked from commit dba4de5) - fix(kas): mount web_search as the engine's remote_web_search (#26435) (cherry picked from commit 65c21b5) - fix(kas): answer a spec's shell.allowedCommands at the gate, after Crew's checks (#25539) (cherry picked from commit 39d07d9) - fix(kas): relay an MCP server's boolean env flags, never its secrets (#25331) (cherry picked from commit b734a68) - fix(security): read the -c script past options and redirections (#26087) (cherry picked from commit fea0920) - fix(kas): refuse a shell command a denyByDefault spec does not allow (#26501) (cherry picked from commit 9f0d02f) - fix(kas): name a deniedCommands deny aimed at a redirect as not carried (#26489) (cherry picked from commit 4951c0c) - fix(security): delete the curl-upload deny rule (#26469) (cherry picked from commit 70e206e) Conflicts resolved by hand: - #26302: test/spawn_audit_helpers.py adds only the page_cache.py entry (the embeddings_child.py entry names a module 0.11.0 lacks); test/test_page_cache_prefetch.py takes main's file. - #25328: test/test_dashboard_server_composition_contract.py lazy-import count 93 -> 96 (the three names it adds). - #25705: test/test_cli_restart_refused_message.py takes main's file. - #26085: dashboard/handlers/workflows.py adds import math, keeps the release typing import. - #25339: platform/governance.py keeps the release rule for a missing ceiling (main's enterprise-baseline clause is not on 0.11.0). - #26435: harness-parity.md H6 row edited in place on the release text. - #25539: its acp-client.md and agent-spec-fields.md lines are left out; the paragraphs they edit are not on 0.11.0 (security.md carries it). - #25331: the test and two doc mentions use hoist_managed_servers / resume=, the 0.11.0 names of main's renamed hoist_servers_for_session. - #26087: security package line budget 32,552 -> 32,714 (re-measured). - #26501: kas_permissions.py comment keeps 0.11.0's shapes (main's subagent rules are absent); its acp-client.md line is left out, and the agent-spec-fields.md toolsSettings row says denyByDefault is gate-enforced. - #26489: its agent-spec-fields.md sentence is added to the 0.11.0 row. - #26469: test_denied_commands_security.py keeps 0.11.0's comment; count 113 -> 112. Test fixes (host-dependent tests made hermetic; none loosens an assertion): - tmpdir_helpers.short_tmp_path: a tmp_path override for modules whose code judges a path by its components (a .kiro/crew data-home part); an agent session's TMPDIR under ~/.kiro/crew made every test path the data home. Used by the file-explorer, design-tweak (both), spawn-offload, launch-copy, home-pin, native-skill and auto-improvement-members tests; the sage ancestor-chain test creates its dir under /tmp for the same reason. - pi-gate tests and the remote-session Python 3.9 test take the first real binary on PATH (playwright_cli_installer_helpers._native_tool_on_path): a mise shim under a scratch HOME hangs or writes to stdout. - snapshot-merge ACL test names its own uid; nobody (65534) is the overflow uid inside a user namespace and cannot be named in an ACL. - installer-step and push_guard interrupt tests spawn with SIGINT at its default; a background pytest run starts with SIGINT ignored, which a shell trap and Python both keep. Left out: #23920 (already on release/0.11.0), #26144 (needs sandbox_launch_mark from #24709), #26088 (fences a main-only port), #25346 (11 of its tests fail on 0.11.0: the kiro-cli skill scope it compares against differs there), #26397 (needs #26152's new download route, not on 0.11.0), #26428 (not merged).
…26487) Backports these main PRs to release/0.11.0, in pick order. Each was a `git cherry-pick -x` of its squash commit on main: - fix(memory): read memory.db off the writer lock, split background pool (#24290) (cherry picked from commit fed830c) - fix(dashboard): bound the pre-prompt build's wait to enter the memory pool (#24414) (cherry picked from commit 520cf2c) - fix(memory): keep the shared -wal when another process closes the memory store (#25852) (cherry picked from commit dc63bb6) - fix: read the page-cache prefetch in a child to keep sqlite locks (#26302) (cherry picked from commit 81dde23) - perf(memory): score facts from a term index and prebuild after restart (#25328) (cherry picked from commit 6824348) - fix(desktop): retry a failed netstat before Windows recovery gives up (#25792) (cherry picked from commit 043dd9f) - fix(cli): say a gateway still serves the port when restart's replacement is refused (#25366) (cherry picked from commit 2e13127) - fix(cli): refuse to stop or restart a gateway the desktop app supervises (#25705) (cherry picked from commit bbf0910) - fix(hooks): approve kiro-cli read-only file searches after the deny tiers (#25150) (cherry picked from commit a0c0bd4) - fix(settings): refuse a config save that config.local.json overrides (#26216) (cherry picked from commit 7f8688e) - fix(workflows): write non-finite floats as null so runs open (#26085) (cherry picked from commit 3591282) - fix(approvals): give each background tool approval its own id (#25905) (cherry picked from commit 51ef3bb) - fix(chat): record file changes for kiro-cli v3 write tools (#25650) (cherry picked from commit 5369270) - fix(sandbox): stop blaming a host-wide OOM kill on a per-tree limit (#25647) (cherry picked from commit 791d2a2) - fix(acp): replay history when a KAS resume restores no turns (#25521) (cherry picked from commit 47c71cb) - fix(kas): auto-approve granted built-ins after Crew's own checks (#25339) (cherry picked from commit dba4de5) - fix(kas): mount web_search as the engine's remote_web_search (#26435) (cherry picked from commit 65c21b5) - fix(kas): answer a spec's shell.allowedCommands at the gate, after Crew's checks (#25539) (cherry picked from commit 39d07d9) - fix(kas): relay an MCP server's boolean env flags, never its secrets (#25331) (cherry picked from commit b734a68) - fix(security): read the -c script past options and redirections (#26087) (cherry picked from commit fea0920) - fix(kas): refuse a shell command a denyByDefault spec does not allow (#26501) (cherry picked from commit 9f0d02f) - fix(kas): name a deniedCommands deny aimed at a redirect as not carried (#26489) (cherry picked from commit 4951c0c) - fix(security): delete the curl-upload deny rule (#26469) (cherry picked from commit 70e206e) Conflicts resolved by hand: - #26302: test/spawn_audit_helpers.py adds only the page_cache.py entry (the embeddings_child.py entry names a module 0.11.0 lacks); test/test_page_cache_prefetch.py takes main's file. - #25328: test/test_dashboard_server_composition_contract.py lazy-import count 93 -> 96 (the three names it adds). - #25705: test/test_cli_restart_refused_message.py takes main's file. - #26085: dashboard/handlers/workflows.py adds import math, keeps the release typing import. - #25339: platform/governance.py keeps the release rule for a missing ceiling (main's enterprise-baseline clause is not on 0.11.0). - #26435: harness-parity.md H6 row edited in place on the release text. - #25539: its acp-client.md and agent-spec-fields.md lines are left out; the paragraphs they edit are not on 0.11.0 (security.md carries it). - #25331: the test and two doc mentions use hoist_managed_servers / resume=, the 0.11.0 names of main's renamed hoist_servers_for_session. - #26087: security package line budget 32,552 -> 32,714 (re-measured). - #26501: kas_permissions.py comment keeps 0.11.0's shapes (main's subagent rules are absent); its acp-client.md line is left out, and the agent-spec-fields.md toolsSettings row says denyByDefault is gate-enforced. - #26489: its agent-spec-fields.md sentence is added to the 0.11.0 row. - #26469: test_denied_commands_security.py keeps 0.11.0's comment; count 113 -> 112. Test fixes (host-dependent tests made hermetic; none loosens an assertion): - tmpdir_helpers.short_tmp_path: a tmp_path override for modules whose code judges a path by its components (a .kiro/crew data-home part); an agent session's TMPDIR under ~/.kiro/crew made every test path the data home. Used by the file-explorer, design-tweak (both), spawn-offload, launch-copy, home-pin, native-skill and auto-improvement-members tests; the sage ancestor-chain test creates its dir under /tmp for the same reason. - pi-gate tests and the remote-session Python 3.9 test take the first real binary on PATH (playwright_cli_installer_helpers._native_tool_on_path): a mise shim under a scratch HOME hangs or writes to stdout. - snapshot-merge ACL test names its own uid; nobody (65534) is the overflow uid inside a user namespace and cannot be named in an ACL. - installer-step and push_guard interrupt tests spawn with SIGINT at its default; a background pytest run starts with SIGINT ignored, which a shell trap and Python both keep. Left out: #23920 (already on release/0.11.0), #26144 (needs sandbox_launch_mark from #24709), #26088 (fences a main-only port), #25346 (11 of its tests fail on 0.11.0: the kiro-cli skill scope it compares against differs there), #26397 (needs #26152's new download route, not on 0.11.0), #26428 (not merged). Co-authored-by: w <w@k.local>
Problem / Motivation
Goal: a command an agent spec allows in
toolsSettings.shell.allowedCommandsruns without a prompt on KAS, as it does on kiro-cli v2, with Crew's own checks still run on it.On v2 a command one of these patterns matches (anchored at both ends) runs unprompted. On KAS the entry is dropped, so every command prompts. This is the last part of #25320; the rest shipped in #25361.
Why it matters
kiro-cli's default engine moves to KAS on 11/2. An agent whose author allowed
git statusornpm run .*then asks before every one of those commands.Not a goal
shellallow rule. It would let KAS run the call with no permission request, so Crew's deny floor would never see it.ask/deny,deniedCommands,denyByDefault): those keep prompting, as a shell grant inallowedToolsdoes under the same restriction.allowedPaths,web_fetch.trusted.What changed (motivation → approach → change)
#25339 (merged) added the gate's
spec-builtin-grantrow: Crew answers a KAS permission request itself, after every deny row and governance. Per the owner's ruling this PR adds no second answer path, only one more allow condition on that row:kas_permissions.crew_answered_commands, at most 64) only whenmay_grant_builtin_at_gate_now("execute_bash")holds andwithhold_answered_under_authored_ruleskeeps the shell (read over every shell setting exceptallowedCommandsitself,without_allowed_commands). The key is Crew-only and stripped before the wire. An entry is kept only whenplatform/allowed_commands.pyreads it: literal characters, escaped punctuation and.*(with optional^/\Aand$/\z), the subset Rust'sregexand Python read alike. It is matched by that module in linear time, never byre, so a POSIX class such as[[:alpha:]]cannot widen a grant and nested repetition cannot stall the gateway. An entry outside the subset, a list over 64, and a list the projection withholds (ceiling or the author's own shell restriction) are each named in the session-start notice, through one shared reader (kas_agents._allowed_commands_withheld).kas_crew_answered_commands, re-read on a mode switch) and stamps them on its OWN permission requests only (AcpEvent.spec_granted_commands; never a sub-session's or a native sub-agent's).execute_bashamong its names,is_shell, host-trusted KAS identity) whose host-recovered command, at most 4,096 characters, holds none of; & | < > $ ` ( ) { }, newline or carriage return, and that one entry matches whole. Every other condition of the row still holds: notclassifier_only, the ceiling asked again per call,confirm_toolshonoured, and every deny row has already run.Backwards compatibility
Compatible: a spec without
shell.allowedCommands, every non-KAS session, and every call the row did not approve before are judged exactly as before.Removes nothing: the change adds one condition under which an already-gated KAS shell request is approved; no key, record or path is taken away.
Tests
test/test_kas_allowed_commands.py(new): a matching command is answered (spec-builtin-grant); a non-fullmatching one, a chained/piped/redirected/substituted one (13 shapes, under.*), a read-file call, an untrusted or non-KAS identity, and a call with no recovered command still prompt; the deny floor, a governance tools deny, a ceiling with an opinion,confirm_toolsand a READ_ONLY surface still refuse or withhold; the projection records patterns only when the ceiling and the author's own shell settings allow; the key never reaches the wire; the handle stamps only its own requests.test/test_hooks.pymaps the new field;test/test_kas_tools_settings.pyno longer names a usableallowedCommandsas lost.Revert proof, each change reverted alone:
test_kas_allowed_commands.pyallowedCommandsstripped from that readre.fullmatch(a+)+)Proof: not provable -- other: prove.py reverts the production hunks and the new test module then fails at import, which it reports as inconclusive; the per-change reverts above are the proof.
Local: 2,231 passed across
test/test_kas*.py,test_hooks.py,test_gate_tiers.py,test_hooks_composition_contract.py.Manual verification
N/A — unit coverage drives the real
HookManager.on_tool_callgate with KAS-shaped permission events (test_tool_call_classification_kas._kas_builtin_flow). Windows / macOS unverified (pure-Python change, no platform branch).Related Issues
Refs #25320
Builds on #25339 (merged) and #25361 (merged).
Sibling sweep
Swept:
git grep -n "spec_granted_builtins" -- srcSibling: src/kiro_crew/acp/session_handle_permissions.py -- changed here
Sibling: src/kiro_crew/hook_runtime/tool_identity.py -- changed here
Pattern harvest
Not generalizable: one field of one projection, answered through the existing gate row.
Checklist
Contribution License Agreement
Contributed under the project's Apache-2.0 license.