Repository navigation
fix: refuse an agent's write to the tool auto-approve rules - #36083
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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fence is opt-in and off by default, so no default changes. One reason string claims more than the code does. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: an owner can stop the agent's file-edit tools from writing kiro-cli's auto-approve rules, which would let it skip approvals. This is a FIX, behind an opt-in.
[FIRST-PRINCIPLES-REVIEWED] 4844bb5 Description read[DESCRIPTION-READ] 3682cc75e6cd25f7cd1b2aba0332ca5306dfd0e170698dd2b20c5aa5fada2a86 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the new fence is opt-in, refusal-only, read from the live config on every check, and removed by switching the setting off. Notes
[DESIGN-REVIEWED] 4844bb5 Description read[DESCRIPTION-READ] 1b7dfaf0d2e25134a4bd1c996c6ef489092b53de161dd2850600d8b6e26ee483 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 |
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: |
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: |
4b53831 to
561e977
Compare
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates an 18% chance that this change introduces a defect, above the 12% limit for approving on its own. This adds an opt-in setting, An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
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 new guard is in the file-edit path gate, and it only applies when the owner turns on TIGHTENING: ADJUDICATED: 17 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: The diff assumes three spellings of the fenced paths: UNADJUDICATED: These guards are outside the shell composite, so no candidate can get a verdict on them:
[SCOPE-REVIEWED] 4844bb5 |
561e977 to
39304fa
Compare
39304fa to
b1b9503
Compare
b1b9503 to
7c89d51
Compare
|
span=5f2de26241bf
|
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving on 8450e119c8. Compared with the head I approved (dd961850c8), the patch differs only in _PACKAGE_LINE_BUDGET moving to the new main base (36,253 to 36,299, still +46). No code change. Auto merge stays on.
8450e11 to
3a2dcf8
Compare
|
span=147984562837
|
|
@bolichen97 one more small push, |
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving on 3a2dcf83cd. Compared with 8450e119c8, the only change is "mcp.protect_kiro_permission_rules": WHY_SAFETY in READONLY_REASONS (config_all_settings.py), so the all-settings page can no longer save that switch. That narrows who can turn the protection off. Auto merge stays on.
3a2dcf8 to
22acaed
Compare
|
span=b307dc41b7d2
|
|
@bolichen97 one more push, |
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving on 22acaedead. Compared with 3a2dcf83cd, the only change is which guidance an edit-gate refusal gets: write to protected path keeps its classification from main, because that wording is shared with credential paths, and only the hook gate wording maps to trust-root guidance. The write is refused either way. The new test pins .aws/credentials and .ssh/authorized_keys to their own guidance. Locally the changed test files pass (138 passed). Auto merge stays on.
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving on 0addac0a3f: a rebase onto main only. The patch is identical to 22acaedead, which I approved. Auto merge stays on.
kiro-cli's engine, which the kiro and kas harnesses run, reads permission rules from permissions.yaml and permissions.json under ~/.kiro/settings and ~/.kiro/workspace-roots. A rule with effect: allow runs its tool with no permission request, so the call never reaches Kiro Crew's tool gate. The agent's file-edit tools could write those files. Put the two user files and the workspace folder on the write-protected tier, the way ~/.kiro/settings/mcp.json already is, including under a moved KIRO_HOME. Reads are unchanged, every other file in the settings folder stays writable, and programs that write the files themselves (the engine saving a rule the user chose, the user's editor) are not affected. The edit gate's wording of a write refusal now reaches the same guidance the hook gate's wording does, so the agent is told to leave the edit to the user whichever gate answers.
|
@bolichen97 main moved and this PR conflicted, so I rebased it onto current main ( |
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving on 4844bb52ae: a rebase onto main after #36839 merged. The only change from 0addac0a3f is _PACKAGE_LINE_BUDGET on the new base (36,794 to 36,840, still +46). Auto merge stays on.
Sensitive change reviewHead: 4844bb5
|
Problem / Motivation
Goal: When the owner turns on
mcp.protect_kiro_permission_rules, an agent's file-edit tools can no longer write the files that decide which tools run without asking the user. With the setting off, the default, nothing changes from main.kiro-cli's engine, which the
kiroandkasharnesses run, reads permission rules frompermissions.yamlandpermissions.json. A rule witheffect: allowlets a tool run with no permission request, so that call never reaches Kiro Crew's tool gate. On main the file-edit gate (is_sensitive_write_path) does not refuse a write to those files, so an agent could add such a rule for itself. The file next to them,~/.kiro/settings/mcp.json, is already write-protected for the same reason.Why it matters
Which tools may run without asking is the user's decision. A file-edit tool that can write the rules file lets the agent make that decision for the user, for one tool or for a whole MCP server, and the user sees no prompt afterwards.
Not a goal
mcp.jsonentry has today. Follow-up work is tracked by the maintainers.approvals.jsonor to any other file in~/.kiro/settings.What changed (motivation → approach → change)
Symptom:
is_sensitive_write_path("~/.kiro/settings/permissions.yaml")isFalseon main, while the same call formcp.jsonisTrue.Cause: the write-protected tier names kiro-cli's agents folder and its MCP registry, and the table in
agent_sdk/native_allow_stores.pysays thekiroandkasharnesses need no row because their stores "are fenced by name". The permission rule files were never named.Change:
mcp.protect_kiro_permission_rules(config/integration_sections.py,config/section_builders.py,config-baseline.json), a bool next tomcp.honour_auto_approve, off by default. Off, nothing changes from main. On, the fence below applies. The gate reads it on every check from the live config, the same readmcp.honour_auto_approveuses, so no restart is needed.dashboard/handlers/config_all_settings.py: the setting is read-only on the Advanced settings page (READONLY_REASONS,WHY_SAFETY), likemcp.honour_auto_approve, so a generic config write cannot turn an opted-in fence off. Until Settings: owner-only Safety switches toggles for mcp.honour_auto_approve and mcp.protect_kiro_permission_rules #37251 adds owner-only Safety switches in Settings > Security, the owner turns it on withkirocrew config set mcp.protect_kiro_permission_rules true.security/paths_lists.pyandsecurity/paths.py: a new tuple_KIRO_PERMISSION_RULE_LEAVESwith the two user files (.kiro/settings/permissions.yaml,.kiro/settings/permissions.json) and the folder the engine keeps each workspace's rules in (.kiro/workspace-roots). While the setting is on,_permission_rule_rows()adds them to the write tier, includingKIRO_HOME, so a movedKIRO_HOMEand a symlink below$HOMEare covered the way they are formcp.json. If the config cannot be read, the fence stays on and a warning is logged, the way the sibling setting withholds its bypass. The engine reads the same two file names in both places; I read that from the installed engine's loader (KAS 3.2.1). The workspace folder is fenced whole because each workspace's subfolder is named by a hash, and the engine keeps only these rule files there.agent_sdk/native_allow_stores.py: the two reason strings forkiroandkasnow name the rule files.docs/system-specs/modules/security.mdandgovernance.md.Every other file in
~/.kiro/settingsstays writable (test_sibling_dirs_are_not_over_blockedis unchanged and passes). Reads are unchanged.builder-security: I read the skill and checked the change against it. The change adds no listener, port, route, storage grant or credential, and weakens no service's own auth. It is a list entry on the tool gate, behind a setting that is off by default, and only adds refusals when the owner turns it on. Nothing runs at import or at startup that can raise, so it cannot stop a Bot or a session from starting.
Backwards compatibility
No change by default: with
mcp.protect_kiro_permission_rulesoff (the default), every write main allows is still allowed. With it on, an agent's file-edit tool call that targets~/.kiro/settings/permissions.yaml,~/.kiro/settings/permissions.jsonor a path under~/.kiro/workspace-roots/is refused. Writer sweep for the opted-in case, on origin/main @ b677e0d:git grep -nE "permissions\.(yaml|json)" -- src/kiro_crewfinds onlykiro_cli_workspace_trust.py(a reader) and an unrelated comment incloud/iam.py. The always-allow path in feat: let one MCP tool be always allowed from its tool list or approval card #35002 stores its grants elsewhere and does not write these files.test_a_program_that_writes_the_file_itself_is_not_stoppedpins that the fence changes nothing on disk.Reader: src/kiro_crew/kiro_cli_workspace_trust.py:kiro_cli_trusts_folder -- chat -- reads the workspace file directly and
is_sensitive_pathstays False; test_reading_a_rules_file_stays_allowedReader: src/kiro_crew/project_hooks_consent.py:kiro_cli_trusts_folder -- chat -- calls the reader above, unchanged; test/test_project_hooks_consent.py passes
Tests
New file
test/test_kiro_permission_rules_write_fence.py. With the setting off (the default): the setting readsFalse; all four rule paths are not on the write tier, the edit gate allows them and the hook gate does not deny;write_protected_home_paths()does not list them; a movedKIRO_HOMEstays writable. With the setting on:kiro,kas) and per file name, a file-edit of the file is refused, by its home path and by its~spelling;_edit_target_denial) and the hook gate (HookManager.on_tool_call);KIRO_HOMEis covered;settings, a.bak,permissions.yml, a project's own.kiro/settings/permissions.yaml);~/.aws/credentialsor~/.ssh/authorized_keyskeeps its own guidance class, not trust-root.Updated:
test_config_mcp_section.py(round trip and load path of the new key),test_security_sensitive_paths.py(the resolved-path pin derives the new leaves),test_security_gate_liveness.py(line budget raised by 37, with the reason).Proof: PROVEN test/test_kiro_permission_rules_write_fence.py::test_a_file_edit_of_a_rules_file_is_refused[.kiro/settings/permissions.yaml-], test/test_kiro_permission_rules_write_fence.py::test_a_file_edit_of_a_rules_file_is_refused[.kiro/settings/permissions.yaml-kas], test/test_kiro_permission_rules_write_fence.py::test_a_file_edit_of_a_rules_file_is_refused[.kiro/settings/permissions.json-], test/test_kiro_permission_rules_write_fence.py::test_a_file_edit_of_a_rules_file_is_refused[.kiro/settings/permissions.json-kas], test/test_kiro_permission_rules_write_fence.py::test_a_file_edit_of_a_rules_file_is_refused[.kiro/workspace-roots/0123abcd/permissions.yaml-] (head b1b9503)
Also run locally: 1,669 related tests across 22 files (the security path, keystone, allow-store, deny-guidance, edit-gate and sandbox-mask suites) pass; black, isort, flake8, mypy on the changed modules, docs-lint, the comment-history, brand, harness-parity and file-line-cap gates pass.
Manual verification
In a throwaway home and data home (never a real
~/.kiro/settings), with this branch's code and the setting on:~/.kiro/settings/permissions.yamlwithdeny: Blocked: modification of write-protected config path: …;standardand instrict. So the engine's and the user's writes keep working.Not verified: macOS and Windows (path logic is shared and unit-tested; no live run there), and a real engine session saving a rule end to end.
Related Issues
None filed. Related: #34975 (the documentation page for this file). Follow-up work is tracked by the maintainers.
Sibling sweep
Swept: git grep -nE "permissions.(yaml|json)|workspace-roots" -- src/kiro_crew, plus the rule-file names and folders in the installed engine's policy loader
Sibling: src/kiro_crew/security/paths_lists.py -- changed here -- the workspace folder holds the same two file names and is fenced in the same tuple
Sibling: src/kiro_crew/agent_sdk/native_allow_stores.py -- not affected -- every other harness's permission files already have a row and are refused by the existing ratchet test
Pattern harvest
Rule candidate: review-prompt
Pattern: a file a harness reads to decide which tools run without a permission request must be on the file-tool write tier; a "fenced by name" reason in
NATIVE_ALLOW_STORES_NONEneeds a test that names each fileChecklist
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.