Skip to content

fix(kas): answer permissions-block shell and file allows at the gate - #30951

Merged
bolichen97 merged 1 commit into
mainfrom
fix/25365-kas-permissions-shell-allow
Nov 6, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/25365-kas-permissions-shell-allow

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a pure-KAS agent spec that allows the shell or the filesystem in its own permissions block runs those calls without a prompt, with Crew's own checks still run on every one.

On KAS, a spec whose permissions block holds {"capability": "shell", "effect": "allow"}, or a shell allow with match entries such as git fetch *, prompts on every call, even for a command that matches an entry exactly. The same grant written in allowedTools or toolsSettings.shell.allowedCommands is 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 its permissions block 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

  • A KAS shell/fs_read/fs_write allow rule on the wire. It would let KAS run the call with no permission request, so Crew's deny floor would never see it.
  • A path-scoped filesystem allow (fs_read/fs_write with match). The gate has no path-scoped grant, so such a call keeps prompting.
  • The meta capabilities (all, builtin, filesystem), and an allow with an exclude. Both keep prompting.
  • A spec whose author also restricted the same capability (an authored ask/deny, a policies bundle, another toolsSettings setting). It keeps prompting, as an allowedTools grant does under the same restriction.
  • The named-policy composition gap (KAS projection drops custom-agent grants when permissions includes a named policy #30165).

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's spec-builtin-grant row, which already answers allowedTools grants (#25339) and allowedCommands patterns (#25539) after every deny row and governance.

The change feeds the authored allow into that same row. It adds no new answer path:

Authored allow (no exclude) Recorded as The gate answers
shell, fs_read or fs_write, no match or an empty one every built-in those capabilities cover, in _crewAnsweredBuiltins any call to those built-ins
shell with match globs each glob as a command pattern, in _crewAnsweredCommands a plain command one pattern matches whole

kas_permissions.crew_answered_builtins and crew_answered_commands take the spec's permissions block as a second input, and kas_agents.to_client_custom_agent passes 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 the permissions row of agent-spec-fields.md say where the grant is now answered.

Backwards compatibility

Compatible: a spec without a permissions block, 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: a permissions shell allow records git fetch * as git fetch .* and make a.b as a literal, leaves ls ? out, and the record answers git fetch origin but not make axb, ls x or a chained command. An allow with an exclude records nothing. The authored-restriction and ceiling filters are the ones the allowedCommands tests already pin.
  • test/test_kas_spec_builtin_grant.py: an unscoped permissions shell allow records the three shell built-ins and no KAS allow rule, a scoped fs_write allow 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's python3.9 is 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 real HookManager.on_tool_call gate 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 00:56
@bolichen97
bolichen97 requested a review from mbriones98 November 6, 2026 00:56
@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 01:13
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 6, 2026
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.
@bolichen97
bolichen97 force-pushed the fix/25365-kas-permissions-shell-allow branch from 30d2ea7 to bd784dd Compare November 6, 2026 04:18
@bolichen97

bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/security.md, src/kiro_crew/acp/kas_agents.py, src/kiro_crew/docs/agent-spec-fields.md and same-dir files since this head went green (fe40b96 -> a67c9dd); CI re-running.

[operator: bolichen97]

@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 Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the change sends the dropped permissions allow to the existing spec-builtin-grant gate row, after the deny floor and governance, and puts no new allow on the KAS wire.

[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 .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 Nov 6, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision bd784dd472bf7c8ed55c2856fd75b4dc41e2f580 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 Nov 6, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of bd784dd472bf7c8ed55c2856fd75b4dc41e2f580 — 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 fix closes #25365 by passing an existing grant into the existing spec-builtin-grant gate row. It adds no new way for a call to get approved, and every deny row and governance check still runs first.

What this change ships

Inventory (6 items) — 6 justified

Intent: let a pure-KAS agent's own permissions allow for shell or filesystem run without a prompt, while Crew's checks still run on every call. This is a FIX.

  1. An unscoped shell/fs_read/fs_write allow in a spec's permissions block no longer prompts on each call — justified
  2. The match globs of a permissions shell allow (e.g. git fetch *) are approved at the gate when a plain command matches one whole — justified
  3. A glob containing ? [ ] { } ! or a backslash, and any allow with an exclude, keeps prompting — justified
  4. The security log message for a withheld allow now names where the grant gets approved — justified
  5. crew_answered_builtins and crew_answered_commands each take an optional second permissions input; to_client_custom_agent is the one caller and passes it — justified
  6. The security.md § KAS spec built-in grant and the agent-spec-fields.md permissions row now describe the new grant source — justified

[FIRST-PRINCIPLES-REVIEWED] bd784dd

Description read

[DESCRIPTION-READ] 193071ded60b420a5d5c9beb61f795bd5ca92968bcaf7b5b903e4ba8013b275d

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 Nov 6, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] bd784dd

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

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] bd784dd

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

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 merged commit bfbfb3d into main Nov 6, 2026
98 checks passed
@bolichen97
bolichen97 deleted the fix/25365-kas-permissions-shell-allow branch November 6, 2026 06:02
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
bolichen97 added a commit that referenced this pull request Nov 9, 2026
…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)
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.

KAS: a spec's permissions-block allow for shell/filesystem still prompts on every call

2 participants