Skip to content

fix(kas): answer a spec's shell.allowedCommands at the gate, after Crew's checks - #25539

Merged
buluoray merged 1 commit into
mainfrom
fix/25320-allowed-commands-r2
Oct 29, 2026
Merged

buluoray merged 1 commit into
mainfrom
fix/25320-allowed-commands-r2

Conversation

@buluoray

@buluoray buluoray commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a command an agent spec allows in toolsSettings.shell.allowedCommands runs 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 status or npm run .* then asks before every one of those commands.

Not a goal

  • A KAS shell allow rule. It would let KAS run the call with no permission request, so Crew's deny floor would never see it.
  • Answering commands for a spec whose author also restricted the shell (an authored ask/deny, deniedCommands, denyByDefault): those keep prompting, as a shell grant in allowedTools does under the same restriction.
  • allowedPaths, web_fetch.trusted.

What changed (motivation → approach → change)

#25339 (merged) added the gate's spec-builtin-grant row: 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:

  • The projection records the spec's patterns (kas_permissions.crew_answered_commands, at most 64) only when may_grant_builtin_at_gate_now("execute_bash") holds and withhold_answered_under_authored_rules keeps the shell (read over every shell setting except allowedCommands itself, without_allowed_commands). The key is Crew-only and stripped before the wire. An entry is kept only when platform/allowed_commands.py reads it: literal characters, escaped punctuation and .* (with optional ^/\A and $/\z), the subset Rust's regex and Python read alike. It is matched by that module in linear time, never by re, 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).
  • The session handle keeps them (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).
  • The row approves a shell call (execute_bash among 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: not classifier_only, the ceiling asked again per call, confirm_tools honoured, 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_tools and 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.py maps the new field; test/test_kas_tools_settings.py no longer names a usable allowedCommands as lost.

Revert proof, each change reverted alone:

Reverted Red in test_kas_allowed_commands.py
command condition on the row 6
metacharacter refusal 13
ceiling check at projection 1
authored-restriction withhold 5
allowedCommands stripped from that read 3
subset matcher replaced by re.fullmatch 3 (and the run stalls ~2 min on (a+)+)
withheld-list notice 3
over-64 notice 1

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_call gate 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" -- src
Sibling: 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

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners October 29, 2026 02:15
@buluoray
buluoray requested a review from CrysisDeu October 29, 2026 02:16
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision c5ff7cced9a7b37338816fdba094c8f70a868a81 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 Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/hook_runtime/gate_tiers.py

  • src/kiro_crew/hook_runtime/tool_identity.py

  • src/kiro_crew/hooks.py

  • @buluoray posted a complete reasoning template for c5ff7cc.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

No design-level concerns. The new condition sits on the existing spec-builtin-grant row, so it runs only after every deny row and governance check, and it accepts only patterns that Rust's regex and Python read the same way.

Notes

  • The "Manual verification: N/A" rests on mocked KAS permission events. One live KAS run showing the host-recovered command on an execute_bash permission request would confirm the premise this row matches against.

[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 .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 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c5ff7cced9a7b37338816fdba094c8f70a868a81 — 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

Nothing blocks. The new regex-subset parser repeats one this module already has, and the 64-entry cap rests on no measured cost.

Notes

  • Item 3 — duplicate of src/kiro_crew/acp/kas_permissions.py:1307 (_regex_to_glob): the same grammar is now parsed in 2 places. Both strip ^/\A/$/\z, read .*, and read escaped punctuation, against an identical _REGEX_METACHARACTERS set (grep count: 2 definitions). The two already disagree on stripping and on what may follow a backslash. Subtraction: delete the loop and the metacharacter set in _regex_to_glob. Build the glob from allowed_commands.parse(...) segments joined with *, keeping only the glob-metacharacter refusal.
  • Item 4 — inherited: _MAX_ALLOWED_COMMANDS = 64 "so the record the session carries and the work the gate does per shell call stay small". Matching is already linear, and no cost was measured. Subtraction: delete the cap and its over-64 notice branch in tools_settings_to_permissions.
  • Item 6 — duplicate of projected_crew_answered/switched_crew_answered (kas_agents.py:1513,1525): the new _registered_entry/_switched_entry are a third and fourth copy of the same entry lookup. Subtraction: have the two existing functions call the new helpers and drop their inline copies.

What this change ships

Inventory (7 items) — 4 justified

Intent: an agent author's shell.allowedCommands should run those commands without a prompt on KAS, as on kiro-cli v2 (#25320). This is a FIX.

  1. A KAS shell command that one of the spec's allowedCommands matches whole now runs without a prompt, after the deny floor and governance — justified
  2. A chained, piped, redirected or substituted command, or one over 4,096 characters, still prompts whatever the pattern says — justified
  3. Only literal-plus-.* entries are accepted, through a new linear-time matcher — duplicate of kas_permissions._regex_to_glob
  4. Lists over 64 entries are cut, and the cut is named in the session-start notice — rides along, inherited bound
  5. The patterns are withheld when the governance ceiling or the author's own shell restrictions (deniedCommands, denyByDefault, ask/deny) apply, and the notice names this — justified
  6. The patterns are re-read on a KAS mode switch — one consumer, duplicated lookup helpers
  7. The session-start notice no longer lists a usable allowedCommands as lost — justified

[FIRST-PRINCIPLES-REVIEWED] c5ff7cc

Description read

[DESCRIPTION-READ] 3646b859d282d2e607c5d9ee4af1ad3d02d1c71199b7b720b18c05416c5c3fd6

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 Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] c5ff7cc

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

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c5ff7cc

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c5ff7cced9a7b37338816fdba094c8f70a868a81 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 Oct 29, 2026
@buluoray
buluoray force-pushed the fix/25320-allowed-commands-r2 branch from ff888ef to 35222ae Compare October 29, 2026 03:27
@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 Oct 29, 2026
@buluoray
buluoray force-pushed the fix/25320-allowed-commands-r2 branch from 35222ae to 32f8608 Compare October 29, 2026 03:28
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: review dispositions for ff888ef, all fixed in 32f8608:

  • GPT 6.1 F1 (security-class), Python regex semantics and backtracking at gate_tiers.py:1194: fixed in code. The gate no longer uses re. platform/allowed_commands.py accepts only literal characters, escaped punctuation and .* (optional ^/\A, $/\z), the subset Rust's regex and Python read alike, and matches it in linear time (prefix, suffix, then each middle literal found left to right). rm [[:alpha:]]+ and make (a+)+ are refused at the projection and grant nothing at the gate; test_kas_allowed_commands.py::test_a_pattern_outside_the_subset_grants_nothing pins both. Putting re.fullmatch back reddens 3 tests and stalls the run for about two minutes on the nested pattern.
  • GPT 6.1 F2, the 64-entry slice drops patterns silently: fixed. A list over the bound names toolsSettings.<tool>.allowedCommands in the session-start notice (test_an_allow_list_over_the_bound_is_named).
  • Opus 5.5, the notice stays silent when the session withholds the list: fixed. kas_agents._allowed_commands_withheld is the one reader for both the projection and spec_keys_without_carrier; when the ceiling or the author's own shell restriction withholds every pattern, the notice names the key (test_the_notice_names_allowed_commands_the_session_withholds, ..._the_ceiling_withholds).
  • Semgrep test-autouse-shared-monkeypatch: fixed. The autouse fixture uses _floor_monkeypatch.
  • The two constants moved into the leaf module, so the hooks facade holds no new owner state (test_hooks_composition_contract.py green).

@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 32f8608
  • What rule changed: the gate's spec-builtin-grant row (fix(kas): auto-approve granted built-ins after Crew's own checks #25339) gains one allow condition: a KAS shell call whose host-recovered command matches a spec toolsSettings.shell.allowedCommands entry, in the literal-plus-.* subset platform/allowed_commands.py reads, and holds none of ; & | < > $ + backtick + ( ) { } or a newline.
  • Before -> after (what was allowed/blocked, now): before, every KAS shell call a spec allowed by allowedCommands prompted; now a matching plain command is approved by Crew after every deny row, governance and confirm_tools have run. Nothing that was denied is now allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a command the author did not mean to allow runs unprompted. Bounded by: exact whole-command match, no chaining/redirect/substitution characters, the deny floor and sensitive-path check still running first, the ceiling asked per call, and the author's own shell restrictions withholding the whole list.
  • Evidence checked (which sandbox result proves it): test/test_kas_allowed_commands.py drives the real HookManager.on_tool_call with KAS-shaped permission events: deny floor (rm -rf /) still denied, governance tools deny still denied, ceiling opinion / confirm_tools / READ_ONLY withhold, 13 chained or substituted shapes under .* never approved, POSIX class and nested repetition refused.
  • No regression:
    • Tools still work (which tools/commands were run, result): test_kas_spec_builtin_grant.py (the fix(kas): auto-approve granted built-ins after Crew's own checks #25339 built-in grants) passes unchanged.
    • Backward compatible (old config / old data / old callers still work, how checked): a spec without allowedCommands and every non-KAS session record no patterns; test_hooks.py field-mapping tests updated for the new spec_granted_commands field with an empty default.
    • Existing tests (which suites passed on this head): 2,231 passed locally across test/test_kas*.py, test_hooks.py, test_gate_tiers.py, test_hooks_composition_contract.py.
  • How to undo: revert this PR's single commit; the row then approves only allowedTools built-ins as before.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does c5ff7cced9a7b37338816fdba094c8f70a868a81 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 11 classified, 0 newly refused, 11 still allowed.
  • ubuntu-latest (platform posix): 11 classified, 0 newly refused, 11 still allowed.
  • windows-latest (platform windows): 11 classified, 0 newly refused, 11 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: Nothing in the shell deny composite (sensitive-bash, exfil, deny-rules) changed. The patch adds a new allow path, the spec-builtin-grant row answering toolsSettings.shell.allowedCommands. Its new limits only narrow that new grant. They do not refuse any command that was allowed before. No candidate came back confirmed as newly refused. The notice and projection checks around the grant cannot be adjudicated; they are named below.

TIGHTENING: Strictly, nothing got stricter. The new limits are on how far the new grant reaches. The command must pass plain_command, and entries must parse into the parse subset. Together these refuse the threat of a wide allow pattern carrying a chained or substituted command, or a pattern that reads wider in Python than in Rust: +UNGRANTABLE_COMMAND_CHARS = frozenset(";&|<>$\(){}\n\r")/+ if not command.startswith(first) ...insrc/kiro_crew/platform/allowed_commands.py. grant_spec_builtin was rewritten (+ if not (granted or call.spec_granted_commands): return None/+ if not call.kas_builtin_ids or not call.identity_trusted: return None`). For a call with no command patterns it behaves exactly as at base.

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.

  • any covers platform-neutral argv: git status, git diff --stat, git diff HEAD --stat, git log --oneline -5, npm run build, npm run test -- --watch=false, make test, cargo test --workspace.
  • posix covers / separators and the escaped-punctuation case: make -C ./sub, ls -la src, python -m pytest test/....
  • windows covers backslash paths and .exe/.cmd names: dir /b src\kiro_crew, npm.cmd run build, .venv\Scripts\python.exe -m pytest test\....

The patch assumes a little about platforms. plain_command treats only the plain space as whitespace and refuses \r, which could affect Windows commands that carry a CR. That check sits only on the grant path, so it can cost a Windows user the grant (the call prompts), never refuse the call. No shell-tier row can probe it.

UNADJUDICATED:

  • The grant row's command filter. Guard: _spec_command_granted → allowed_commands.plain_command / parse / matches. Call path: KAS permission request → _build_permission_event stamps spec_granted_commands → ToolCall.from_event → grant_spec_builtin. A command that fails the filter falls through to the prompt; it is not refused. The legitimate inputs this would leave prompting, which I would have submitted:
    • a Windows command ending in \r\n;
    • git log --format=%H under git log .* (no forbidden characters, so it should be granted, but it is not measurable here);
    • echo $HOME and ls {a,b} under .* ($, { and } are refused on purpose);
    • an entry like make (all|test) (refused on purpose).
  • The projection and notice checks. Guard: _allowed_commands_withheld → withhold_answered_under_authored_rules(..., tools_settings=without_allowed_commands(...)) and may_grant_builtin_at_gate_now("execute_bash"), in to_client_custom_agent and spec_keys_without_carrier. If a spec carries deniedCommands or denyByDefault beside allowedCommands, or has an authored shell ask, the patterns are withheld and those commands keep prompting. At base they prompted anyway, so this is no new refusal. It is a narrowing someone could argue (one unrelated deniedCommands entry withholds every allowedCommands grant), but it can't be confirmed.

[SCOPE-REVIEWED] c5ff7cc

@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 Oct 29, 2026
@buluoray
buluoray force-pushed the fix/25320-allowed-commands-r2 branch from 32f8608 to d03ceed Compare October 29, 2026 04:31
@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d03ceed
  • What rule changed: the gate's spec-builtin-grant row (fix(kas): auto-approve granted built-ins after Crew's own checks #25339) gains one allow condition: a KAS shell call whose host-recovered command matches a spec toolsSettings.shell.allowedCommands entry, in the literal-plus-.* subset platform/allowed_commands.py reads, and holds none of ; & | < > $ + backtick + ( ) { } or a newline.
  • Before -> after (what was allowed/blocked, now): before, every KAS shell call a spec allowed by allowedCommands prompted; now a matching plain command is approved by Crew after every deny row, governance and confirm_tools have run. Nothing that was denied is now allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a command the author did not mean to allow runs unprompted. Bounded by: exact whole-command match, no chaining/redirect/substitution characters, the deny floor and sensitive-path check still running first, the ceiling asked per call, and the author's own shell restrictions withholding the whole list.
  • Evidence checked (which sandbox result proves it): test/test_kas_allowed_commands.py drives the real HookManager.on_tool_call with KAS-shaped permission events: deny floor (rm -rf /) still denied, governance tools deny still denied, ceiling opinion / confirm_tools / READ_ONLY withhold, 13 chained or substituted shapes under .* never approved, POSIX class and nested repetition refused.
  • No regression:
    • Tools still work (which tools/commands were run, result): test_kas_spec_builtin_grant.py (the fix(kas): auto-approve granted built-ins after Crew's own checks #25339 built-in grants) passes unchanged.
    • Backward compatible (old config / old data / old callers still work, how checked): a spec without allowedCommands and every non-KAS session record no patterns; test_hooks.py field-mapping tests updated for the new spec_granted_commands field with an empty default.
    • Existing tests (which suites passed on this head): 2,231 passed locally across test/test_kas*.py, test_hooks.py, test_gate_tiers.py, test_hooks_composition_contract.py.
  • How to undo: revert this PR's single commit; the row then approves only allowedTools built-ins as before.

@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 Oct 29, 2026
@buluoray
buluoray force-pushed the fix/25320-allowed-commands-r2 branch from d03ceed to 92d8e8d Compare October 29, 2026 05:38
…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
@buluoray
buluoray force-pushed the fix/25320-allowed-commands-r2 branch from 92d8e8d to c5ff7cc Compare October 29, 2026 05:39
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: GPT 6.1 security-class finding on d03ceed (gate_tiers.py:1179, command.strip() widens a grant): fixed in code in c5ff7cc, no override.

  • The gate matches the recovered command verbatim. platform/allowed_commands.plain_command refuses any command with a control character or whitespace other than the plain space (so rm scratch + U+00A0, a tab, or a bell never match), on top of the chaining/redirect characters and the length bound.
  • Patterns are kept verbatim too (allowed_command_pattern no longer strips), and parse refuses one holding those characters.
  • Pinned by test_kas_allowed_commands.py::test_a_command_is_matched_verbatim (six spellings around rm scratch) and ::test_a_wildcard_never_covers_an_invisible_character (rm .* vs U+00A0, tab, bell). Restoring the strip reddens 4; dropping the printable-character check reddens 3.
  • The previous head also fixed the AcpProvider._to_llm_event path dropping spec_granted_commands (caught by test_acp_provider.py field parity in CI).

@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: c5ff7cc
  • What rule changed: the gate's spec-builtin-grant row (fix(kas): auto-approve granted built-ins after Crew's own checks #25339) gains one allow condition: a KAS shell call whose host-recovered command, verbatim (no strip; only printable characters and the plain space), matches a spec toolsSettings.shell.allowedCommands entry, in the literal-plus-.* subset platform/allowed_commands.py reads, and holds none of ; & | < > $ + backtick + ( ) { } or a newline.
  • Before -> after (what was allowed/blocked, now): before, every KAS shell call a spec allowed by allowedCommands prompted; now a matching plain command is approved by Crew after every deny row, governance and confirm_tools have run. Nothing that was denied is now allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a command the author did not mean to allow runs unprompted. Bounded by: exact whole-command match, no chaining/redirect/substitution characters, the deny floor and sensitive-path check still running first, the ceiling asked per call, and the author's own shell restrictions withholding the whole list.
  • Evidence checked (which sandbox result proves it): test/test_kas_allowed_commands.py drives the real HookManager.on_tool_call with KAS-shaped permission events: deny floor (rm -rf /) still denied, governance tools deny still denied, ceiling opinion / confirm_tools / READ_ONLY withhold, 13 chained or substituted shapes under .* never approved, POSIX class and nested repetition refused.
  • No regression:
    • Tools still work (which tools/commands were run, result): test_kas_spec_builtin_grant.py (the fix(kas): auto-approve granted built-ins after Crew's own checks #25339 built-in grants) passes unchanged.
    • Backward compatible (old config / old data / old callers still work, how checked): a spec without allowedCommands and every non-KAS session record no patterns; test_hooks.py field-mapping tests updated for the new spec_granted_commands field with an empty default.
    • Existing tests (which suites passed on this head): 2,231 passed locally across test/test_kas*.py, test_hooks.py, test_gate_tiers.py, test_hooks_composition_contract.py.
  • How to undo: revert this PR's single commit; the row then approves only allowedTools built-ins as before.

@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 Oct 29, 2026
@buluoray
buluoray enabled auto-merge (squash) October 29, 2026 10:03
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@buluoray
buluoray merged commit 39d07d9 into main Oct 29, 2026
175 of 178 checks passed
@buluoray
buluoray deleted the fix/25320-allowed-commands-r2 branch October 29, 2026 16:07
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
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).
bolichen97 added a commit that referenced this pull request Oct 31, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants