Repository navigation
fix: explain a data home another account owns, and refuse root mcp starts - #33028
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. Both changed surfaces are in the screenshots. The blind reader read the notice and the "How to give the files back" link correctly and would click the link. Notes
[UX-REVIEWED] 4d54c48 Description read[DESCRIPTION-READ] 7c19c0b9d5d7ce9c56e623a1c0ff43fc759fa60fa9ff2a8c17e95845354aa11e That sha256 names everything this verdict read: the PR description, plus the 5 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the repair command is removed rather than patched again, the slim MCP start now runs the same refusal step as Notes
[DESIGN-REVIEWED] 4d54c48 Description read[DESCRIPTION-READ] ad23eb197cc1f207ecb6c26a6fb27dc39e94aad20f664226125b6fcb871dcda4 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 (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix removes the cause on both paths: there is no privileged command to race, and the one slim entry now asks the refusal. The only open point is that the docs still give out the same Notes
What this change shipsInventory (7 items) — 5 justifiedIntent: make sure Kiro Crew can never trick its own user into a root re-own of a system file, and that root-started MCP servers stop writing into a person's data home. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 4d54c48 Description read[DESCRIPTION-READ] 7f850e348c6d48987483374ce9397d18aec4fe3655e8cd3cfa6558f77c406da3 That sha256 names the PR description this verdict read. 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: |
3b50295 to
59fa25f
Compare
|
Superseded: this disposition had a malformed marker and was re-posted in the correct format further down (head 3b50295, Opus span c6e7b1438497). |
|
Superseded: this disposition had a malformed marker and was re-posted in the correct format further down (head 3b50295, GPT span 38f5990241c0). |
59fa25f to
6d3a715
Compare
|
Superseded: this disposition had a malformed marker and was re-posted in the correct format further down (head 59fa25f, Opus span 1afafa35f8da). |
|
Superseded: this disposition had a malformed marker and was re-posted in the correct format further down (head 59fa25f, GPT span 38f5990241c0, macOS ACL finding). |
|
Superseded: this disposition had a malformed marker and was re-posted in the correct format further down (head 59fa25f, GPT span 38f5990241c0, concurrent-save finding). |
|
|
|
|
|
6d3a715 to
a4647de
Compare
|
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for this. The MCP root refusal sits at the right step, and the test that makes project detection and ensure_data_home raise pins the order well. One thing needs fixing before merge.
kiro_crew/docs/troubleshooting.md:622-664(withkiro_crew/data_home_owner.py:76). Take an entry in the data home that this account owns but cannot use, for examplemembers/at mode 0500 orconfig.jsonat 0200._usable()returns False for it,_other_owner()returns"", and the notice, doctor and the 409 all show "can't be used by this account" with a link to this section. The only repair in that section issudo find ... ! -user "$(id -un)" ... -exec chown -h. That command matches nothing here, because the files already belong to this account. Step 6 says the doctor check "should now pass", and it keeps failing. On main, the repair line ended with&& chmod -R u+rwX <home>, which fixed this case. The PR removes it, and the Before/Now table and the Reader list do not mention that. Smallest fix: add a step the person runs as their own account, without sudo, such aschmod -R u+rwX <folder>. Or give the "can't be used by this account" case its own short paragraph. This needs no root, so it does not reopen the privilege boundary this PR closes.
Optional:
- Step 5 uses full-path
-exec chown -h ... {} +. Main's-execdir chown -h ... {} \;form costs nothing and keeps the protection against a parent folder being swapped. - The PR title still says "re-own the data home through the checked file". The head commit subject describes the diff better, and the squash merge uses the title.
- The direction changed from repair to refuse-and-explain after the PR opened. A maintainer should confirm that direction on this PR before merge.
|
Maintainer note on 932915d, confirming the direction:
I agree with the one point in the open change request: the "can't be used by this account" case needs its own step without sudo, such as |
932915d to
925c8d2
Compare
|
Thanks, @KiroCrewCaptain. Answers to your review of 932915d, all in 925c8d2:
|
…arts When files in the data home belong to another account (an earlier `sudo kirocrew ...`), the gateway log, `kirocrew doctor`, /api/status, Settings and the New Bot dialog now say which folder and which account, that Kiro Crew was probably started as root once, to stop running it as root, and link the troubleshooting section that explains giving the files back by hand. Kiro Crew no longer offers a command that re-owns the files as root: every copyable version left a race in which a process writing the folder could point root at a file outside it. The gateway's own mcp-* servers start through mcp_entry.slim_server, which never asked root_run_refusal, so a root-started server still wrote into the person's home. It now asks at the same step as cli.main and hands a refusal to the full CLI.
925c8d2 to
4d54c48
Compare
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving head 4d54c48. The earlier change request is resolved. Item 1 is fixed: step 6 now runs chmod -R u+rwX <folder> without sudo, and the intro sends the "can't be used by this account" case straight to it. The optional -execdir form and the title change are also in. A maintainer confirmed the refuse-and-explain direction and the slim refusal in comment 6722570282 on this PR, which signs off the design.
What the review checked on this head: mcp_entry.slim_server calls root_run_refusal before project detection and ensure_data_home, then falls back to cli.main, which refuses at the same step. No reader of fix_command or fixCommand is left under src or website/src. All 12 locales carry the new keys. The HELP_URL anchor test matches a real heading. PR Readiness is green.
Security: the root re-own race is gone from the code. The only privileged command left is a manual docs step that the person runs themselves, after the stop step and the step 4 hard-link check. A sandboxed MCP child gets an identity uid map, so it never sees euid 0 and is never refused by mistake.
Done well: the PR removes the repair line instead of patching it a fourth time. A new test makes project detection and ensure_data_home raise, which pins the refusal ahead of every data home write.
Optional:
- Step 2 names only
kirocrewandkiro-cli. Asking the person to check for "any process of the agent backend you use" would also cover other backends before step 5. homeis now the resolved folder, not the configured path, but the body says it "stays". One line under Backwards compatibility would record this.- #33006 and #31628 still carry
fix_command. Hold them or re-cut them so they follow this change.
…arts (#33028) When files in the data home belong to another account (an earlier `sudo kirocrew ...`), the gateway log, `kirocrew doctor`, /api/status, Settings and the New Bot dialog now say which folder and which account, that Kiro Crew was probably started as root once, to stop running it as root, and link the troubleshooting section that explains giving the files back by hand. Kiro Crew no longer offers a command that re-owns the files as root: every copyable version left a race in which a process writing the folder could point root at a file outside it. The gateway's own mcp-* servers start through mcp_entry.slim_server, which never asked root_run_refusal, so a root-started server still wrote into the person's home. It now asks at the same step as cli.main and hands a refusal to the full CLI. (cherry picked from commit 8297ded)
…arts (#33028) When files in the data home belong to another account (an earlier `sudo kirocrew ...`), the gateway log, `kirocrew doctor`, /api/status, Settings and the New Bot dialog now say which folder and which account, that Kiro Crew was probably started as root once, to stop running it as root, and link the troubleshooting section that explains giving the files back by hand. Kiro Crew no longer offers a command that re-owns the files as root: every copyable version left a race in which a process writing the folder could point root at a file outside it. The gateway's own mcp-* servers start through mcp_entry.slim_server, which never asked root_run_refusal, so a root-started server still wrote into the person's home. It now asks at the same step as cli.main and hands a refusal to the full CLI. (cherry picked from commit 8297ded)
Problem / Motivation
Goal: The data home repair can no longer be tricked into giving a system file to the person's account, and a root-started Kiro Crew MCP server no longer writes into the person's data home.
Review of the 0.12 backport (#33006) found two holes in the data home ownership work on
main:sudo find ... -links 1 ... -execdir chown -hchecks the link count while it walks and changes the owner later, by name. Something that can write the data home (an agent) can swap a checked file for a hard link to/etc/sudoersin that gap, and root then re-owns the system file. Linux blocks that link by default (fs.protected_hardlinks); macOS does not.cli.mainrefuses a root run aimed at a person's data home, but the gateway's ownkirocrew mcp-*servers start throughmcp_entry.slim_server, which never asks. An ACP host run as root with the person'sHOMEstill gets root-owned files written into~/.kiro/crew.Why it matters
The repair line runs with
sudobecause we tell the person to run it, so a gap there is a privilege escalation: an agent with write access to its own data home could take ownership of a root-owned system file, and nothing changes it back. The MCP start gap leaves the exact damage #31602 exists to prevent.Not a goal
check_data_homechecks, or the root-run refusal itself.What changed (motivation → approach → change)
Kiro Crew no longer offers a repair line. Three review rounds found a new way to point the root repair at a file outside the data home each time, so the repair is removed and the person is told what is wrong instead.
kirocrew doctorsudo ...line to run/api/statusdata_home_access, 409data_home_not_ownedfix_commandownerandhelp_url(homeandforeignstay)mcp_entry.slim_servernever askedroot_run_refusalcli.main; a refusal hands over to the full CLI, which prints itThe docs link goes to a new "Kiro Crew files belong to another account" section in
src/kiro_crew/docs/troubleshooting.md. It explains the cause and, as the person's own step with Kiro Crew and every agent stopped, on the folder the notice names: first check thatsudo find -P <folder> -xdev -type f -links +1prints nothing (it only lists, and runs as root so it can see into folders the root run left unreadable) (a hard link planted earlier survives the stop), then run a filteredsudo find -P ... -xdev ! -user ... \( -type d -o -links 1 \) -execdir chown -h ... {} \;, thenchmod -R u+rwX <folder>as their own account withoutsudo. Thechmodstep replaces the&& chmod -R u+rwX <home>tail of the removed repair line, and on its own fixes the "can't be used by this account" case (files already theirs, only permissions wrong). The strings are translated in all 12 locales.docs/system-specs/modules/cli.mdandcrew-mode.mddescribe the new behaviour.Backwards compatibility
Compatible: the refusal, the checked entries and the 409 code are unchanged; only the help that comes with them changes, and no release has shipped
fix_commandyet.Reader: src/kiro_crew/doctor_checks/install.py:_doctor_data_home_owner -- release -- prints owner and docs link; test_doctor_reports_the_files_owner_and_docs
Reader: src/kiro_crew/data_home_owner.py:warn_if_data_home_not_owned -- release -- logs
explain(); test_the_gateway_warning_is_the_explanationReader: src/kiro_crew/dashboard/agent_admin/crew_records.py:_api_kirocrew_agents_create (409 body) -- crew page -- sends home, owner, help_url; test_creation_refuses_a_data_home_another_account_owns
Reader: website/src/components/DataHomeOwnerNotice.tsx:DataHomeOwnerStatusNotice -- crew page -- reads owner and help_url; DataHomeOwnerNotice.test.tsx
Reader: website/src/pages/members/NewCrewmateDialog.tsx:409 branch -- crew page -- reads home, owner, help_url; MembersPage.newCrewmateOutcomes.test.tsx
Tests
Proof: not provable -- other: the fix removes the repair line instead of changing it, so there is no production hunk whose revert a changed test would catch
test_data_home_owner.py: the explanation names folder, owner, cause and docs and holds nochownorsudo; the docs anchor exists introubleshooting.md; the owner is reported; the race tests for the removed script are gone; the refusal tests stay.test_mcp_slim_entry.py: a refused root run returns before project detection orensure_data_home; the slim/CLI parity test spies the refusal step on both paths.DataHomeOwnerNotice.test.tsxandMembersPage.newCrewmateOutcomes.test.tsxpin the folder/owner sentence, the docs link and that no command is shown.Ran: the related backend files plus the flake-pattern ratchet gave 471 passed (the 13 subprocess tests in
test_mcp_slim_entry.pyneedyaml, missing on this host). Frontend:tsc,i18n:checkand 79 vitest files (1271 tests, the i18n suite included) passed.Manual verification
Ran an isolated gateway from this worktree on a throwaway data home whose
members/this account cannot write, and looked at Settings and the New Bot dialog in a headless browser. Both show the notice below.Screenshots / video
Settings, above every tab:
New Bot dialog after Create is refused:
Related Issues
Raised in review of #33006 (the 0.12 backport of #31602 and #32944).
Sibling sweep
Swept: git grep -n "root_run_refusal|ensure_data_home()" -- src/kiro_crew/mcp_entry.py src/kiro_crew/_bootstrap.py src/kiro_crew/cli.py
Sibling: src/kiro_crew/mcp_entry.py:136 -- changed here
Sibling: src/kiro_crew/cli.py:648 -- not affected -- the full CLI already refuses before project detection
Pattern harvest
Rule candidate: review-prompt
Pattern: a copyable privileged command that changes files inside a folder a less-privileged process can write; prefer explaining the problem and leaving the privileged step to the person
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.