Repository navigation
fix(kas): backport the checked-deny grant and kiro-cli toolsSettings grant fixes to 0.12.1 (batch 37) - #32467
Conversation
A KAS spec that pairs allowedCommands (or an allowedTools shell or write grant) with deniedCommands or a write deniedPaths asked for every call, because Crew read the deny as the author's restriction. On kiro-cli the grant runs unless a deny names the call. When Crew can read every deny entry itself, the projection records the grants the deny alone held back together with the deny list, as one value the session stamps on its own requests. A new spec-denies gate row refuses a call a deny names; spec-builtin-grant honours the grant only after the same check answers a clear no. Anything unreadable keeps asking. (cherry picked from commit 817a9ef) Release backport, hand-ported without its main prerequisites (#30193 toolsSettings aliases, #30964 batch write guard, #29543 GitHub OAuth), which are wide and change other behaviour: - acp/kas_spec_denies.py: reads toolsSettings as given instead of folding kiro-cli alias spellings (#30193). Every spelling's denies are read and any other key under them still withholds, so this fails toward ask; crew_answered_commands takes one argument here. - acp/kas_agents.py: took the kas_managed_entries import only (this branch keeps _pin_legacy_negotiation in the module); spec_keys_without_carrier adds the lift beside release's _allowed_commands_withheld(spec, None); to_client_custom_agent keeps release's tools_settings_to_permissions(spec.get("toolsSettings")) and adds untranslated_policy. - acp/kas_permissions.py: added CREW_SPEC_DENIES_KEY only (the CREW_ANSWERED_WRITES_KEY beside it is #30964's). - docs/agent-spec-fields.md: added this change's one sentence to the toolsSettings row. - test/test_kas_spec_denies.py: the alias test is replaced by one that checks a deny under either shell spelling refuses. Every other file applied unchanged. Original author: Ray Xu (#31622).
…and allowedPaths grants (#31850) * refactor(kas): move env-withholding and tool-row helpers to sibling modules kas_agents.py and kas_permissions.py sit just under the 2,000-line cap, so the KAS toolsSettings grant fix that follows cannot land in them. This commit only moves whole definitions, with no behaviour change: - kas_agents -> kas_env_withhold: _MANAGED_ENV_KEYS_KEPT, _ENV_REFERENCE, _withhold_credential_fields, _is_relayed_reference, _carries_env_reference. - kas_permissions -> kas_tool_rows: _HOOK_ONLY_ROWS, _rows_from_policy_table, KAS_TOOL_IDS_BY_KIRO_TOOL, KAS_TOOL_MATCH_VOCABULARY, kas_tool_match_names. Both old modules re-export every name they held, so callers and test patch points keep their import paths. Each moved definition is source-identical to its original. The managed-server helpers (resolve_managed_entries and its neighbours) are left in place: another change moves them. * fix(kas): keep a kiro-cli agent's allowedCommands, autoAllowReadonly and allowedPaths grants (cherry picked from commit e0e6196) Release backport, on top of #31622's hand-port. The definitions this change moves to acp/kas_env_withhold.py and acp/kas_tool_rows.py are source-identical on this branch. Hand-resolved: - acp/kas_agents.py: dropped the kas_legacy_negotiation import and kept _pin_legacy_negotiation in the module (this branch never moved it); took CREW_ANSWERED_PATHS_KEY and shell_denies_carried only (the CREW_ANSWERED_WRITES_KEY and projection_accepts imports serve #30964 and #30193 code this branch does not have). This branch has no tools_settings local in to_client_custom_agent (#30193 adds one), so it binds tools_settings = spec.get("toolsSettings") once and passes it to tools_settings_to_permissions, crew_answered_commands and every _allowed_commands_withheld call, including spec_keys_without_carrier. - acp/kas_permissions.py: tool_names import without KIRO_CLI_NAME_BY_KAS_TOOL (it moved with the tool rows) and without the tools_settings_aliases module; kept this branch's _entry_* readers in kas_agents and aliased _SHELL_SETTINGS_KEYS to SHELL_SETTINGS_KEYS; added crew_answered_paths and kept this branch's crew_answered_builtins signature. - docs/agent-spec-fields.md: this branch's toolsSettings row with this change's own edits applied. Every other file applied unchanged. Original author: Ray Xu (#31850).
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: this backports two KAS grant fixes already merged on Notes
[DESIGN-REVIEWED] 1711769 Description read[DESCRIPTION-READ] 05d5d4ee42591d8755a785ad437ab55abe151a9b622f1a25a825241d6693631c 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. This backports two KAS permission fixes already merged on What this change shipsInventory (8 items) — 8 justifiedIntent: let a KAS agent's own spec grants run calls unasked the way kiro-cli runs them, so unattended runs on 0.12.x stop stalling on approval cards. This is a FIX (a backport of #31622 and #31850).
[FIRST-PRINCIPLES-REVIEWED] 1711769 Description read[DESCRIPTION-READ] 742f44401f4b66066bbd5e7b8e4eed233bceee241475c0314dd3e68fc6b1cdb9 That sha256 names the PR description this verdict read. Recompute it with |
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 PR leaves the three shell deny tiers ( TIGHTENING: a new ADJUDICATED: 16 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: I wrote posix, windows and no UNADJUDICATED:
[SCOPE-REVIEWED] 1711769 |
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: |
Problem / Motivation
Goal: Bring #31622 and #31850, two KAS permission fixes that merged on
mainafterv0.12.0, ontorelease/0.12.0as one commit each in a PR of their own, so they can be reviewed and reverted apart from the other batches.Why it matters
shell.allowedCommands, orallowedToolsnaming the shell or write tool) withdeniedCommandsor a writedeniedPathsasks before every call, even one no deny names, because the deny list is read as the author's restriction. An unattended run stalls on the first card. kiro-cli runs those calls unasked and refuses what a deny names.shell.allowedCommandsbesidedenyByDefaultorautoAllowReadonlyasks for every matched command,denyByDefaultrefuses read-only commands kiro-cli runs, and a write insidewrite.allowedPathsasks before every write. Reported by several users of unattended agents. kiro-cli runs all of these without asking.Not a goal
main; nothing is changed only here.mainprerequisites (fix(kas): read kiro-cli toolsSettings aliases, wide path denies and pwsh process control #30193, fix(acp): let the batch guard judge writes the spec auto-approves #30964, feat(connections): Crew-owned GitHub OAuth on KAS behind connections.crew_oauth (default off) #29543): each changes other behaviour and is wide. fix(kas): keep a kiro-cli agent's allowedCommands, autoAllowReadonly and allowedPaths grants #31850 needs nothing beyond fix(kas): honour a grant beside deniedCommands or deniedPaths #31622 and fix(kas): keep an allowedTools grant when toolsSettings only adds allows #30813.CHANGELOG.mdchange. Cuttingv0.12.1-rc.Nand the bare tag follow docs/build/release.md and stay with the maintainers.What changed (motivation → approach → change)
Each main squash commit was applied with
cherry-pick -nontorelease/0.12.0@344cc7ca44, inmainorder, and committed with itscherry picked fromtrailer.deniedCommandsordeniedPaths817a9ef36334bff402feallowedCommands,autoAllowReadonlyandallowedPathsgrantse0e6196e561711769359What it does. When Crew can read every entry of a
deniedCommands/ writedeniedPathslist itself, the projection records the grants that deny alone held back, with the deny list, as one Crew-only value the session stamps on its own agent's requests. A newspec-deniesgate row refuses a call a deny names;spec-builtin-granthonours the recorded grant only after the same check answers a clear no. An unreadable entry, a non-plain command, or a target it cannot resolve grants nothing, so the call keeps asking.resolve_managed_entriesmoves intoacp/kas_managed_entries.pyfor the line cap;kas_agentsre-exports it.What #31850 does.
denyByDefaultand a booleanautoAllowReadonlybesideallowedCommands, andfallbackActionbeside a writeallowedPaths, no longer withhold that grant (kas_grant_only_settings.without_shell_grant_keys/without_write_grant_keys);deniedCommands,deniedPaths, any other key or a malformed value still do.autoAllowReadonly: truebesidedenyByDefaultlets a read-only command past thespec-shell-allowlistrow for the read-only row to answer. A writeallowedPathsis recorded andspec-builtin-grantapproves a write only when every target is covered as written and symlink-resolved, by thespec-write-allowlistrow's own test; a delete is never granted this way. Its pure move (definitions toacp/kas_env_withhold.pyandacp/kas_tool_rows.py, re-exported) is in the same squash commit; every moved definition is source-identical on this branch.Prerequisites checked. Already on this branch: #30961 (batch 32) and #30813 (batch 35). Not taken:
toolsSettingsreader sees alias spellings, and modifies three files this branch does not have (#30108, #30088), so it would pull more in. #31622 needs only its alias folding, in one reader.CREW_ANSWERED_WRITES_KEY.Hand-resolved hunks.
acp/kas_spec_denies.pytoolsSettingsas given instead of folding alias spellings with #30193'scanonical_tools_settings. Every spelling's denies are read, and any other key under them still withholds, so it fails toward ask.crew_answered_commandstakes one argument on this branch.acp/kas_agents.py(imports)kas_managed_entriesimport only; this branch keeps_pin_legacy_negotiationin the moduleacp/kas_agents.py(spec_keys_without_carrier)and not _commands_lifted_by_denies(spec)beside release's_allowed_commands_withheld(spec, None)acp/kas_agents.py(to_client_custom_agent)tools_settings_to_permissions(spec.get("toolsSettings"))and addeduntranslated_policyacp/kas_permissions.pyCREW_SPEC_DENIES_KEYonly, to the constants and to the Crew-only key setdocs/agent-spec-fields.mdtoolsSettingsrowtest/test_kas_spec_denies.pyacp/kas_agents.py(imports)kas_legacy_negotiationimport and kept_pin_legacy_negotiationin the module; tookCREW_ANSWERED_PATHS_KEYandshell_denies_carriedonly (CREW_ANSWERED_WRITES_KEYandprojection_acceptsserve #30964 / #30193 code this branch lacks)acp/kas_agents.py(tools_settings)tools_settingslocal into_client_custom_agent(#30193 adds it), so it bindstools_settings = spec.get("toolsSettings")once and passes it totools_settings_to_permissions,crew_answered_commandsand every_allowed_commands_withheldcall,spec_keys_without_carrierincludedacp/kas_permissions.pytool_namesimport withoutKIRO_CLI_NAME_BY_KAS_TOOL(moved with the tool rows) and without the alias module; kept this branch's_entry_*readers inkas_agents; aliased_SHELL_SETTINGS_KEYStoSHELL_SETTINGS_KEYS; addedcrew_answered_pathsand kept this branch'screw_answered_builtinssignaturedocs/agent-spec-fields.mdtoolsSettingsrow with #31850's own edits appliedThe moved
resolve_managed_entriesmatches this branch's copy except its docstring and the constant's name. In each commit, every other file has added and removed lines identical to its main commit. The commit is authored with the public identity the push guard requires and names its original author in its message.Other open batches. This batch touches
acp/harness/kas.py,acp/kas_agents.pyanddocs/agent-spec-fields.md, which #32229 also touches, anddocs/agent-spec-fields.md, which #32349 also touches.git merge-treeof this batch on top of each of their heads reports no conflict.builder-security checked: no bind, listener, route, auth mechanism or storage grant changes. The changes widen auto-approve cases on KAS for an agent's own spec grants, bounded as described above, and keep the deny floor, the deny rows and governance ahead of them.
Backwards compatibility
Compatible: the changes are the ones already merged on
main, and their own compatibility notes apply unchanged. An agent with a grant beside a deny list Crew can read now runs what no deny names without asking, as on kiro-cli; a deny Crew cannot read keeps the old prompt. A read-only command underdenyByDefaultwithautoAllowReadonly: truenow runs, as kiro-cli runs it.Two public functions move out of their modules for the line cap; each old module re-exports its name, so every reader keeps its import path:
Reader: src/kiro_crew/acp/harness/kas.py:resolve_managed_entries -- chat -- reads kas_agents.resolve_managed_entries, re-exported from acp/kas_managed_entries.py; test_kas_agents_mcp_servers.py
Reader: src/kiro_crew/agent_sdk/spec_hooks.py:kas_tool_match_names -- chat -- imports it from kas_permissions, which re-exports it from acp/kas_tool_rows.py; test_spec_hook_kas_tool_names.py, test_harness_tool_names.py
Tests
Proof: not provable -- other: a backport of a main commit whose proof ran on its own PR
release/*, so the related set was run here: every touched test file plus every test file that names a changed module or record (kas_spec_denies,spec_denied,kas_managed_entries,kas_grant_only_settings,kas_spec_grants,kas_env_withhold,kas_tool_rows,kas_write_allowlist,allowed_commands,allowed_paths,gate_tiers,tool_identity,acp_turns, the KAS session handle modules,spec_granted_paths,spec_shell_readonlyorto_client_custom_agent): 139 files, one pytest process per batch of 20,-n 0. 8661 passed. 21 failed, and the same 21 fail on a cleanrelease/0.12.0checkout with the same command (copilot backend, harness-parityis_kiro_cli,doctor, and the conductor verify-fix contract suite).test_kas_spec_denies.py,test_kas_tools_settings_grants.py,test_kas_allowed_commands.py,test_kas_write_fallback_deny.py,test_kas_tools_settings.py,test_hooks.py,test_crew_fired_spec_hooks.py): 459 passed.fallbackActionfrom the write grant-only keys turns 2 of those tests red on this branch.Manual verification
N/A - the fix was verified on its own main PR. The 0.12.1 RC soak is the end-to-end check.
Screenshots / video
Related Issues
Backport to the 0.12 line for 0.12.1 of #31622.
Sibling sweep
Siblings: none -- the source PR carried its own sibling sweep; this PR only carries that fix.
Pattern harvest
Not generalizable: this PR only carries a fix already on
main. The source PR has its own harvest.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.