Repository navigation
fix(kas): answer permissions-block shell and file allows at the gate - #30951
Conversation
A pure-KAS agent spec that grants the shell or the filesystem through its own permissions block prompted on every call: the KAS projection drops such an allow on purpose (it must not reach KAS as an allow rule, or the call would skip Crew's deny floor), and nothing fed it to the gate's spec-builtin-grant row the way allowedTools and allowedCommands are. The projection now records an unscoped shell/fs_read/fs_write allow as the built-ins it covers, and a shell allow's match globs as command patterns (* read as .*, every other character a literal). The gate answers them after every deny row and governance, and an allow with an exclude, an authored ask/deny, or a ceiling with an opinion keeps the prompt.
30d2ea7 to
bd784dd
Compare
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change sends the dropped [DESIGN-REVIEWED] bd784dd Description read[DESCRIPTION-READ] 0b5c237e1352eb11a17730a1f9805100c43858fd7b71fec462b1d48d42ccd4d6 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 |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix closes #25365 by passing an existing grant into the existing What this change shipsInventory (6 items) — 6 justifiedIntent: let a pure-KAS agent's own
[FIRST-PRINCIPLES-REVIEWED] bd784dd Description read[DESCRIPTION-READ] 193071ded60b420a5d5c9beb61f795bd5ca92968bcaf7b5b903e4ba8013b275d 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: |
…30951) A pure-KAS agent spec that grants the shell or the filesystem through its own permissions block prompted on every call: the KAS projection drops such an allow on purpose (it must not reach KAS as an allow rule, or the call would skip Crew's deny floor), and nothing fed it to the gate's spec-builtin-grant row the way allowedTools and allowedCommands are. The projection now records an unscoped shell/fs_read/fs_write allow as the built-ins it covers, and a shell allow's match globs as command patterns (* read as .*, every other character a literal). The gate answers them after every deny row and governance, and an allow with an exclude, an authored ask/deny, or a ceiling with an opinion keeps the prompt. Backport note: resolved onto release's KAS projection: the crew_answered_commands call keeps release's tools_settings local and 3-arg _allowed_commands_withheld, kas_permissions.py keeps release's crew_answered_paths, the agent-spec-fields.md permissions row takes only the added sentence, and the new test sits beside release's tests. (cherry picked from commit bfbfb3d)
Problem / Motivation
Goal: a pure-KAS agent spec that allows the shell or the filesystem in its own
permissionsblock runs those calls without a prompt, with Crew's own checks still run on every one.On KAS, a spec whose
permissionsblock holds{"capability": "shell", "effect": "allow"}, or a shell allow withmatchentries such asgit fetch *, prompts on every call, even for a command that matches an entry exactly. The same grant written inallowedToolsortoolsSettings.shell.allowedCommandsis already answered without a prompt.Why it matters
Since KAS became the default backend, an agent that allowed read-only commands (
git status,git fetch *, a cron script) through itspermissionsblock asks for a click on each one. The only way out today is session-wide Trust mode, which is much broader than what the author granted.Not a goal
shell/fs_read/fs_writeallow rule on the wire. It would let KAS run the call with no permission request, so Crew's deny floor would never see it.fs_read/fs_writewithmatch). The gate has no path-scoped grant, so such a call keeps prompting.all,builtin,filesystem), and an allow with anexclude. Both keep prompting.ask/deny, apoliciesbundle, anothertoolsSettingssetting). It keeps prompting, as anallowedToolsgrant does under the same restriction.What changed (motivation → approach → change)
Root cause: the KAS projection drops a
permissions-block allow for the shell and filesystem families on purpose, so it never reaches KAS as an allow rule. But nothing then passed that grant to the gate'sspec-builtin-grantrow, which already answersallowedToolsgrants (#25339) andallowedCommandspatterns (#25539) after every deny row and governance.The change feeds the authored allow into that same row. It adds no new answer path:
exclude)shell,fs_readorfs_write, nomatchor an empty one_crewAnsweredBuiltinsshellwithmatchglobs_crewAnsweredCommandskas_permissions.crew_answered_builtinsandcrew_answered_commandstake the spec'spermissionsblock as a second input, andkas_agents.to_client_custom_agentpasses it. The block is read by the merge's own parser, so a block the merge refuses grants nothing. A glob keeps*as.*, and every other character stays a literal. A glob holding? [ ] { } !or a backslash is left out, so its commands keep prompting. The recorded sets go through the same governance and authored-restriction filters as before. The log line for the withheld allow,security.md§ KAS spec built-in grant and thepermissionsrow ofagent-spec-fields.mdsay where the grant is now answered.Backwards compatibility
Compatible: a spec without a
permissionsblock, every non-KAS session, and every call the row did not approve before are judged exactly as before.Removes nothing: the change adds grant sources to an existing gate row; no key, record, rule or path is taken away, and nothing new travels to KAS.
Tests
test/test_kas_allowed_commands.py: apermissionsshell allow recordsgit fetch *asgit fetch .*andmake a.bas a literal, leavesls ?out, and the record answersgit fetch originbut notmake axb,ls xor a chained command. An allow with anexcluderecords nothing. The authored-restriction and ceiling filters are the ones theallowedCommandstests already pin.test/test_kas_spec_builtin_grant.py: an unscopedpermissionsshell allow records the three shell built-ins and no KAS allow rule, a scopedfs_writeallow records nothing, and the deny floor still refuses a recorded call.Proof: PROVEN test/test_kas_allowed_commands.py::test_a_permissions_shell_allow_is_answered_by_its_globs, test/test_kas_spec_builtin_grant.py::test_an_unscoped_permissions_allow_is_answered_like_an_allowed_tools_grant (head bd784dd)
Local: the related backend set (107 files, 9,658 passed). One failure,
test_remote_session_launch.py::test_worker_runs_on_the_oldest_guest_python, is host-only: this host'spython3.9is a version-manager shim that prints a warning on every start, which floods the guest output. That test does not touch KAS.Manual verification
N/A — unit coverage drives the real projection (
to_client_custom_agent) and the realHookManager.on_tool_callgate with KAS-shaped permission events. Windows / macOS unverified (pure-Python change, no platform branch).Related Issues
Closes #25365
Refs #30017
Builds on #25339 (merged) and #25539 (merged).
Sibling sweep
Swept: git grep -n "crew_answered_builtins(|crew_answered_commands(" -- src
Sibling: src/kiro_crew/acp/kas_agents.py -- changed here
Sibling: src/kiro_crew/acp/kas_permissions.py:408 -- not affected -- spec_shell_allowlist reads only toolsSettings for denyByDefault
Sibling: src/kiro_crew/acp/harness/kas.py:763 -- not affected -- reads the recorded key, which carries the new patterns as is
Pattern harvest
Not generalizable: one projection input that was never wired into the existing gate row.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.