Repository navigation
fix(kas): refuse a shell command a denyByDefault spec does not allow - #26501
Conversation
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The new rule only ever refuses, it covers the auto-approve path the bug came in through, it fails closed on malformed data, and the one behaviour it takes away is listed with its readers. Notes
[DESIGN-REVIEWED] ed15e88 Description read[DESCRIPTION-READ] bfc185172fc91fafbc2644bda51d334e4e4d9976ec540a8b634d6e1605bb507d 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. Each item enforces What this change shipsInventory (8 items) — 8 justifiedIntent: on KAS, stop an unattended auto-mode job from running a shell command that its agent spec's
[FIRST-PRINCIPLES-REVIEWED] ed15e88 Description read[DESCRIPTION-READ] 3761b11ac4c3132a9478e476903b4aa43f5caca602e7836e4aa1f20e8cd12a79 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 Review detailsNo findings. None of the four candidates held up against the code. Notes:
[OPUS-REVIEWED] ed15e88 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
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: The tightening is a new gate row that only fires when a KAS agent's own spec sets TIGHTENING: a new ADJUDICATED: 17 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: I wrote candidates for posix, windows and any.
The diff makes no platform-specific path assumption of its own. Its only spelling assumption is the ungrantable character set, which hits Windows spellings hardest ( UNADJUDICATED: The guard is Call path: The classifier never sets
To probe this row, I would submit each command above with a [SCOPE-REVIEWED] ed15e88 |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head, UX skipped or pass, no conflict, no open change request.
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: on KAS, an agent spec's
toolsSettings.execute_bash.denyByDefaultrefuses every shell command itsallowedCommandsdo not match, on every approval mode, so an unattended--approval-mode autojob can no longer run a command the spec never allowed.Today the key has no KAS rule and is only named in the session-start notice. Every shell call prompts, and an auto-mode cron job approves the prompt: the reporter's
mkfiforan with exit 0. A default-mode job waits about 180 s and is rejected.Why it matters
A deny-by-default allowlist is how authors confine an unattended agent. Under auto mode it silently became "run anything", and the run reported success.
Not a goal
denyByDefault. fix(kas): answer a spec's shell.allowedCommands at the gate, after Crew's checks #25539 withholds that grant when the author restricted the shell; this PR keeps that ruling.allowedCommandssubset (literals, escaped punctuation,.*) that Crew reads like kiro-cli.fs_write.fallbackAction: "deny", the write-side twin (Scheduled runs on KAS: toolsSettings.fs_write.fallbackAction "deny" is not enforced #26492).toolsSettingstranslation.What changed (motivation → approach → change)
Symptom: an auto-mode job ran an unlisted command. Cause: nothing on the KAS path enforced
denyByDefault, and auto mode approves whatever the gate does not deny.Fix: one new gate row,
spec-shell-allowlist, adeny_policyplaced after governance and before every grant. It refuses the session agent's own shell call unless the recovered command is plain and one usableallowedCommandsentry matches it whole, the same test thespec-builtin-grantrow uses. The data travels the pathallowedCommandsalready uses: projection key, session handle, permission event,ToolCall, and the provider event copy inproviders/acp_turns.py. It is recorded whatever the governance ceiling says, because it only restricts. A malformed record reads as an empty allowlist, and an entry outside the subset allows nothing. The notice no longer namesdenyByDefault. The user docsrc/kiro_crew/docs/agent-spec-fields.mdand the specs indocs/system-specs/modules/(security.md,acp-client.md, the tier table inmemory-skills-hooks.md) describe the row.Backwards compatibility
Breaking: on KAS, a spec with
denyByDefaultnow has unlisted shell commands refused instead of prompted (or auto-approved). A command listed only by an entry outside the subset is refused too: the reporter's own[a-z]+entry is one. The notice already names such entries, and^touch /tmp/probe-allowed-.*\.txt$is the subset form. Writer sweep on origin/main @ 1bd20d0:git grep -n "denyByDefault" -- src configfinds no shipped spec or default that sets it; the only writers are user agent specs.Reader: src/kiro_crew/llm_helpers_parts/tool_approval.py:_handle_tool_approval -- cron -- AUTO_APPROVE consults
permission_floor.refusal_for(security_only=False), which now returns the refusal (test_an_auto_mode_job_refuses_a_command_the_spec_never_allowed)Reader: src/kiro_crew/hooks.py:HookManager.on_tool_call -- chat -- HOOK_BASED refuses at once (test_an_interactive_session_refuses_it_at_once_instead_of_prompting)
Reader: src/kiro_crew/acp/kas_agents.py:spec_keys_without_carrier -- chat -- the notice drops
denyByDefaultand still names unusableallowedCommands(test_the_notice_no_longer_names_it, test_an_unusable_pattern_allows_nothing)Tests
test/test_kas_deny_by_default.py(new): an auto-mode floor refuses the unlistedmkfifoand keeps the listedtouch; an interactive gate refuses it at once and still prompts for the listed one; chained, piped, substituted, newline and near-miss commands are refused; an empty list, an unusable entry and an unrecovered command refuse; a spec withoutdenyByDefault, a read, an MCP tool and a sub-session request are untouched; the record is kept under a withholding ceiling, never reaches the wire, follows a mode switch, and a malformed one restricts.test_gate_tiers.pyadds the row to the order golden and a scenario;test_hooks.pymaps the new field;test_kas_tools_settings.pyno longer namesdenyByDefaultas lost.Proof: not provable -- other: prove.py reverts every production hunk and the new test module then fails at import, which it reports as inconclusive; the per-change reverts below are the proof.
from_eventread()Reproduced on origin/main: the reporter's spec (subset pattern) through
permission_floor.refusal_for(security_only=False)approvesmkfifo /tmp/probe-notlisted-fifo; with the fix it is refused andtouch /tmp/probe-allowed-a.txtis still approved.Manual verification
N/A -- unit coverage drives the real gate and the auto-mode floor with KAS-shaped permission events built by the real session handle. Windows / macOS unverified (pure-Python change, no platform branch).
Related Issues
Closes #26437
Sibling sweep
Swept:
git grep -nE "denyByDefault|fallbackAction" -- src/kiro_crewSibling: src/kiro_crew/acp/kas_permissions.py:1531 -- tracked in #26492
Sibling: src/kiro_crew/hook_runtime/gate_tiers.py -- changed here
Pattern harvest
Not generalizable: one spec key with no engine rule, now enforced by one gate row; the other such key is tracked in #26492.
Checklist