Skip to content

fix(sandbox): move the standing auto-approve grant onto a masked keystone - #13385

Closed
chenmingwei23 wants to merge 2 commits into
mainfrom
fix/config-standing-trust-9105
Closed

chenmingwei23 wants to merge 2 commits into
mainfrom
fix/config-standing-trust-9105

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

1. What is the problem?

config.json holds agent.dangerously_skip_permissions, and safety_override reads it at
every startup and re-establishes it as a DECLARED grant with no expiry. That one key is
therefore the difference between one session's elevation and the host's default posture.

Nothing refused a sandboxed shell that wrote it. Three controls could have:

Control Answer on the crew config.json
is_sensitive_write_path (agent file-edit tool gate) refuses
is_sensitive_path (read+write floor, the source the sandbox mask projects) does not cover it
is_sensitive_bash_command on printf '{}' > .../config.json does not refuse

The first two were measured, not read off the tier lists. The floor deliberately excludes
that leaf so reading config in-sandbox stays routine, and the bash gate matches no paths at
all by design -- its own docstring says a text matcher over command text "adds no
protection" and denies ordinary commands whenever a fenced spelling appears as data. So an
auto-approved session could append "dangerously_skip_permissions": true and turn its own
temporary elevation into every later session's default.

2. Why this issue matters to the user

Auto-approve is the control that catches everything else. An operator who grants it for one
task expects it to end with that task. A grant an agent can write for itself does not end,
and it removes the step that would have asked about whatever the agent did next -- so the
failure is not one bad action but the absence of the question on all of them.

3. How our fix solves it

The switch moves off config.json onto its own masked keystone.
standing_approval.json (config.loader.standing_approval_path) holds {"enabled": bool}
and is the only authority for a standing grant.
safety_override.standing_grant_declared() is the single declaration of that question, read
by the dashboard startup path and the headless --slack-only path alike, and it fails soft
to NO GRANT in every direction: absent, unreadable, malformed, not an object, an enabled
that is anything but the boolean true, a missing provenance MAC, and a MAC that does not
verify.

The document carries provenance, and that closes the one window a mask cannot. The mask
exists only on a release that knows this leaf, so on an EARLIER release the name is ordinary
and writable: a sandboxed agent could plant enabled: true there and wait for the upgrade to
adopt it. The document therefore carries a MAC keyed under the host secret
dashboard.token_secret already manages -- a key that PREDATES this change and is already
unreadable from a sandbox, which is exactly why it is the anchor. Anything this change minted
could itself have been planted first, so a nonce or a first-run marker would regress. The MAC
covers the decision only, so one minted for false cannot be carried onto a document claiming
true.

The leaf is on security._CREW_SECRET_LEAVES for the tool path and on
sandbox._CREW_HIDDEN_LEAVES -- masked, not sealed. That distinction is the whole reason the
leaf exists. A read-only bind covers a PATH, not the inode behind it, and the crew data-home
root is writable in every sandbox, so a sealed document stays writable through a second name
the sandbox can create itself; the module records the same shape for the live-target pointer
in its own words. A mask covers the name for every present and future spelling, so the
document cannot be opened at all -- no read of the grant and no link(2) source for it.

Masking is available here and NOT for config.json for one measurable reason: this leaf has
no in-sandbox reader, while the config document is resolved per call by the subagent cap
(mcp_tools/spawn.py), the quarantine threshold (mcp_quarantine.py) and the browser and
monitoring paths.

Because absence is this leaf's DEFAULT state and mount(2) cannot mask a name that does not
exist, the publisher writes an absent-equivalent {"enabled": false} before every spawn,
staged through the masked standing-approval-staging directory so the temp -- whose inode
becomes the grant -- is never a visible, linkable name. The stub is absent-equivalent by the
reader's own rule, and the direction is safe: a stale or empty read can only subtract a grant.

Both alias shapes refuse. A SYMLINK would make the mask bind the wrong file entirely; a
second HARDLINK leaves a writable path to the right one, which for an authorization document
is the same harm. The refusal has a real cost -- a link count above one is left by ordinary
operation (cp -al, rsnapshot, a dotfile manager) and a refusal stops every sandboxed spawn
on the host -- so it is paid with a notice rather than a surprise:
sandbox.standing_approval_unfitness() reports the identical sentence through
kirocrew doctor before a spawn ever meets it, which is the arrangement the live-target
pointer already uses for this exact trade.

This is the sixth time this repo has moved a control out of config.json for this reason.
computer_use.json, browser-mode-enabled, ops_mission_control_secrets.json,
ops_mission_control_policy.json and aws_service_consent.json each carry an entry comment
giving config.json's agent-writability as the motive.

What an operator has to do

This is a migration, and it is visible.

  • The old document: agent.dangerously_skip_permissions is still parsed and still read at
    startup, but it installs nothing. It is read only to WARN.
  • What to do: run kirocrew security standing-approval --enable on the gateway host, as
    the gateway's own user. That is the only writer, and it has to be one: the document carries
    a MAC an operator cannot hand-compute and a sandboxed process cannot mint, which is what
    makes a planted file inert. --disable withdraws. There is deliberately no dashboard writer
    and no API route -- a browser-reachable control over a never-expiring skip-every-approval
    grant is the surface this design removes, not one it adds.
  • If they do nothing: approvals are requested normally, which is the pre-grant behaviour.
    Nothing else in config.json changes, and the dashboard's timed auto-approve toggle still
    works -- it is a live operator action with a duration, not a document. Every startup logs
    one warning naming the exact file to write, so the change is discoverable from the log
    rather than only from this description. The settings help text and the generated config
    baseline name the keystone and mark the key deprecated.

config.json is deliberately NOT sealed

An earlier revision of this PR also sealed config.json and config.local.json read-only in
the sandbox and pre-created them. Both are removed, on two grounds:

  • It breaks a documented agent workflow. kirocrew config set, kirocrew agent create and
    kirocrew app enable are bundled-skill verbs an agent runs from its own sandboxed shell
    (builtin_skills/kirocrew-commands/SKILL.md), and they reach update_config_locked ->
    atomic_write, whose temp-and-rename onto a mountpoint fails. The writer census behind the
    seal looked for in-process callers and missed the CLI being invoked in-sandbox.
  • Pre-creating an empty document sets the loader's loaded_base, which bypasses its
    never-setup return and drives a doomed MIGRATE_AGENTS write-back on every in-sandbox load.

And it buys nothing now: with the switch on the masked keystone, writing config.json
decides no authorization, so the escalation this PR exists to close is closed without it.
test/test_config_standing_trust_surface.py pins the non-seal with its reason, so it cannot
be reinstated without meeting that argument.

4. What tests we did

test/test_config_standing_trust_surface.py pins the whole surface, one assertion per
control: the file-edit gate refuses a write to the config documents; the read+write floor and
the bash gate do not reach them; neither is sealed, pre-created or masked, while
computer_use.json still is (the control proving the sealed set is populated); the new leaf
is masked and NOT merely sealed, is on the read+write floor, and its staging directory is
masked and pre-created; one publisher serves every masked file leaf. The reader is pinned in
both directions -- a document the writer verb produced grants, and absent, false, {},
"true", 1, [], invalid JSON, an empty file, a document with NO provenance, one with a
forged MAC, and one carrying a MAC minted for the false posture all answer no grant. The verb
is pinned round-tripping through the reader, since an operator cannot hand-compute the MAC and
a broken writer would leave the grant unreachable. The alias policy is pinned through the
publisher itself, not only through its helper.

test/test_config_standing_trust_surface.py with test_sandbox_governance_mask.py,
test_dashboard_yolo_startup.py, test_safety_override.py,
test_remote_provisioner_seam.py and test_sandbox_dev_fleet_live_target.py: 855 passed,
-n0. The startup-gate cases in test_slack_events_coverage.py and
test_dashboard_server_coverage.py: 13 passed, -n0.

Mutation-verified, each mutation restored and compared byte-identical afterwards:

  • Unmasking the grant leaf reddens exactly one: the "masked, not merely sealed" pin.
  • Re-adding config.json to the seal list reddens exactly one: the non-seal pin.
  • Removing the warn policy from the publisher's call reddens exactly one. That mutation
    initially did NOT redden, which is how the first version of the alias pin was found to test
    the helper rather than the wiring; the pin now drives the publisher against a hardlinked
    document and requires it to return.
  • Loosening the reader's strict is True identity test to a truthy check reddens exactly
    two: the "true" string and the 1 cases.

Gates: comment-history, the repo black ratchet (no new offender; the three files it still
lists pre-date this branch), isort, flake8 and mypy clean. The added diff is strict ASCII.

Pattern harvest

Rule candidate: repo convention, enforced by a test rather than a linter.

Pattern: an authorization protected by a read-only SEAL rather than a MASK. A seal answers a
write to one path; it does not make the document unopenable, so the inode stays reachable
under a second name and the value stays readable. When a leaf has no in-sandbox reader,
masking is strictly stronger and costs nothing, and "does anything in-sandbox read this?" is
a question a reviewer can answer from a census. This PR reached for the seal first and had to
be corrected twice -- once because a seal cannot close the shape it was reached for, once
because it broke a documented in-sandbox workflow.

Second candidate, narrower: any leaf added to _CREW_READONLY_LEAVES or
_CREW_HIDDEN_LEAVES whose absence is the default state, but which is not added to the
matching pre-create list. The protection is then vacuous exactly on a fresh install, because
mount(2) skips an absent path. live_target.json, cloud.json,
ssh_auth_sock_consent.json, agent_model_state.json and playwright-cli each carry an
entry comment saying so, which is five arrivals at one defect. The repo already has the right
enforcement shape next door: test_sandbox_governance_mask refuses to let a sealed leaf ship
unclassified. A sibling pin -- every protected leaf whose absent state is reachable is either
pre-created or explicitly exempted with a stated reason -- would catch this class.

5. Any other suggestions on the work

The publisher for masked file leaves is now one parametrised function
(_materialize_masked_file_leaf) rather than two near-identical bodies; each caller supplies
its own refusal prose, because an operator reading it is about to go look at that file, and
its own hardlink policy, because what a second name costs differs per leaf.

The standing-approval leaf gets its own kirocrew doctor section
(_doctor_standing_approval_leaf), reporting the launcher's own sentence rather than a
paraphrase, so an operator who meets the refusal later reads one diagnosis rather than two.

Specs of record updated: docs/system-specs/modules/security.md gains the keystone entry,
records the authority move in its YOLO section, and states why sealing the config documents
is deliberately not the answer; config.md marks the old key legacy; decisions.md and three
security/paths.py rationale comments are corrected where they cited config.json's
shell-writability as their motive -- the reason that holds is that the document is
agent-READABLE and no path-based control refuses a shell write there, while a ceiling needs
both halves.

Eighteen further sites across app code and side specs repeat the superseded claim. They
describe the config PATCH surface rather than the sandbox disposition, so they are left for a
follow-up sweep rather than widened into this diff.

Fixes #9105
Fixes #13435

@chenmingwei23
chenmingwei23 requested review from a team and cixuuz September 24, 2026 15:07
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging 7af71d043102a79110ba418240876a8fe3f6a9a6. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/dashboard/server.py:2677 -- Config-declared standing grants are no longer restored (origin: validation)
if not standing_grant_declared():
Existing dangerously_skip_permissions: true → startup returns here → the declared grant is not re-established.
Anchor: backend-security-controls
Fix: Preserve the config key as a standing-grant declaration in both startup paths.
[GPT-REVIEWED] 7af71d0
[BLOCK-MERGE] 7af71d0

Adjudication (Opus 5) — is blocking on each finding proportionate?

F1 — harm rung: LOW, and in the fail-CLOSED direction. Conditions confirmed: the key is still parsed (config/sections.py:1204), so an operator carrying agent.dangerously_skip_permissions: true reaches server.py:2676-2678, where the keystone read (safety_override.py:2285-2339) returns False for an absent standing_approval.json and startup returns with no grant. Recovery: warn_if_config_declares_standing_grant (safety_override.py:2342-2359) logs a warning that names the exact migration command, its writer exists (cli_commands.py:2498), and the dashboard's timed auto-approve toggle is untouched — one command, loud, non-silent. The remedy the finding asks for ("preserve the config key as a standing-grant declaration") re-anchors a never-expiring skip-every-approval grant on a document that is agent-readable and shell-writable in-sandbox, which is the escalation this PR exists to close and which the spec records in the same commit (docs/system-specs/modules/security.md:2273); its cost is therefore negative, not merely large.

[ADJUDICATION] 7af71d0 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] 7af71d0

[ADJUDICATION-FENCED] 7af71d0 fenced=1 flagged=1
FLAG F1 src/kiro_crew/dashboard/server.py:2677 -- The only condition reaching this is a legacy config key the PR deliberately demotes to a warning; the outcome is deny-by-default (approvals requested normally, timed toggle intact) with a one-command documented migration, and the requested fix would restore the agent-writable grant anchor this change removes.
[GPT-ADJUDICATED-FENCED] 7af71d0

🏷️ Fenced finding(s) machine-flagged as likely edge case

The security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.

  • F1 src/kiro_crew/dashboard/server.py:2677 — The only condition reaching this is a legacy config key the PR deliberately demotes to a warning; the outcome is deny-by-default (approvals requested normally, timed toggle intact) with a one-command documented migration, and the requested fix would restore the agent-writable grant anchor this change removes.

    /ai-review override gpt 7af71d043102a79110ba418240876a8fe3f6a9a6: The only condition reaching this is a legacy config key the PR deliberately demotes to a warning; the outcome is deny-by-default (approvals requested normally, timed toggle intact) with a one-command documented migration, and the requested fix would restore the agent-writable grant anchor this change removes.
    

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7af71d043102a79110ba418240876a8fe3f6a9a6: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 7af71d043102a79110ba418240876a8fe3f6a9a6 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

security.md's new "no authorization is decided by this document at all" overstates: hooks.auto_approve_* still widens approvals from config.json — scope the claim.

Not justified as shipped

  • Item 9 — rides along: the diff writes "so no authorization is decided by this document at all" (security.md) and the description says "writing config.json decides no authorization", yet the same edited paragraph keeps three approval-widening key families in config.json — hooks.auto_approve_tools / auto_approve_sources / auto_approve_subagent_* (grep "auto_approve" in that paragraph; auto_approve_tools ships in config/defaults.json), applied live within ~2s.
    Subtraction: shrink the sentence to the standing grant ("the standing-approval switch is no longer decided here") — delete the "no authorization at all" clause.
    Clears when: the security.md sentence is scoped to the standing grant.
  • Item 10 — one consumer, generalized: standing_grant_mac(enabled: bool) — grep standing_grant_mac( finds 2 call sites (cli_commands.py:2481, safety_override.py:2318), both passing True; no False MAC is ever minted (the stub carries none).
    Subtraction: drop the enabled parameter and mint over the literal {"enabled": true} payload.
    Clears when: the parameter is deleted, or a caller minting False exists.

What this change ships

Inventory (10 items) — 8 justified

Intent: stop a sandboxed agent from turning one session's elevation into a permanent auto-approve grant by writing config.json — a FIX, shipping its replacement control. (The workflow's patch file also carries base-drift hunks from already-merged main commits #13285/#13433/#13304; verified against the branch's two commits and excluded.)

  1. agent.dangerously_skip_permissions in config.json no longer installs the standing grant; startup warns with the migration command — justified
  2. The standing grant lives in standing_approval.json, valid only with a host-keyed provenance MAC — justified
  3. New kirocrew security standing-approval --enable/--disable is the document's only writer; no dashboard or API writer — justified
  4. The grant document and its staging directory are unopenable in every sandbox — justified
  5. Every Linux spawn first publishes an {"enabled": false} stub; a symlink or extra hard link refuses all spawns — justified
  6. kirocrew doctor reports an unfit grant document before spawns start failing — justified
  7. Headless --slack-only startup reads the same grant authority as the dashboard — justified
  8. Settings help and config baseline mark the old key DEPRECATED, naming the new command — justified
  9. Sibling keystone rationale prose rewritten across security.md/config.md/decisions.md — rides along: one sentence overclaims (entry above)
  10. Public standing_grant_mac(enabled) mint function — one consumer, generalized: both callers pass True

[FIRST-PRINCIPLES-REVIEWED] 7af71d0

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 7af71d043102a79110ba418240876a8fe3f6a9a6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Upgrade silently drops existing dangerously_skip_permissions grants — unattended cron/Slack flows stall on approvals with only a startup log line as notice.

Watch

  • Non-migration is correct (auto-adopting the config value would carry an agent-planted grant forward, defeating the fix), but the description's own rationale for permanence — "flows driven from Slack/Discord and from cron where nobody is watching" — is exactly the operator who won't see the warning log. That regression needs a louder channel than the log.
    Clears when: the shipping release's notes/changelog section names the deprecation and the kirocrew security standing-approval --enable command prominently.
  • The grant's validity is bound to token_signing.key's lifecycle: rotating or restoring that key silently withdraws the grant (safe direction, warned), and conversely --disable unlinks the file but never invalidates a once-minted true document — a copy captured and replanted through a downgrade window (where the leaf is unmasked and readable) re-grants on the next upgrade, with key rotation as the only remedy. The security.md entry added here records neither residual, though the repo's convention (e.g. the sel_hmac.key note) is to carry residuals in the spec.
    Clears when: security.md's standing-grant entry records the key-rotation coupling and the disable-doesn't-invalidate residual with its remedy.

Suggestions

  • The keystone's writer lifecycle (_publish_standing_grant, _standing_grant_key_is_persisted) sits in cli_commands.py reaching into sandbox._STANDING_APPROVAL_STAGING_LEAF and three token_secret privates; housing it in safety_override beside the reader and MAC would keep the document's whole contract in one module.

[DESIGN-REVIEWED] 7af71d0

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of 7af71d043102a79110ba418240876a8fe3f6a9a6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

Migrated operators' standing auto-approve silently stops installing, with only a gateway-log warning as notice — the headless Slack/cron operators it serves won't see it.

Watch

  • The population this grant exists for ("flows driven from Slack/Discord and from cron where nobody is watching the dashboard", safety_override.py) is exactly the population that never reads the gateway log, yet warn_if_config_declares_standing_grant only calls logger.warning, and the new _doctor_standing_approval_leaf section checks leaf shape but never the deprecated key. Their first symptom after upgrade is unexplained approval prompts or stalled unattended tasks. Once per host at upgrade × stalled headless flows × persists until migrated. Smallest fix: add a doctor line for "old key set in config.json, no keystone grant — run kirocrew security standing-approval --enable".

Suggestions

  • config-baseline.json/sections.py help still opens with the promise that no longer holds ("Skip EVERY tool approval confirmation, permanently.") before "DEPRECATED here"; open with the deprecation and the replacement command, drop the path-vs-inode mechanism clause.
  • _standing_approval checks --disable first, so --enable --disable together silently withdraws; refuse contradictory flags with one line.

[UX-REVIEWED] 7af71d0

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

Which legitimate operations does 7af71d043102a79110ba418240876a8fe3f6a9a6 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: the reviewer's own judgement; no confirmed regression.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 12 classified, 0 newly refused, 12 still allowed.
  • ubuntu-latest (platform posix): 12 classified, 0 newly refused, 12 still allowed.
  • windows-latest (platform windows): 12 classified, 0 newly refused, 12 still allowed.

No candidate flipped from allowed to refused.

candidates.json is written with 15 boundary-probing rows. Emitting the review as my final message.

Scope-Verdict: CONCERNS

TIGHTENING: the standing skip-every-approval grant's authority moves off config.json onto a MAC-verified, sandbox-masked keystone — - if not cfg.agent.dangerously_skip_permissions: / + warn_if_config_declares_standing_grant(cfg.agent.dangerously_skip_permissions) / + if not standing_grant_declared(): (dashboard/server.py, with the same swap in slack/events.py), backed by + "standing_approval.json" / + "standing-approval-staging" on security._CREW_SECRET_LEAVES and sandbox._CREW_HIDDEN_LEAVES, a pre-spawn materializer that refuses unfit leaf shapes, and a provenance MAC keyed under the host secret — the ONE threat refused is a sandboxed or prompt-injected agent authoring the grant document (or flipping the config key) so that its own never-expiring auto-approval becomes the host's startup default, including planting it pre-upgrade: "on an EARLIER release the name is ordinary and writable and a sandboxed agent could plant enabled: true there and wait for the upgrade to adopt it."

ADJUDICATED: 15 candidates, 0 confirmed newly-refused
No confirmed rows were handed back for this run. That is consistent with the mechanism: the shell composite's three measured tiers (is_sensitive_bash_command, audit_bash_exfiltration, is_denied) are textually untouched by this diff — none of them consume _CREW_SECRET_LEAVES — so the candidates probe accidental over-match on the new leaf names and the touched CLI area rather than an edited rule.

PLATFORM COVERAGE: posix (ls -la ~/.kiro/crew, cat ~/.kiro/crew/config.json, and find ~/.kiro/crew -samefile ~/.kiro/crew/standing_approval.json — the exact remedy the new multilink refusal tells the operator to copy), windows (Get-ChildItem -Force $env:USERPROFILE\.kiro\crew, type %USERPROFILE%\.kiro\crew\config.json, findstr /s /n standing_approval src\kiro_crew\*.py — the drive-profile, backslash, %VAR%/$env: spellings of the same operations, since the leaf fence casefold-matches on Windows too), and any for the platform-neutral kirocrew verbs (doctor, security standing-approval bare and --disable, security deny-list/verify/events, config get/set) and git grep. Not coverable by any candidate: macOS's Seatbelt half of the mask and the Linux-only spawn-path materializer have no shell-command spelling on any host — no leg can answer for them, and they are named below. Per-leg verdicts are the deterministic fold's to report, not mine.

UNADJUDICATED:

  • The grant-authority move itself. Guard: standing_grant_declared() (safety_override.py), reached at gateway startup by _apply_startup_yolo (dashboard/server.py) and init_socket_mode (slack/events.py); it reads standing_approval.json and verifies the MAC under dashboard.token_secret. Candidate legitimate inputs I could not get a verdict for: (1) every pre-migration installation carrying agent.dangerously_skip_permissions: true in config.json and no keystone — the grant no longer installs, so Slack- and cron-driven flows (the exact "nobody is watching the dashboard" flows the no-expiry design protects) revert to prompt-for-everything, with a gateway-log warning as the only notice; (2) a keystone minted before a token_signing.key rotation or restore-from-backup onto a different key — the grant is silently refused at every startup, and the migration warning does not fire unless the old config key is also still set; (3) a fresh or degraded install whose signing key is ephemeral — --enable refuses (fail-closed, but an operation an operator loses).
  • The Linux pre-spawn refusal. Guard: _materialize_standing_approval_mask_target → _refuse_unless_sole_regular_link / _refuse_if_standing_approval_symlink, wired into namespace_argv. A pre-existing standing_approval.json with a link count above one (cp -al, rsnapshot, a dotfile manager — shapes the diff itself calls "ordinary operation") or a symlinked leaf (dotfile managers routinely symlink into ~/.kiro/crew) now refuses EVERY sandboxed agent spawn on the host. The diff pays for this with a kirocrew doctor section, but the regression class — all agent starts on hosts with hard-link snapshot regimes over the data home — is real, deliberate, and invisible to the shell classifier.
  • The file-tool path fence additions. _CREW_SECRET_LEAVES gains the two names, so is_sensitive_path/is_sensitive_write_path now refuse agent file-tool reads and writes of them, and path_contains_sensitive counts them for bulk-operation roots; deny_diff's tier table deliberately runs no path tier over shell rows, so no row could obtain a verdict here. The diff's claim that the leaf has no in-sandbox reader held up against the base tree; the residual candidates are file-tool (not shell) operations: an agent reading its own grant status, and bulk ops (e.g. the Notes builtin's git add -A) rooted at a directory that now contains the leaf.
  • The sandbox mask. _CREW_HIDDEN_LEAVES additions are mount(2) behavior, not command text; nothing the classifier settles.

One narrowing note in prose (not a row): I deliberately did not propose kirocrew security standing-approval --enable as a golden path. It is the operator's sanctioned verb, but a corpus row would pin the agent tool gate open on the one command that installs a never-expiring skip-every-approval grant — the overlap between the legitimate operation and the threat shape is the operation itself, and its in-sandbox defense is the unreadable signing key, not the command gate.

[SCOPE-REVIEWED] 7af71d0

@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 Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

Three advisory findings; nothing blocks.

FINDING — src/kiro_crew/cli_commands.py:2451 — --disable unlinks whatever sits at the leaf and unconditionally prints "✅ Standing auto-approve grant withdrawn" with SEL outcome="withdrawn", but _materialize_standing_approval_mask_target publishes the absent-equivalent {"enabled": false} stub at that same real path on every Linux namespace_argv spawn, so on any host that has ever spawned an agent the FileNotFoundError "nothing to withdraw" branch is unreachable and both the operator and the audit log are told a never-expiring grant was revoked when none was ever in force → Fix: call standing_grant_declared() before the unlink and report/audit the absent case distinctly.

FINDING — docs/architecture/security-deep-dive.md:552 — the security-model doc still states "The one non-expiring grant is agent.dangerously_skip_permissions in operator-owned config … re-established and re-audited on every startup", and governance.md:3061 still calls permanent "the standing agent.dangerously_skip_permissions declaration", while _apply_startup_yolo and init_socket_mode now gate solely on standing_grant_declared(), so an operator following either doc sets the config key and gets no grant → Fix: point both sentences at the keystone standing_approval.json and kirocrew security standing-approval --enable (untouched files, so the remedy is outside this diff). (origin: validation)

FINDING — docs/system-specs/modules/config.md:1797 — the reason the hooks.auto_approve_* applier SEL-logs was rewritten from config.json being "writable by an auto-approved agent shell" to "a write to config.json from outside the sandbox needs no restart to take effect", which states a latency property instead of the reachability one and leaves config.md — the spec owning the live watcher and its appliers — with no record that an in-sandbox shell can write that document, contradicting this same diff's security/paths.py comments and warn_if_config_declares_standing_grant text → Fix: keep the restart clause but restore the in-sandbox-writability statement as the audit's reason.

[OPUS-REVIEWED] 7af71d0

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7af71d043102a79110ba418240876a8fe3f6a9a6: <one-sentence reason>

@chenmingwei23
chenmingwei23 force-pushed the fix/config-standing-trust-9105 branch from e5f7be9 to 7f20d41 Compare September 24, 2026 16:32
@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 readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 24, 2026
@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 Sep 24, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/config-standing-trust-9105 branch from dd17a5f to a7ccce5 Compare September 24, 2026 17:39
@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 Sep 24, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/config-standing-trust-9105 branch 4 times, most recently from d025098 to cefb82b Compare September 24, 2026 23:23
@chenmingwei23 chenmingwei23 changed the title fix(sandbox): seal the runtime config read-only against a sandboxed shell fix(sandbox): move the standing auto-approve grant onto a masked keystone Sep 24, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/config-standing-trust-9105 branch from cefb82b to 899f3e8 Compare September 24, 2026 23:43
@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 Sep 24, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/config-standing-trust-9105 branch from 899f3e8 to b697c4c Compare September 25, 2026 00:04
@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 Sep 25, 2026
…tone

config.json holds agent.dangerously_skip_permissions, the standing approval
posture safety_override re-establishes at every startup. The agent file-edit
gate refuses that write, but nothing refused a shell: the read+write floor
excludes that leaf so reading config stays routine, and the bash gate matches
no paths by design. An auto-approved session could therefore write the key and
turn one session's elevation into the default for every later one.

standing_approval.json becomes the only authority, read fail-closed through
safety_override.standing_grant_declared by both the dashboard and the headless
slack-only startup. The leaf is masked rather than sealed, which makes the name
unopenable: no read of the grant, and no link source for it. Masking is
available here and not for config.json because nothing in-sandbox reads it.
It is published with an absent-equivalent document before every spawn, since a
mask cannot cover a name that does not exist and absent is the default state.
A symlinked leaf refuses; a pre-existing hardlink warns, because refusing it
would cost every spawn on the host over a state a snapshot tool creates.

config.json is deliberately NOT sealed. A read-only bind there breaks the
in-sandbox kirocrew config set verb through atomic_write's rename, and it
closes nothing a mask does not close better, since a bind covers a path while
the inode stays reachable under a second name.

The publisher for masked file leaves is now one parametrised function instead
of two near-identical bodies, each caller supplying its own prose and policy.

Migration: the old key is still read, to warn. An operator writes
{"enabled": true} to standing_approval.json to keep a standing grant; until
then approvals are requested normally and the timed toggle is unaffected.

Fixes #9105
Fixes #13435
@chenmingwei23
chenmingwei23 force-pushed the fix/config-standing-trust-9105 branch from b697c4c to 28d64a1 Compare September 25, 2026 00:22
@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 Sep 25, 2026
hmac.compare_digest refuses two str arguments when either holds a non-ASCII
character: it raises TypeError instead of answering False. standing_grant_declared
is contracted to fail soft to NO GRANT in every direction, and both callers reach it
through an unguarded to_thread, so a planted document carrying a non-ASCII mac
aborted gateway startup rather than declining the grant. Compare bytes, with
surrogatepass for the lone surrogate json.loads accepts; the expected value is a
hexdigest and stays ASCII. Two pins cover both shapes, and reverting the comparison
reddens exactly those two.

Also corrects prose and one log line the move left behind. Four places still said
config.json carried a read-only seal, which it does not: the seal was dropped so an
in-sandbox `kirocrew config set` keeps working, so no path-based control refuses a
shell write to that document. Two places still told operators to hand-edit the
grant, which the provenance mac refuses; the sole writer is named instead. The
startup success log asserted dangerouslySkipPermissions=true while the function no
longer reads that key, and its docstring named the key as the authority.

The CLI verb's newly added function-local imports move to module scope. Three tests
patched those symbols on their source modules, which only worked while the verb
re-resolved them per call; they now patch the module that holds them, and two of
those assertions had gone vacuous.
@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 readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 25, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Consolidation: this PR and PR #13478 both implement issue #13435 on the same seams

Both PRs retire agent.dangerously_skip_permissions as the grant source and read a new masked keystone instead. They give the shared symbols different values:

Seam here (7af71d0431) PR #13478 (4164fb3ff9)
loader.standing_approval_path() standing_approval.json (src/kiro_crew/config/loader.py:1111) standing-approval/grant.json
sandbox._STANDING_APPROVAL_LEAF file leaf plus a staging dir (src/kiro_crew/sandbox.py:266,272) directory leaf
startup gate (dashboard/server.py:2616-2617, slack/events.py:937-938) standing_grant_declared() standing_approval.is_declared(mode)

Running git merge-tree on the two heads gives conflicts in 8 files: server.py, slack/events.py, sections.py, security/paths.py, security.md, config-baseline.json and both startup test files. They can't both land as written.

Only this PR has:

  • The provenance MAC (src/kiro_crew/safety_override.py:2219-2246, with the byte comparison at :2331). PR fix(approvals): read the standing auto-approve switch from an unopenable keystone #13478 has no MAC. So a grant.json planted before the upgrade, or while sandbox=off, is honoured once the mask holds. Its own design review names the second case.
  • The writer kirocrew security standing-approval (src/kiro_crew/cli_commands.py:2237). It writes the CRITICAL SEL record before the grant (:2302-2308) and refuses an ephemeral key (:2213). The MAC needs this writer, because an operator can't compute the MAC by hand.
  • Doc and test corrections. The spec and rationale now say config.json is VISIBLE, not sealed, with pins in test/test_config_standing_trust_surface.py:62. It also carries Fixes #9105.

Only PR #13478 has:

  • _keystone_is_masked, which refuses the grant where Crew's mask does not hold (Windows, delegated macOS, off). On those hosts, with this PR, an agent shell can read token_signing.key and mint a valid MAC, or just run the CLI verb itself.
  • A directory leaf pre-created at 0700. A directory can't be a link(2) source. A host-side os.replace (--enable) or unlink (--disable) can't detach it the way it detaches a single-file bind in running sandboxes. And it needs no staging leaf.
  • A reader that catches UnicodeDecodeError. Here, path.read_text(encoding="utf-8") (safety_override.py:2287) only catches FileNotFoundError and OSError. A file that isn't valid UTF-8 escapes both startup gates and stops the gateway from booting.
  • A current base. It is 0 commits behind main; this branch is 183 behind.

Suggestion: build on PR #13478, since its mask check and directory leaf address the harder problem. Port two things into it:

  • the MAC check, into standing_approval.is_declared;
  • the CLI writer, which can write grant.json inside the directory that is already masked, so no staging leaf is needed.

Porting the writer reverses PR #13478's stated "no CLI verb" choice (standing_approval.py:45-47 there), so that needs an explicit decision.

Two things to fix during the port:

From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Closing this in favour of #13478, following the maintainer audit in
#13385 (comment). Both PRs
implement #13435 on the same seams, give shared symbols different values, and conflict in
eight files, so only one can land. I verified the audit's factual legs against committed
heads before acting on it, and both hold.

Why #13478 survives

It carries a security precondition this PR does not have at all.
standing_approval._keystone_is_masked is not merely present on #13478, it is enforced:
a declared-but-not-masked grant returns False.

declared = _read_all().get(GRANT_FIELD) is True
if declared and not _keystone_is_masked(requested_mode):
    logger.warning(...)
    return False

It composes sandbox.credential_mask_applies() and sandbox.spawn_delegates_masking() and
then checks the leaf really sits inside a masked target, so the grant is refused on hosts
where masking cannot hold: Windows, macOS delegating to kiro-cli's internal sandbox, and a
mode that clamps to off. Both heads share five callers of credential_mask_applies;
#13478 adds a sixth in src/kiro_crew/standing_approval.py, a file absent from this PR
entirely. So the refusal is uniquely #13478's, and that settles which half survives
independently of the recommendation.

Reconciling the two by name was never available. _STANDING_APPROVAL_LEAF is a
file here ("standing_approval.json", sandbox.py:266) and a directory on #13478
("standing-approval", sandbox.py:242). A rebase that merged those by name would have
produced something that type-checks and is wrong. The three shared symbols:

Symbol this PR 7af71d0431 #13478 4164fb3ff9
loader.standing_approval_path() standing_approval.json (loader.py:1111) standing-approval/grant.json (loader.py:1237)
sandbox._STANDING_APPROVAL_LEAF "standing_approval.json", a file, plus _STANDING_APPROVAL_STAGING_LEAF (:272) "standing-approval", a directory, no staging leaf
startup gate standing_grant_declared(), no argument (server.py:2617, slack/events.py:938) standing_approval.is_declared(cfg.agent.sandbox) (server.py:2678, slack/events.py:934)

Two corrections to the audit

The audit's freshness claim was accurate on 2026-09-25 and is not accurate now. It said
#13478 was "0 commits behind main". Measured today:

behind main ahead state conflicts vs main
this PR 452 2 dirty 3 files, 4 hunks
#13478 272 2 dirty 1 file

So #13478 holds no freshness edge. It wins on the mask precondition above, and on being the
cheaper rebase by a wide margin: one conflicted file against three.

What does not die with this close

Two capabilities exist only here, and they are recorded as work owed on top of #13478 in
#14454, with the pointers verified against this head: the provenance MAC
(safety_override.py:2242, byte comparison at :2331) and the operator CLI writer
(cli_commands.py:2237, dispatched at :2330). That issue also carries two items for
whoever holds #13478: the MAC signs only {"enabled": <bool>}, so a copied document grants
again after --disable until the host secret rotates; and #13478's description still
credits this PR with a config.json read-only seal as defence in depth, which does not
land now.

The branch is kept, so everything above is recoverable at
7af71d043102a79110ba418240876a8fe3f6a9a6.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 27, 2026
@bolichen97
bolichen97 deleted the fix/config-standing-trust-9105 branch November 6, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

2 participants