Repository navigation
fix(sandbox): mount config.json and config.local.json read-only - #14486
Conversation
|
Intent: Stop a sandboxed agent process from changing the owner's settings files ( |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS On Linux the seal is agent-defeatable today: an induced gateway save detaches the bind, reopening the WatchThe description concedes "an in-sandbox agent can reach some of those [save] paths indirectly through an ordinary tool call" — so on Linux a prompt-injected agent can induce a [DESIGN-REVIEWED] afbeced Description read[DESCRIPTION-READ] f458095d6a0c13fa19d02bd73cd331ef3137ae0a8df41a11225fec01acc03ff0 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the seal on a real Linux sandbox before merge: the description says "Linux not run by hand," and the new tests pin set membership, not a refused write. Not justified as shipped
What this change shipsInventory (7 items) — 6 justifiedIntent: stop a sandboxed agent from rewriting the owner's settings files — the switches in them (
The rewritten "deliberately VISIBLE / writing it there is routine" pin is reversed with evidence: the description's writer sweep counts zero legitimate in-sandbox writers, and the clamp claim is shown wrong for switches. The Linux rename-detach residual is declared at its level and deferred to #15143 — accepted-and-deferred. [FIRST-PRINCIPLES-REVIEWED] afbeced Description read[DESCRIPTION-READ] f34a8e271331c0f6bdc3f63c86a3fadf005ddfc6642e88e788702ba7652aa5c8 That sha256 names the PR description this verdict read. Recompute it with |
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. Scope-Verdict: CONCERNS TIGHTENING: OS-sandbox read-only seal of the runtime config pair — ADJUDICATED: 14 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix — home-path reads of both sealed leaves under both UNADJUDICATED: The tightening lives almost entirely outside the classifier's reach. The guard is the kernel-level read-only mount of
[SCOPE-REVIEWED] afbeced |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsIn-sandbox FINDING — src/kiro_crew/sandbox.py:597 — sealing [OPUS-REVIEWED] afbeced Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
c7b32d1 to
f9d8c28
Compare
|
|
|
|
|
|
|
f9d8c28 to
4fa37f9
Compare
|
self-added: no
|
|
|
Also in 9eb4013: |
|
self-added: no
|
|
self-added: yes
|
|
self-added: no
|
|
|
|
|
/ai-review override gpt 9eb4013: alias bypass is the recorded warn-not-refuse residual shared by every MS_RDONLY ceiling leaf; the PR narrows the base (unsealed file) and adds no new alias path. |
Human judgment recorded@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
self-added: yes
|
|
self-added: yes
|
|
|
|
|
Scope reduced at head fd19e9a. This PR is now the seal only: Why: keeping the inode gave up every property rename provides for free and each had to be rebuilt by hand. It grew What that leaves open: on Linux a per-file bind is detached when the host next renames onto that name, so the seal holds from spawn until the owner's next save, then that sandbox sees the file unsealed until it respawns. This is the same residual every other sealed leaf already carries and is recorded in |
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
buluoray
left a comment
There was a problem hiding this comment.
LGTM. I checked this at head afbeced0f7.
config.json and config.local.json join the read-only crew leaves (sandbox.py ~597, with matching child-readable and pre-create entries), so an agent can still read its config but can no longer rewrite it. The leaves were never read-gated, so this narrows write access only; read scope is unchanged. The one intended casualty, kirocrew config set/unset/defaults run from the agent shell, is the declared breaking change and now exits 1 with a pointer to the dashboard (cli_config.py ~120-130, ~529-535). The operator's own terminal and the dashboard keep write access.
In-sandbox writers: migration write-back in KiroCrewConfig.load() is best-effort and logs "Config write-back failed" (config/loader.py ~4414). A mutate that returns None returns from update_config_locked before writing and only touches the .lock sidecar. The MCP servers write no config directly (learn_add, cron_add and set_project go through the gateway). The pre-created config.local.json is {}, which every overlay reader treats as a no-op.
Mutations (baseline 669 passed): dropping the pair from _CREW_READONLY_LEAVES reddens test_config_leaf_is_read_only_in_every_mode and test_every_non_hidden_leaf_is_classified_for_a_foreign_child; from the pre-create list reddens test_config_leaf_is_precreated_so_the_linux_bind_has_a_file; making the hint always None reddens 11 reports_the_seal_* tests; checking only filename and not filename2 reddens publishing_rename. test_sandbox_governance_mask.py needed no edit because its pin is structural and goes red when the child-readable entry is dropped. security.md records both residuals (the Linux per-file bind detach tracked in #15143, and a second-name alias).
Bot dispositions: the earlier in-place-write spans no longer apply, since the final diff keeps temp+rename. The hint-wording spans are addressed. The rebuttal on agent create/workspace create showing a raw traceback holds, since those fail closed. The GPT alias/hardlink rebuttal holds (EXDEV across the bind, Seatbelt denies file-link, and it's documented).
Non-blocking follow-ups:
builtin_skills/kirocrew-commands/SKILL.md~352-356 still listsconfig set/defaultswith no note that they fail inside the sandbox. An earlier disposition says a note was added, but it isn't in the final diff.- Comments still say "config.json is agent-writable" in
apps/routes.py(4551, 4690),config/sections.py:174,computer_use/types.py:351,autonudge_service/judge_tick.py:55andapps/registry_pipeline/sources.py:354. - In-sandbox knowledge search can reach
_verify_custom_model, which writes the custom embedding-model stamp. Under the seal it degrades tocustom:unavailableuntil the gateway records the stamp. That fails closed, but it's worth moving to the gateway. - The body's "Ran locally" list names
test_weixin_qr.py, which the final diff no longer touches.
Problem / Motivation
Goal: The owner's settings files cannot be changed from inside the agent sandbox.
~/.kiro/crew/config.jsonandconfig.local.jsonhold the owner's settings. Some of those settings loosen safety limits. Today a sandboxed agent shell can write both files, while its sibling ceiling files (denied_commands.json,security_policy.json,computer_use.json, ...) are already mounted read-only.Why it matters
Settings that loosen limits should only be changed by the owner, from the dashboard or their own terminal. They should not be changeable by the process those limits apply to.
Not a goal
config.jsoninto separate files.What changed (motivation → approach → change)
config.jsonandconfig.local.jsonare mounted read-only, in every tier, and pre-created when absentkirocrew configprints a one-line hint when the write is refusedBoth settings files were writable from inside the sandbox → the settings loader's value clamp only bounds numbers, it cannot stop a valid value that loosens a switch → mount both files read-only, like the other ceiling files.
sandbox.pyadds both files to_CREW_READONLY_LEAVESand_CREW_PRECREATE_READONLY_FILE_LEAVES, so Linux can bind-mount them even when the overlay does not exist yet. Reads still work: both are listed as child-readable, since every in-sandboxKiroCrewConfig.load()opens them and neither was ever on the read-gate floor.cli_config.pycatches the denial and prints where to change the setting instead. It decides from the failing file name and errno, not from the sandbox env marker, becausecli.main()clears that marker before dispatch. The hint names both causes: the sandbox by design, or plain file permissions.security/paths.pyshortens the comment that said the loader clamp covers any value written intoconfig.json. Specs (security.md,config.md,decisions.md,messaging.md,subagent.md,aws-control.md,app-kit-platform.md,docs/feature-map/README.md) now say both files are read-only in the sandbox, andsecurity.mdrecords the two residuals below.Backwards compatibility
Breaking: an agent shell inside the sandbox can no longer run
kirocrew config set/unset/defaults. Writer sweep on origin/main: the dashboard, settings API, channel handlers and the user's own CLI all write from the gateway or the user's process, outside the sandbox, and are unaffected. The loader's migration write-back already catches a failed write and logs a warning. MCP servers read config and write through the gateway API.Residuals, both shared with every other sealed leaf:
config.json(a dotfile manager) is sealed by name only; the other name stays writable. The Linux spawn path treats it as it does every sealed leaf: a resolving link warns and continues; a dangling link (target absent) refuses the spawn.Tests
test/test_sandbox_config_seal.py: both files are in the read-only and pre-create sets for every tier and stay child-readable; the CLI hint fires for a denial naming either file with no sandbox env marker set, replaces the generic write error, and does not fire for other files or other errors.test/test_sandbox_protected_name_holds.py: leaf-only count raised by 6 (two root-level leaves × three home spellings). They sit at the data-home root, which no directory mask can hold, the same ascredential_redaction.jsonandredaction-allow.test_sandbox_config_seal.py,test_sandbox_protected_name_holds.py,test_security_gate_liveness.py,test_sandbox_governance_mask.py,test_cli_config_defaults.py,test_cli_commands_coverage.py,test_config_loader.py,test_weixin_qr.py(1604 passed, 1 skipped); black, flake8, isort and mypy clean on the changed files.Manual verification
On macOS, from inside a live standard-tier session, confirmed
config.jsonwas openable for write before the change. The nested Seatbelt run cannot be repeated here (sandbox-exec cannot nest), so the read-only effect is covered by the set tests above and CI. Linux not run by hand.Related Issues
Reported privately. Linux per-file bind residual for all sealed leaves: #15143.
Pattern harvest
Rule candidate: review-prompt
Pattern: a file under the crew home whose contents can loosen a safety limit must be in the sandbox read-only set; a per-file bind seal on Linux lasts only until the host's next rename onto that name.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)