Repository navigation
fix: refuse root runs on a person's data home and name the repair - #31602
Conversation
3c68968 to
9af42cc
Compare
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The refusal in Notes
What this change shipsInventory (9 items) — 7 justifiedIntent: a person whose data home was left owned by root can see why Kiro Crew fails, get the one command that repairs it, and a root run can no longer break it again. FIX.
[FIRST-PRINCIPLES-REVIEWED] a426f7f Description read[DESCRIPTION-READ] d5e258cfb1f395874fcf7440ce524a2ba0b3269de5f0ea49c38cdc4d5d2d02ef That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the root refusal skips Notes
[DESIGN-REVIEWED] a426f7f Description read[DESCRIPTION-READ] 59cf1278ade743fe0c1a303c070dc78dd3dfd6410ff4ec46e929eb4178a9774d 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 |
UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)UX-level review of UX-Verdict: PASS cannot evaluate: missing the Settings "Couldn't check who owns the Kiro Crew files." state. It is new, shows on every Settings tab, and no screenshot shows it. Evidence gaps
Notes
[UX-REVIEWED] a426f7f Description read[DESCRIPTION-READ] df9121d480856ecb43eaba1ae26e3cae0ee0d1159198602008e6cd835b3b2184 That sha256 names everything this verdict read: the PR description, plus the 6 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
5feae7b to
1159416
Compare
1159416 to
30d1602
Compare
7ddf844 to
b579bb9
Compare
A run as root that keeps the person's HOME (sudo on macOS keeps it) writes root-owned files into their data home. The normal account then cannot read config.json, and creating a Bot fails with only the generic "Couldn't create the Bot". kirocrew now refuses, before it touches the data home, when it runs as root and the data home belongs to another account, and names the same command without sudo. Root in its own home, `service` and `stop` are left alone. The damage an earlier run left is found and named: the gateway logs it at start, `kirocrew doctor` reports it with the repair line, /api/status carries it as data_home_access, and POST /api/agents refuses with 409 data_home_not_owned plus fix_command before it writes anything. The New Bot dialog and Settings show one sentence and the command to copy, in every shipped language.
b579bb9 to
a426f7f
Compare
…1602) A run as root that keeps the person's HOME (sudo on macOS keeps it) writes root-owned files into their data home. The normal account then cannot read config.json, and creating a Bot fails with only the generic "Couldn't create the Bot". kirocrew now refuses, before it touches the data home, when it runs as root and the data home belongs to another account, and names the same command without sudo. Root in its own home, `service` and `stop` are left alone. The damage an earlier run left is found and named: the gateway logs it at start, `kirocrew doctor` reports it with the repair line, /api/status carries it as data_home_access, and POST /api/agents refuses with 409 data_home_not_owned plus fix_command before it writes anything. The New Bot dialog and Settings show one sentence and the command to copy, in every shipped language. (cherry picked from commit 64beae3) Originally authored on main by Bolin Chen (bolichen97); authored here with the public identity because the commit guard refuses the original address.
…1602) A run as root that keeps the person's HOME (sudo on macOS keeps it) writes root-owned files into their data home. The normal account then cannot read config.json, and creating a Bot fails with only the generic "Couldn't create the Bot". kirocrew now refuses, before it touches the data home, when it runs as root and the data home belongs to another account, and names the same command without sudo. Root in its own home, `service` and `stop` are left alone. The damage an earlier run left is found and named: the gateway logs it at start, `kirocrew doctor` reports it with the repair line, /api/status carries it as data_home_access, and POST /api/agents refuses with 409 data_home_not_owned plus fix_command before it writes anything. The New Bot dialog and Settings show one sentence and the command to copy, in every shipped language. (cherry picked from commit 64beae3) # Conflicts: # docs/system-specs/modules/crew-mode.md
Problem / Motivation
Goal: When files in the data home belong to another account (left by an earlier root run), Kiro Crew stops making it worse, says so in plain words, and gives the one command that repairs it.
A macOS user could not create a Bot. The New Bot dialog said only "Couldn't create the Bot", and the gateway log repeated
[Errno 13] Permission denied: ~/.kiro/crew/config.json. Files in the data home were owned by root, most likely from an earliersudo kirocrew ...(sudo on macOS keepsHOME). Giving the folder back to the user fixed it.Why it matters
Once the data home holds root-owned files, every config read and every Bot create fails, and nothing in the product names the cause. A person with no idea a root run happened has no way out.
Not a goal
kirocrew serviceorkirocrew stop, which are documented to run under sudo.What changed (motivation → approach → change)
kirocrewexits before it touches the data home when it runs as root and the data home (or the closest folder above it) belongs to another account. It prints the same command without sudo.check_data_homefinds which of the data home,config.json,members/andmemory_stores/this account does not own or cannot read and write, plus one repair line:sudo chown -R <user> <home> && chmod -R u+rwX <home>.kirocrew doctor(Data Home, counted as an issue);/api/statusasdata_home_access;POST /api/agentsrefuses with 409data_home_not_ownedandfix_commandbefore it writes anything./api/statusreports it. All 12 languages.Root working in root's own home is left alone, and so are
serviceandstop, which the docs tell people to run with sudo.builder-security checked: no new route, listener or bind.
POST /api/agentsstays owner-gated and only gains an early refusal;/api/statusstays behind the dashboard credential and adds paths under the data home, which that caller already owns.Specs updated:
docs/system-specs/modules/cli.md(new "Data home owned by another account") andcrew-mode.md(New Bot dialog).Backwards compatibility
Compatible: a run that works today still works; the only new refusal is a root run aimed at another account's data home, which today leaves that home broken.
Removes nothing: no route, key, field or command is removed or renamed.
Tests
test/test_data_home_owner.py: owned home is ok; missing entries are fine; files another uid owns are reported with the fix; an owned but unusable file is reported; the fix quotes paths; root aimed at a person's home is refused with the command to rerun; root in root's own home,serviceandstopare not; the CLI exits before it resolves the data home; doctor reports the files and joinsissues;/api/statuscarriesdata_home_access.test/test_member_memory_creation_capability.py: create refuses with 409data_home_not_ownedandfix_command, and writes nothing.MembersPage.newCrewmateOutcomes.test.tsx: the dialog shows the sentence and the server's command; editing the name or a later failure of another kind drops the command.DataHomeOwnerNotice.test.tsx: Settings notice shows only when the status reports the problem.Each key test was mutation-checked alone: allowing root in a root-owned home, skipping the create pre-check, removing the CLI exit, and removing the dialog branch each turned the matching tests red.
Proof: not provable -- other: the key backend and frontend tests were mutation-checked by hand as listed above
Manual verification
Rendered the real New Bot dialog and Settings page against stubbed
/api(Vite + Playwright, loopback only). The Settings capture harness pins English (initI18n('en')incapture/settings-agent-harness.tsx), so its Japanese frame reads English; the dialog harness follows the language setting and shows the Japanese strings.Screenshots / video
New Bot dialog, Japanese, dark:
Settings, English, dark:
New Bot dialog, English, light
Related Issues
Follow-up to #30975. Reported by a user; no issue filed.
Sibling sweep
Swept: git grep -n "geteuid() == 0" -- src/kiro_crew
Sibling: src/kiro_crew/service/linux_systemctl.py -- not affected -- runs as root on purpose for the system unit and targets SUDO_USER
Sibling: src/kiro_crew/github_runner.py -- not affected -- refuses root for its own runner, unrelated to the data home
Pattern harvest
Not generalizable: one entry point (
cli.main) creates the data home, so one guard there covers every command.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.