Skip to content

fix: refuse an agent's write to the tool auto-approve rules - #36083

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/protect-permissions-rules-write
Nov 14, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/protect-permissions-rules-write

Conversation

@buluoray

@buluoray buluoray commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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 kiro and kas harnesses run, reads permission rules from permissions.yaml and permissions.json. A rule with effect: allow lets 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

  • No change to the OS sandbox, and no change to how shell commands are judged. This PR covers the file-edit tools, the same reach the mcp.json entry has today. Follow-up work is tracked by the maintainers.
  • No change to approvals.json or to any other file in ~/.kiro/settings.
  • No new UI for granting a tool, and no change to what the rules mean or how the engine reads them.
  • No change to the documentation page in fix: point agents at permissions.yaml to auto-approve one MCP tool #34975.

What changed (motivation → approach → change)

Symptom: is_sensitive_write_path("~/.kiro/settings/permissions.yaml") is False on main, while the same call for mcp.json is True.

Cause: the write-protected tier names kiro-cli's agents folder and its MCP registry, and the table in agent_sdk/native_allow_stores.py says the kiro and kas harnesses need no row because their stores "are fenced by name". The permission rule files were never named.

Change:

  • New setting mcp.protect_kiro_permission_rules (config/integration_sections.py, config/section_builders.py, config-baseline.json), a bool next to mcp.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 read mcp.honour_auto_approve uses, 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), like mcp.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 with kirocrew config set mcp.protect_kiro_permission_rules true.
  • security/paths_lists.py and security/paths.py: a new tuple _KIRO_PERMISSION_RULE_LEAVES with 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, including KIRO_HOME, so a moved KIRO_HOME and a symlink below $HOME are covered the way they are for mcp.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 for kiro and kas now name the rule files.
  • Specs: docs/system-specs/modules/security.md and governance.md.

Every other file in ~/.kiro/settings stays writable (test_sibling_dirs_are_not_over_blocked is 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_rules off (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.json or a path under ~/.kiro/workspace-roots/ is refused. Writer sweep for the opted-in case, on origin/main @ b677e0d:

  • Kiro Crew's own code: no writer. git grep -nE "permissions\.(yaml|json)" -- src/kiro_crew finds only kiro_cli_workspace_trust.py (a reader) and an unrelated comment in cloud/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.
  • kiro-cli and its engine: they write the files with their own file calls (saving a rule the user chose, recording a workspace trust answer). Those calls are not tool calls and never reach this gate. test_a_program_that_writes_the_file_itself_is_not_stopped pins that the fence changes nothing on disk.
  • The user's own editor: the same, not a tool call.
  • Clients outside this repository: none mint or present anything here; the rule is about a local file path.

Reader: src/kiro_crew/kiro_cli_workspace_trust.py:kiro_cli_trusts_folder -- chat -- reads the workspace file directly and is_sensitive_path stays False; test_reading_a_rules_file_stays_allowed
Reader: 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 reads False; 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 moved KIRO_HOME stays writable. With the setting on:

  • per harness (kiro, kas) and per file name, a file-edit of the file is refused, by its home path and by its ~ spelling;
  • both gates refuse it: the always-enforced edit gate (_edit_target_denial) and the hook gate (HookManager.on_tool_call);
  • a moved KIRO_HOME is covered;
  • nine neighbours stay writable (other files in settings, a .bak, permissions.yml, a project's own .kiro/settings/permissions.yaml);
  • reads stay allowed;
  • a program that writes the file itself is not stopped (first write and atomic replace);
  • an edit-gate refusal for ~/.aws/credentials or ~/.ssh/authorized_keys keeps 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:

  • the hook gate answers a file-edit of ~/.kiro/settings/permissions.yaml with deny: Blocked: modification of write-protected config path: …;
  • a process that writes the file with its own file call, which is how the engine saves a rule, still succeeds with the sandbox off, in standard and in strict. 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_NONE needs a test that names each file

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

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 12, 2026 20:51
@buluoray
buluoray requested a review from CrysisDeu November 12, 2026 20:51
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/paths.py

  • src/kiro_crew/security/paths_lists.py

  • src/kiro_crew/security/paths_targets.py

  • @buluoray comment: does not name the current head 4844bb5; post it again for this head

  • @bolichen97: missing the ## Sensitive change review heading

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 4844bb52ae4bce8ef45fa36cb63a680a747021fa
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

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

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 4844bb52ae4bce8ef45fa36cb63a680a747021fa 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 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 4844bb52ae4bce8ef45fa36cb63a680a747021fa — 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 fence is opt-in and off by default, so no default changes. One reason string claims more than the code does.

Notes

  • Item 5 — undeclared overstatement: the new kiro reason string in native_allow_stores.py says the rule files "are fenced by name in security.paths_lists". _permission_rule_rows() returns [] unless the owner opts in, so on a default install they are not fenced. Subtraction: delete the added "permissions.yaml / permissions.json rule files…" clause and the added "the permissions rule files included" from the kas string, which keeps main's wording.

What this change ships

Inventory (6 items) — 5 justified

Intent: 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.

  1. New setting mcp.protect_kiro_permission_rules, off by default (1 consumer, _permission_rule_rows) — justified
  2. With the setting on, file-edit writes to ~/.kiro/settings/permissions.{yaml,json} and ~/.kiro/workspace-roots are refused, including under a moved KIRO_HOME — justified
  3. The setting is read-only on the Advanced settings page, so a generic config write can't turn it off — justified
  4. A degraded or unreadable config keeps the fence on and logs a warning — justified
  5. The kiro/kas reason strings now name the rule files as fenced — undeclared, overstates the default
  6. push_policy no longer masks these leaves' parents, which keeps ~/.kiro from being hidden — justified

[FIRST-PRINCIPLES-REVIEWED] 4844bb5

Description read

[DESCRIPTION-READ] 3682cc75e6cd25f7cd1b2aba0332ca5306dfd0e170698dd2b20c5aa5fada2a86

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 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

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

  • _permission_rule_rows() turns the fence on when mcp is in degraded_sections or the config can't be read, including for an owner who never opted in. That breaks the Goal's promise: "With the setting off, the default, nothing changes from main." The effect can be undone, but consider failing on only when the raw section really holds true.
  • The push_policy.py hunk in the builtin auto_improvement app is a second concern the description doesn't explain (it may sit past the truncation point). The spec's line "push_policy never masks these leaves' parents" accounts for it. The app isn't in adoption-pins.json, so fixing it in place is allowed.

[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 .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 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 4844bb5

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

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

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4844bb5

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

@buluoray
buluoray force-pushed the crew/slack/protect-permissions-rules-write branch from 4b53831 to 561e977 Compare November 12, 2026 21:00
@buluoray
buluoray enabled auto-merge (squash) November 12, 2026 21:06
@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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, mcp.protect_kiro_permission_rules, off by default. When it is on, the file-edit tools refuse writes to kiro-cli's permissions.yaml and permissions.json under ~/.kiro/settings, and to anything under ~/.kiro/workspace-roots. I checked that the setting is read live at each check, as the sibling mcp.honour_auto_approve reader does, and that both the edit gate and the hook gate go through sensitive_write_path_refusal. A moved KIRO_HOME is re-anchored only when the leaves are in the list being built, so nothing is added while the setting is off. push_policy leaves out these leaves' parents so all of ~/.kiro is not hidden. Nothing in the OS sandbox reads the new leaves. The setting is read-only on the Advanced settings page, like its siblings. Kiro Crew itself writes none of these files; kiro_cli_workspace_trust only reads them. The tests cover on and off, both gates, a moved KIRO_HOME, neighbouring files, reads and the degraded-config branch. One deviation: a degraded or unreadable config turns the fence on even for owners who never opted in. That only adds refusals and the description says it is intended, so I did not block on it. Not

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 4844bb52ae · 439 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 4844bb52ae4bce8ef45fa36cb63a680a747021fa 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): 6 classified, 0 newly refused, 6 still allowed.

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 mcp.protect_kiro_permission_rules, which is off by default. The shell deny composite does not read paths, so the shell rows below can only show that the shell tiers did not change. They cannot test the guard itself. That guard, including its rule that a degraded config keeps the fence on, is not adjudicated and is named below.

TIGHTENING: sensitive_write_path_refusal and write_protected_home_paths() now add _KIRO_PERMISSION_RULE_LEAVES (.kiro/settings/permissions.yaml, .kiro/settings/permissions.json, .kiro/workspace-roots) to the write tier. -- The threat it refuses is an agent's file-edit tool writing an effect: allow rule that kiro-cli then runs with no approval card: + if not matched and (rule_rows := _permission_rule_rows()): / + matched = _path_in_home_dirs(path_str, rule_rows, base_dir, strict=True)

ADJUDICATED: 17 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: The diff assumes three spellings of the fenced paths: $HOME-rooted (~/.kiro/...), re-anchored under KIRO_HOME, and the separator form each host uses. I wrote posix rows for each: tilde paths, $KIRO_HOME/settings/..., a project-relative .kiro/settings/..., and the neighbours in the same folder (cli.json, mcp.json, .bak). I wrote windows rows for the same operations: %USERPROFILE%\.kiro\... under cmd, $env:USERPROFILE\... under PowerShell, %KIRO_HOME%\settings\..., the kirocrew.cmd forwarder, and a backslash pytest path. I wrote no any rows because every candidate carries a path or an executable name. I wrote no UNC-path row, because nothing in the diff assumes a network home.

UNADJUDICATED: These guards are outside the shell composite, so no candidate can get a verdict on them:

  • The file-edit gate. Call paths: hooks.on_tool_call(tool_kind="edit", diff_path=…) → hook_runtime/gate_tiers.py:752 sensitive_write_path_refusal, and llm_helpers_parts/tool_input_denials._edit_target_denial → sensitive_write_path_refusal → _permission_rule_rows() → live.snapshot() or KiroCrewConfig.load(). The candidate inputs I would have submitted are all file-edit writes with the fence OFF, where the change has to be a no-op: ~/.kiro/settings/permissions.yaml, %USERPROFILE%\.kiro\workspace-roots\<bucket>\permissions.json, and $KIRO_HOME/settings/permissions.json. The tests pin these as allowed.
  • The fail-closed branch. _permission_rule_rows fences when cfg._base_unreadable, cfg._overlay_unreadable, "mcp" in cfg.degraded_sections, or any exception is true. The comment says this "keeps an existing opt-in safe", but the branch does not check whether the owner ever opted in. It turns the fence on for someone who never enabled it whenever their config is degraded. Example: a hand-edit leaves a stray comma in config.json, and agent edits of ~/.kiro/settings/permissions.yaml are refused even though the setting was never on. I can't confirm this without a file-edit classifier, so it does not block. It is a narrowing to consider: fail closed only when the last good snapshot had the setting on.
  • The redirect floor. platform/redirect_floor.redirects_clear now refuses a redirect into these leaves while the fence is on or the config is degraded, for example kiro-cli … > ~/.kiro/settings/permissions.json under an allowedCommands grant. That only withholds the spec-builtin-grant auto-approval, so the call goes back to a prompt and is not denied. The classifier does not measure it.
  • push_policy.write_protected_targets. It now excludes these leaves from parent masking. That loosens the mask, so it is outside this lane.

[SCOPE-REVIEWED] 4844bb5

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@buluoray
buluoray force-pushed the crew/slack/protect-permissions-rules-write branch from 561e977 to 39304fa Compare November 13, 2026 01:39
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 13, 2026
@buluoray
buluoray force-pushed the crew/slack/protect-permissions-rules-write branch from 39304fa to b1b9503 Compare November 13, 2026 04:50
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 13, 2026
@buluoray
buluoray force-pushed the crew/slack/protect-permissions-rules-write branch from b1b9503 to 7c89d51 Compare November 13, 2026 19:18
@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 13, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

span=5f2de26241bf
self-added: yes
mechanism: write_protected_targets() skips the kiro-cli permission-rule leaves like native_allow_stores

  • The file-tool fence also masks the entire Kiro home during candidate admission

fixed in 7c89d51: write_protected_targets() now leaves out _KIRO_PERMISSION_RULE_LEAVES, the same way it already leaves out native_allow_stores.home_leaves().
Those leaves sit on the write tier only to refuse the agent's file-edit tools; masking their parent would hide all of ~/.kiro.
~/.kiro/crew is still masked. permissions.yaml/json's parent ~/.kiro/settings stays masked through mcp.json, as on main.
test_write_protected_targets_masks_existing_parent_dirs creates ~/.kiro/workspace-roots and asserts ~/.kiro is not returned; red before the fix, green after.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 14, 2026
bolichen97
bolichen97 previously approved these changes Nov 14, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 14, 2026
@buluoray
buluoray force-pushed the crew/slack/protect-permissions-rules-write branch from 8450e11 to 3a2dcf8 Compare November 14, 2026 15:26
@buluoray

Copy link
Copy Markdown
Contributor Author

span=147984562837
self-added: yes
mechanism: the new safety key is listed in READONLY_REASONS with WHY_SAFETY, beside its sibling mcp.honour_auto_approve

  • The new safety switch can be turned off from the generic Advanced settings page

fixed in 3a2dcf8: "mcp.protect_kiro_permission_rules": WHY_SAFETY in READONLY_REASONS (dashboard/handlers/config_all_settings.py), so descriptor() gives it mode: "readonly" and generic_spec() returns no PATCH rule for it.
test_config_all_settings.py::test_a_security_sounding_key_is_editable_only_after_review was red on 8450e11 ("add each to READONLY_PATHS ... ['mcp.protect_kiro_permission_rules']") and passes now; honour_auto_approve has no other read-only list to mirror.
The owner turns it on with kirocrew config set mcp.protect_kiro_permission_rules true (checked in a scratch home); owner-only Safety switches toggles for both keys are #37251.

@buluoray

Copy link
Copy Markdown
Contributor Author

@bolichen97 one more small push, 3a2dcf83cdfd: the Opus lane found the new key was editable from the generic Advanced settings page, so it is now read-only there (READONLY_REASONS, WHY_SAFETY), like mcp.honour_auto_approve. One line, plus the repo test that pins it. Owner-only toggles for both keys are #37251. Could you approve again?

@buluoray
buluoray requested a review from bolichen97 November 14, 2026 15:26
bolichen97
bolichen97 previously approved these changes Nov 14, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@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 Nov 14, 2026
@buluoray
buluoray force-pushed the crew/slack/protect-permissions-rules-write branch from 3a2dcf8 to 22acaed Compare November 14, 2026 15:52
@buluoray

Copy link
Copy Markdown
Contributor Author

span=b307dc41b7d2
self-added: yes
mechanism: the trust-root anchor on the edit gate's shared refusal prefix is removed; deny_guidance.py matches main again
resolution: removed in 22acaed

  • The new trust-root anchor matches the fixed prefix of every edit-gate refusal

fixed in 22acaed: the "write to protected path" anchor is removed from DENY_CLASS_TRUST_ROOT, so git diff origin/main -- src/kiro_crew/deny_guidance.py is empty. Credential paths, native allow stores and install roots get the guidance they get on main; the hook gate's modification of write-protected config path wording still reaches trust-root, as on main.
test_an_edit_gate_refusal_of_a_credential_path_keeps_its_own_guidance sends the edit gate's real refusal for ~/.aws/credentials and ~/.ssh/authorized_keys through classify_deny: red on 3a2dcf8 ('trust_root' == 'aws_credential', 'trust_root' == 'secret_file'), green now. The test that pinned the anchor is removed; 375 related tests pass.

@buluoray

Copy link
Copy Markdown
Contributor Author

@bolichen97 one more push, 22acaedead09: the Opus lane found that the new trust-root anchor in deny_guidance.py matched every edit-gate refusal, so an edit of ~/.aws/credentials was told it was the governance ceiling. I removed that anchor; deny_guidance.py now matches main, with a regression test for credential paths. Could you approve again?

@buluoray
buluoray requested a review from bolichen97 November 14, 2026 15:52
@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 14, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
bolichen97 previously approved these changes Nov 14, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@buluoray

Copy link
Copy Markdown
Contributor Author

@bolichen97 main moved and this PR conflicted, so I rebased it onto current main (4844bb52ae4b). The only hand-resolved line is _PACKAGE_LINE_BUDGET in test/test_security_gate_liveness.py (main's 36,794 plus this PR's 46). No code change since the head you approved. The rebase dismissed your approval; could you approve again?

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: 4844bb5

  • What rule changed: a new setting, mcp.protect_kiro_permission_rules, off by default. When the owner turns it on, the file-edit write fence refuses an agent's write to kiro-cli's own tool auto-approve rules: ~/.kiro/settings/permissions.yaml, ~/.kiro/settings/permissions.json and ~/.kiro/workspace-roots (_KIRO_PERMISSION_RULE_LEAVES, added to the write tier by security.paths._permission_rule_rows). If config.json cannot be parsed, the fence stays on. The setting is read-only on the Advanced settings page (READONLY_REASONS, WHY_SAFETY), like mcp.honour_auto_approve; the owner turns it on with kirocrew config set mcp.protect_kiro_permission_rules true until Settings: owner-only Safety switches toggles for mcp.honour_auto_approve and mcp.protect_kiro_permission_rules #37251 adds a Settings toggle. Auto Improvement's write_protected_targets() leaves these leaves out of its sandbox mask.
  • Before -> after: with the setting off (the default), nothing changes from main. With it on, an agent's file-edit tool is refused for those three paths. Reads are unchanged, and other ~/.kiro/settings files stay writable. deny_guidance.py is unchanged from main.
  • Worst case if wrong: an owner who turned the fence on finds a legitimate edit of these files refused. kiro-cli and the user's editor write them outside the agent's tool gate, so the user's own "always allow" choices keep working. If the fence is off, behaviour is exactly main's.
  • Evidence checked: the default is off and matches main (tests for both values). An unparseable config keeps an opted-in fence on (GPT finding, test red before the fix). A malformed mcp section is repaired to defaults as on main, so no other mcp.* setting changes. The generic settings page cannot write the key (test_a_security_sounding_key_is_editable_only_after_review). An edit-gate refusal for ~/.aws/credentials or ~/.ssh/authorized_keys keeps main's guidance class (Opus finding, test red before the fix). GPT and Opus show no blocking findings on this head, and bolichen97 approved it (review 5906114836).
  • No regression:
    • Tools still work: with the setting off, no write is refused that main allows. test_kiro_permission_rules_write_fence.py covers both values; 225 related tests pass on this head.
    • Backward compatible: one new config key with a default of off. Nothing migrates, and existing permission files are left as they are.
    • Existing tests: test_security_sensitive_paths.py, test_security_gate_liveness.py, test_config_all_settings.py, test_config_mcp_section.py and test_ai_github_profile_coverage.py pass; CI is green on this head except this gate.
  • How to undo: revert the PR's single commit. It adds one setting, list entries and the mask skip, so a revert restores the old behaviour with no data to clean up; a stored mcp.protect_kiro_permission_rules value is then ignored.

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.

3 participants