Skip to content

fix: refuse root runs on a person's data home and name the repair - #31602

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/data-home-owner
Nov 7, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/data-home-owner

Conversation

@buluoray

@buluoray buluoray commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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 earlier sudo kirocrew ... (sudo on macOS keeps HOME). 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

  • Changing which files root may write when it works in root's own home.
  • Changing kirocrew service or kirocrew stop, which are documented to run under sudo.
  • A one-click repair button (a separate desktop-app change).
  • Windows: ownership by uid does not apply there.

What changed (motivation → approach → change)

Part What it does
Refusal kirocrew exits 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.
Detection check_data_home finds which of the data home, config.json, members/ and memory_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>.
Where it shows gateway log at start; kirocrew doctor (Data Home, counted as an issue); /api/status as data_home_access; POST /api/agents refuses with 409 data_home_not_owned and fix_command before it writes anything.
UI The New Bot dialog shows "Some Kiro Crew files belong to another user, so Kiro Crew can't read them." with the command to copy. Settings shows the same notice on every tab while /api/status reports it. All 12 languages.

Root working in root's own home is left alone, and so are service and stop, which the docs tell people to run with sudo.

builder-security checked: no new route, listener or bind. POST /api/agents stays owner-gated and only gains an early refusal; /api/status stays 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") and crew-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, service and stop are not; the CLI exits before it resolves the data home; doctor reports the files and joins issues; /api/status carries data_home_access.
  • test/test_member_memory_creation_capability.py: create refuses with 409 data_home_not_owned and fix_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.
  • Doctor report and facade pins updated for the new row.

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') in capture/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:

dialog ja dark

Settings, English, dark:

settings en dark

New Bot dialog, English, light

dialog en 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

  • 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.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 6, 2026 17:48
@buluoray
buluoray requested a review from Zedmor November 6, 2026 17:48
@buluoray
buluoray enabled auto-merge (squash) November 6, 2026 17:48
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@buluoray
buluoray force-pushed the crew/slack/data-home-owner branch 2 times, most recently from 3c68968 to 9af42cc Compare November 6, 2026 18:46
@buluoray

buluoray commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 2) red on 9af42cc is test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget. It fails the same way on clean main (tracked in #31648, fix in #31625). This PR touches nothing under src/kiro_crew/security/. I'll rebase onto main once #31625 merges.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a426f7ff4121cd4aaedf819bb4ba6bb699d7278f — 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 refusal in cli.main stops root runs from writing into a person's data home, and the other items show the same check where people will see it.

Notes

  • Item 8 — oversized: DataHomeOwnerStatusNotice's isError branch adds a "Couldn't check who owns the Kiro Crew files." banner to every Settings tab whenever /api/status fails. The Goal only asks to name files another account owns, so this banner is extra. Subtraction: delete the isError branch and render nothing when the read fails. The 409 from the create route still names the cause. Clears when: the mechanism is removed, or a human amends the Goal.

What this change ships

Inventory (9 items) — 7 justified

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

  1. A root kirocrew run aimed at another account's data home exits and prints the same command without sudo — justified
  2. service and stop still run under sudo, as the docs say — justified
  3. Project-dir detection now runs after argument parsing — undeclared; needed so the refusal comes before the home is created
  4. The gateway logs the foreign files and the repair line once, after ready — justified
  5. kirocrew doctor shows a Data Home owner row and counts it as an issue — justified
  6. /api/status carries data_home_access — justified
  7. A Bot create on such a home gets 409 data_home_not_owned with fix_command and writes nothing — justified
  8. Settings shows the owner notice on every tab, plus a "couldn't check" banner when the status read fails — oversized: the failed-read banner goes beyond the Goal
  9. The New Bot dialog shows the cause sentence and a copyable repair command — justified

[FIRST-PRINCIPLES-REVIEWED] a426f7f

Description read

[DESCRIPTION-READ] d5e258cfb1f395874fcf7440ce524a2ba0b3269de5f0ea49c38cdc4d5d2d02ef

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the root refusal skips service/stop, the system unit runs the gateway under the invoking person's account (User=), and the Docker image runs as uid 1000. The UI has three rendered screenshots.

Notes

  • The description gives the repair line as sudo chown -R <user> <home> && chmod -R u+rwX <home>, but fix_command sends sudo find … -xdev ! -user … \( -type d -o -links 1 \) -exec chown -h …. The description should quote what users will actually be told to paste.
  • Only config.json, members/ and memory_stores/ are checked. If root left files elsewhere in the home (for example under memory/ or the sessions folder), they stay unreported until something fails on them. The fix itself is recursive, so the narrow check only affects detection, and widening it later is easy to reverse.

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

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

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

  • DataHomeOwnerStatusNotice's isError branch (components.dataHomeOwnerNotice.check_failed) renders above every Settings tab whenever /api/status fails. None of shot-01 to shot-03 shows it. A screenshot of Settings with /api/status stubbed to fail would close the gap. Fix it before you capture it: the line has no next step, and it warns about file ownership to a user who never had an ownership problem. Either drop the branch or say what the user can do.

Notes

  • The blind reader would not run the repair: "I don't know what a terminal is… pasting a command I can't read that seems to change who owns my files feels risky." Extend run_this to say what the command does, e.g. "This gives these files back to your account. Run it in Terminal, then create the Bot again." That also answers the reader's "Try again: try what again?"
  • The reader asked who the "other user" is. Name it in message if the server knows it, e.g. "belong to root".

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] a426f7f

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

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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a426f7f

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

@buluoray
buluoray force-pushed the crew/slack/data-home-owner branch 2 times, most recently from 5feae7b to 1159416 Compare November 6, 2026 20:19
@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 6, 2026
@buluoray
buluoray force-pushed the crew/slack/data-home-owner branch from 1159416 to 30d1602 Compare November 6, 2026 21:48
@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 Nov 6, 2026
@buluoray
buluoray force-pushed the crew/slack/data-home-owner branch 2 times, most recently from 7ddf844 to b579bb9 Compare November 7, 2026 01:53
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.
@buluoray
buluoray force-pushed the crew/slack/data-home-owner branch from b579bb9 to a426f7f Compare November 7, 2026 04:44
@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 readiness: checking Automated validation is still running labels Nov 7, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 7, 2026
@buluoray
buluoray merged commit 64beae3 into main Nov 7, 2026
98 of 101 checks passed
@buluoray
buluoray deleted the crew/slack/data-home-owner branch November 7, 2026 06:03
buluoray added a commit that referenced this pull request Nov 8, 2026
…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.
buluoray added a commit that referenced this pull request Nov 8, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants