Skip to content

feat(desktop): fix data-home permissions with one click - #31628

Closed
buluoray wants to merge 2 commits into
mainfrom
crew/slack/data-home-fix-button
Closed

buluoray wants to merge 2 commits into
mainfrom
crew/slack/data-home-fix-button

Conversation

@buluoray

@buluoray buluoray commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the desktop app, a person whose data home belongs to another account can repair it with one click and their own admin password, without a terminal.

The data-home notice (#31602) names the cause and gives sudo chown -R ... to paste into a terminal. Many people who hit this have never opened one.

Why it matters

The person stays locked out of creating a Bot until the folder is theirs again, and a command to paste is a dead end for anyone without a terminal habit.

Not a goal

What changed (motivation → approach → change)

Part What it does
Button "Fix permissions" on the data-home notice in Settings and in the New Bot dialog, shown only when the shell says the repair can run here. A fixed repair re-reads the status, so the notice goes away. A failed one says so and keeps the command. A dismissed prompt changes nothing.
Bridge window.dataHomeFixAPI.available() / fix(). Neither takes an argument.
Main process data-home:can-fix and data-home:fix, both behind the existing three-check local-dashboard gate.
Repair Resolves the data home itself; refuses a link, a non-directory or a filesystem root; asks the OS to run only chown -R -P <this uid> <real path> with admin rights (macOS osascript ... with administrator privileges, Linux pkexec, each at a fixed path); then chmod -R u+rwX as the person, with no privilege.

The OS draws the password prompt, so the password never reaches the app. -P keeps the walk from following any link inside the folder. The target is never widened past the data home, and never taken from the page.

builder-security checked: no new listener, route or bind. The privileged step is one fixed argv on one path the main process resolves, behind the gate every machine-local action uses; a connection window on a remote gateway is refused before anything runs.

Specs updated: docs/build/desktop-app.md (the bridge and the repair) and crew-mode.md (New Bot dialog).

Backwards compatibility

Compatible: a new optional bridge and two new channels; nothing existing changes shape.

Removes nothing: no channel, bridge, key or command is removed.

Tests

  • website/electron/test/data-home-fix.test.js: routes exist only where the prompt and chown exist; the target must be a real directory, not a link or a root; pkexec runs only chown -R -P <uid> <home>; osascript quotes the path for both the shell and AppleScript; root or an unknown uid is never the target account; a fix chowns then chmods as the person; a dismissed prompt is cancelled and runs nothing else; nothing runs without a route, as root, or on a linked home.
  • website/electron/test/ipc-registrar.test.js: both channels refuse every non-local sender and never reach the repair; on the local dashboard fix ignores any renderer argument; can-fix is false with no prompt; the pinned channel set gains the two names.
  • DataHomeOwnerNotice.test.tsx: no button without the bridge or when the shell says no; a fixed repair re-reads the status and hides the notice; cancelled and failed keep the command, and only failed says so.
  • electronBridgeContract.test.ts: the new bridge is declared.

Mutation-checked one at a time: dropping -P, accepting a linked data home, removing the gate from data-home:fix, and showing the button when the shell says no each turned the matching tests red.

Manual verification

Rendered the New Bot dialog and Settings against stubbed /api and a stubbed bridge (Vite + Playwright, loopback only). The real OS prompt was not exercised: there is no macOS host here, and pkexec needs a desktop session.

Screenshots / video

New Bot dialog with the button, English, light:

dialog en light

Japanese, dark:

dialog ja dark

Settings (the capture harness pins English)

settings en dark

Related Issues

Builds on #31602 (merge that first; this branch carries its commit until then).

Held as a draft until #32127 lands: the privileged repair still re-resolves paths as root, so a same-account process can swap a parent folder for a symlink mid-run. #32127 tracks a race-safe helper.

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 18:07
@buluoray
buluoray requested a review from Zedmor November 6, 2026 18:07
@buluoray
buluoray enabled auto-merge (squash) November 6, 2026 18:07
@buluoray
buluoray force-pushed the crew/slack/data-home-fix-button branch 2 times, most recently from d7d2435 to 4befe4a Compare November 6, 2026 18:29
@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-fix-button branch from 4befe4a to b1fcd66 Compare November 6, 2026 18:47
@buluoray

buluoray commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 2) red on b1fcd66 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

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The repair runs as one fixed privileged command on a path the main process resolves itself, behind the local-dashboard check. If it fails or is cancelled, the user falls back to the command they copy today.

Notes

  • The description doesn't match the code. It says the repair runs "only chown -R -P <this uid> <real path>" and that the bridge calls take no argument. data-home-fix.js:elevatedCommand actually runs find … -xdev ! -user <uid> ( -type d -o -links 1 ) -exec chown -h, and available/fix both pass gatewayHome. The comment above dataHomeFixAPI in preload.js repeats the wrong "Neither takes an argument" claim. Update the "What changed" table, the -P mutation-test claim and the preload comment to describe what actually runs.
  • gatewayHome comes from the page. It only gates the repair; the target is always resolveHome(). That is sound, but the docs should say so.
  • The real osascript and pkexec prompts were never run on a host. Before release, someone should try one cancel and one success on macOS, to confirm the -128 cancel detection and the follow-up chmod as the user.

[DESIGN-REVIEWED] 26fd0d4

Description read

[DESCRIPTION-READ] 16187d527a693859ce8f74987a6c4d7e907cefdd0deaeea5d5de7657fe8f693e

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 26fd0d4538683c493673f0052509fae4129cc089 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the fixing, fixed and failed states of "Fix permissions". The screenshots also come from an older build: they show "Run this command…" where HEAD renders "Or run this command… instead".

Evidence gaps

  • "Fixing…" state. The button disables and its label changes while the OS asks for the password. No screenshot shows it. Close with a capture taken while the prompt is open.
  • Fixed state. It shows "Fixed. Restart {{productName}}, then try again." in text-ok. No screenshot shows it. The PR says the notice "goes away", but the code comment says "the notice stays and says so". A capture would settle which one ships.
  • Failed state. It shows "Couldn't fix the files. Run the command below in a terminal instead." and the line above the command drops its "Or". No screenshot shows it. Close with one capture.
  • Copy that differs from HEAD.
    • When the button shows, HEAD renders or_run_this ("Or run this command in a terminal on this computer instead, then try again."). shots 01–03 all show run_this.
    • In Settings, HEAD also renders "Until this is fixed, {{productName}} can't create a new Bot.". shot-03 doesn't show it.
    • The blind reader's main confusion was the button versus the command: "whether the button is enough or whether I need to do both". That is exactly what the newer copy is meant to fix, but nobody has seen it rendered. Recapture shots 01 and 03 from this HEAD.

Notes

  • fixed: "Restart {{productName}}" doesn't say what to restart, and the dialog offers nothing to click. Either add a restart button next to the message, or say "Quit and reopen {{productName}}".
  • message: the reader asked, "I don't know who 'another user' is on my own computer." Name the cause in plain words, for example "Some {{productName}} files were created by an admin (sudo) command, so {{productName}} can't read them."

[UX-REVIEWED] 26fd0d4

Description read

[DESCRIPTION-READ] eb4dc00746ebd6950f707b3884a599bc81866f33e1d0334aef5c5d35247da21a

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

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 26fd0d4538683c493673f0052509fae4129cc089 — 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

The repair button removes a named harm (no terminal, so no way out) and nothing already does the job. But ## What changed no longer describes what the diff does.

Notes

  • Item 3 — undeclared: the description says "Neither takes an argument" and "runs only chown -R -P <this uid> <real path>". The diff has fix: (gatewayHome) => ipcRenderer.invoke("data-home:fix", gatewayHome) and runs route.find, target, "-xdev", "!", "-user", id, ... "-exec", route.chown, "-h". Reviewers are reading the security claim against a command that isn't the one shipped. Subtraction: delete the stale -R -P and "no argument" sentences from ## What changed, and the "Neither takes an argument" comment in preload.js.
  • Item 4 — undeclared: the description says "A fixed repair re-reads the status, so the notice goes away". The diff says "A fixed home still needs a restart … the notice stays and says so". Subtraction: delete the "notice goes away" claim.

What this change ships

Inventory (6 items) — 4 justified

Intent: a desktop user locked out of their data home can take it back with one click and their admin password. ADDITION.

  1. A "Fix permissions" button on the data-home notice in Settings and the New Bot dialog, desktop local dashboard only — justified
  2. The OS admin prompt (osascript / pkexec) runs a privileged ownership repair limited to the data home — justified
  3. The repair is offered only when the gateway's data home is the same one the shell resolves — undeclared
  4. After a fix, the notice stays up and asks for a restart — undeclared
  5. Two new IPC channels and the dataHomeFixAPI bridge, behind the local-dashboard gate — justified
  6. The fix: refuse root runs on a person's data home and name the repair #31602 detection, the notice and the doctor check come along in this patch — justified

[FIRST-PRINCIPLES-REVIEWED] 26fd0d4

Description read

[DESCRIPTION-READ] 0019968460807b2b2766e826ad6c1ee6d57b1ab6fb775265e3281e9fc3cc114b

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

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 26fd0d4

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 26fd0d4538683c493673f0052509fae4129cc089 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 — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 26fd0d4538683c493673f0052509fae4129cc089. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- website/electron/data-home-fix.js:162 -- Privileged repair re-resolves a replaceable pathname

const elevated = await run(execFile, file, args);
Trigger: With data home /home/alice/repair/etc, click Fix permissions on the local dashboard. During the admin prompt, a same-account process renames the writable repair parent and replaces it with a symlink to /. data-home:fix → fixDataHome → elevatedCommand launches privileged find on the previously validated pathname.
Outcome: Root traverses /etc and transfers its directories and eligible files to the caller. The local-dashboard gate, initial realpath check, -xdev, and chown -h do not prevent following a replaced pathname ancestor, so system files outside the data home become caller-controlled.
Anchor: residual/security
Fix: Use a privileged helper that pins the validated directory identity and performs descriptor-relative, no-follow traversal and ownership changes; use it for the terminal repair too.
Sites: Both elevation routes share website/electron/data-home-fix.js:110; src/kiro_crew/data_home_owner.py:82 generates the same pathname-based terminal repair, exposed by src/kiro_crew/doctor_checks/install.py:46, src/kiro_crew/dashboard/handlers_system.py:263, src/kiro_crew/dashboard/agent_admin/crew_records.py:620, and src/kiro_crew/slack/gateway_runtime/service_boot.py:1079.

[BLOCK-MERGE] 26fd0d4
[GPT-REVIEWED] 26fd0d4

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 (fenced): the harm is unbounded (privilege escalation). I checked the conditions in the code:

  • repairTarget resolves the path once, before the admin prompt (website/electron/data-home-fix.js:68).
  • elevatedCommand then hands find a plain path string (website/electron/data-home-fix.js:114), and root runs it after the prompt (website/electron/data-home-fix.js:162). Nothing pins the directory, so a parent folder swapped in between is followed.
  • No recovery path: a mis-chowned system tree is not restored.

The attack needs a same-account process to race the prompt, and the home's leaf name must match a root-owned directory. A same-account attacker can arrange both by setting KIROCREW_HOME. Kiro Crew's own agent is such a process. I can't call that so extreme that a human should accept the risk, so I am not flagging it.

[ADJUDICATION] 26fd0d4538683c493673f0052509fae4129cc089 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] 26fd0d4538683c493673f0052509fae4129cc089

[ADJUDICATION-FENCED] 26fd0d4538683c493673f0052509fae4129cc089 fenced=1 flagged=0
UPHOLD-FENCED F1 website/electron/data-home-fix.js:162 -- The privileged find re-resolves a path checked once before the admin prompt (data-home-fix.js:68 vs :114), so a same-account process (KIROCREW_HOME is under its control) can swap a parent folder during the prompt and get root to chown system files to the user; the conditions are plausible, not extreme.
[GPT-ADJUDICATED-FENCED] 26fd0d4538683c493673f0052509fae4129cc089

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

@buluoray
buluoray force-pushed the crew/slack/data-home-fix-button branch 2 times, most recently from 7fc70c6 to 8f010d0 Compare November 6, 2026 20:18
@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-fix-button branch from 8f010d0 to 450769b Compare November 6, 2026 21:50
@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-fix-button branch 3 times, most recently from 53da790 to 8937de9 Compare November 7, 2026 01:53
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 7, 2026
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.
The data-home notice gives a command to paste into a terminal, and
many people have none. On the desktop app's local dashboard the notice
now carries a "Fix permissions" button: the OS asks for the admin
password (macOS through osascript, Linux through pkexec) and the data
home is given back to this account.

The main process resolves the data home itself and takes no argument
from the page. It refuses a data home that is a link, not a directory
or a filesystem root, runs only `chown -R -P <this uid> <real path>`
with privilege, and restores owner modes as the person. The password
never reaches the app. A plain browser, the PWA and a window on a
remote gateway keep showing the command.
@buluoray
buluoray force-pushed the crew/slack/data-home-fix-button branch from 8937de9 to 26fd0d4 Compare November 7, 2026 04:44
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 7, 2026
@buluoray
buluoray marked this pull request as draft November 7, 2026 05:36
auto-merge was automatically disabled November 7, 2026 05:36

Pull request was converted to draft

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

Closing. The one-click root repair would need a pinned, no-follow walk to be safe: GPT's finding on 26fd0d4 (a same-account process can swap a parent folder during the admin prompt and point root's chown at system files) is real. The data-home notice already shipped in #31602, and main gives no command to copy: the troubleshooting page has the person stop Kiro Crew and every agent, check for extra hard links, then run find -P <folder> -xdev ... -execdir chown -h, so no separate hardening PR is needed. Reopen if we want a one-click repair built on a pinned helper.

@buluoray buluoray closed this Nov 14, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant