Repository navigation
fix(sandbox): move the standing auto-approve grant onto a masked keystone - #13385
chenmingwei23 wants to merge 2 commits into
Conversation
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging 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) 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 ( [ADJUDICATION] 7af71d0 total=0 uphold=0 downgrade=0 [ADJUDICATION-FENCED] 7af71d0 fenced=1 flagged=1 🏷️ Fenced finding(s) machine-flagged as likely edge caseThe 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.
False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS security.md's new "no authorization is decided by this document at all" overstates: Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: 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.)
[FIRST-PRINCIPLES-REVIEWED] 7af71d0 |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Upgrade silently drops existing Watch
Suggestions
[DESIGN-REVIEWED] 7af71d0 |
UX Review (Fable 5) — 🟡 CONCERNSUX-level review of 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
Suggestions
[UX-REVIEWED] 7af71d0 |
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
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 ADJUDICATED: 15 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix ( UNADJUDICATED:
One narrowing note in prose (not a row): I deliberately did not propose [SCOPE-REVIEWED] 7af71d0 |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsThree advisory findings; nothing blocks. FINDING — src/kiro_crew/cli_commands.py:2451 — FINDING — docs/architecture/security-deep-dive.md:552 — the security-model doc still states FINDING — docs/system-specs/modules/config.md:1797 — the reason the [OPUS-REVIEWED] 7af71d0 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
e5f7be9 to
7f20d41
Compare
dd17a5f to
a7ccce5
Compare
d025098 to
cefb82b
Compare
cefb82b to
899f3e8
Compare
899f3e8 to
b697c4c
Compare
…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
b697c4c to
28d64a1
Compare
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.
|
Consolidation: this PR and PR #13478 both implement issue #13435 on the same seams Both PRs retire
Running Only this PR has:
Only PR #13478 has:
Suggestion: build on PR #13478, since its mask check and directory leaf address the harder problem. Port two things into it:
Porting the writer reverses PR #13478's stated "no CLI verb" choice ( 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. |
|
Closing this in favour of #13478, following the maintainer audit in Why #13478 survivesIt carries a security precondition this PR does not have at all. declared = _read_all().get(GRANT_FIELD) is True
if declared and not _keystone_is_masked(requested_mode):
logger.warning(...)
return FalseIt composes Reconciling the two by name was never available.
Two corrections to the auditThe audit's freshness claim was accurate on 2026-09-25 and is not accurate now. It said
So #13478 holds no freshness edge. It wins on the mask precondition above, and on being the What does not die with this closeTwo capabilities exist only here, and they are recorded as work owed on top of #13478 in The branch is kept, so everything above is recoverable at |
1. What is the problem?
config.jsonholdsagent.dangerously_skip_permissions, andsafety_overridereads it atevery 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:
config.jsonis_sensitive_write_path(agent file-edit tool gate)is_sensitive_path(read+write floor, the source the sandbox mask projects)is_sensitive_bash_commandonprintf '{}' > .../config.jsonThe 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": trueand turn its owntemporary 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.jsononto 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, readby the dashboard startup path and the headless
--slack-onlypath alike, and it fails softto NO GRANT in every direction: absent, unreadable, malformed, not an object, an
enabledthat is anything but the boolean
true, a missing provenance MAC, and a MAC that does notverify.
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: truethere and wait for the upgrade toadopt it. The document therefore carries a MAC keyed under the host secret
dashboard.token_secretalready manages -- a key that PREDATES this change and is alreadyunreadable 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
falsecannot be carried onto a document claimingtrue.The leaf is on
security._CREW_SECRET_LEAVESfor the tool path and onsandbox._CREW_HIDDEN_LEAVES-- masked, not sealed. That distinction is the whole reason theleaf 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.jsonfor one measurable reason: this leaf hasno 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 andmonitoring paths.
Because absence is this leaf's DEFAULT state and
mount(2)cannot mask a name that does notexist, the publisher writes an absent-equivalent
{"enabled": false}before every spawn,staged through the masked
standing-approval-stagingdirectory so the temp -- whose inodebecomes 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 spawnon the host -- so it is paid with a notice rather than a surprise:
sandbox.standing_approval_unfitness()reports the identical sentence throughkirocrew doctorbefore a spawn ever meets it, which is the arrangement the live-targetpointer already uses for this exact trade.
This is the sixth time this repo has moved a control out of
config.jsonfor this reason.computer_use.json,browser-mode-enabled,ops_mission_control_secrets.json,ops_mission_control_policy.jsonandaws_service_consent.jsoneach carry an entry commentgiving
config.json's agent-writability as the motive.What an operator has to do
This is a migration, and it is visible.
agent.dangerously_skip_permissionsis still parsed and still read atstartup, but it installs nothing. It is read only to WARN.
kirocrew security standing-approval --enableon the gateway host, asthe 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.
--disablewithdraws. There is deliberately no dashboard writerand 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.
Nothing else in
config.jsonchanges, and the dashboard's timed auto-approve toggle stillworks -- 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.jsonis deliberately NOT sealedAn earlier revision of this PR also sealed
config.jsonandconfig.local.jsonread-only inthe sandbox and pre-created them. Both are removed, on two grounds:
kirocrew config set,kirocrew agent createandkirocrew app enableare bundled-skill verbs an agent runs from its own sandboxed shell(
builtin_skills/kirocrew-commands/SKILL.md), and they reachupdate_config_locked->atomic_write, whose temp-and-rename onto a mountpoint fails. The writer census behind theseal looked for in-process callers and missed the CLI being invoked in-sandbox.
loaded_base, which bypasses itsnever-setup return and drives a doomed
MIGRATE_AGENTSwrite-back on every in-sandbox load.And it buys nothing now: with the switch on the masked keystone, writing
config.jsondecides no authorization, so the escalation this PR exists to close is closed without it.
test/test_config_standing_trust_surface.pypins the non-seal with its reason, so it cannotbe reinstated without meeting that argument.
4. What tests we did
test/test_config_standing_trust_surface.pypins the whole surface, one assertion percontrol: 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.jsonstill is (the control proving the sealed set is populated); the new leafis 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 aforged MAC, and one carrying a MAC minted for the
falseposture all answer no grant. The verbis 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.pywithtest_sandbox_governance_mask.py,test_dashboard_yolo_startup.py,test_safety_override.py,test_remote_provisioner_seam.pyandtest_sandbox_dev_fleet_live_target.py: 855 passed,-n0. The startup-gate cases intest_slack_events_coverage.pyandtest_dashboard_server_coverage.py: 13 passed,-n0.Mutation-verified, each mutation restored and compared byte-identical afterwards:
config.jsonto the seal list reddens exactly one: the non-seal pin.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.
is Trueidentity test to a truthy check reddens exactlytwo: the
"true"string and the1cases.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_LEAVESor_CREW_HIDDEN_LEAVESwhose absence is the default state, but which is not added to thematching 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.jsonandplaywright-clieach carry anentry comment saying so, which is five arrivals at one defect. The repo already has the right
enforcement shape next door:
test_sandbox_governance_maskrefuses to let a sealed leaf shipunclassified. 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 suppliesits 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 doctorsection(
_doctor_standing_approval_leaf), reporting the launcher's own sentence rather than aparaphrase, so an operator who meets the refusal later reads one diagnosis rather than two.
Specs of record updated:
docs/system-specs/modules/security.mdgains the keystone entry,records the authority move in its YOLO section, and states why sealing the config documents
is deliberately not the answer;
config.mdmarks the old key legacy;decisions.mdand threesecurity/paths.pyrationale comments are corrected where they citedconfig.json'sshell-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