Skip to content

fix(update): repair only this account's pnpm launcher and never keep set-ID bits - #203447

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/update-launcher-repair-ownership
Nov 22, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/update-launcher-repair-ownership

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: the automatic pnpm launcher repair that Doctor and Gateway startup run (from #201735) could replace a launcher another account owns and carry its set-ID bits into the replacement. It could also relocate a lexical shim from a different directory than the one it was detected from.

These are hardening gaps that ClawSweeper review found on the backports (#203401, #201740). The same code is on main.

User Impact

User impact: the repair now rewrites only a launcher owned by the account running it, and the rewritten launcher keeps permission bits only. Another account's launcher is left unchanged. Doctor and Gateway startup report it through the existing failed-repair message, which names the owner and current uids and the pnpm add -g --allow-build=openclaw openclaw@<installed-version> reinstall to run as the owning account. A pnpm 10-style shim in a symlinked bin directory is now repaired correctly instead of failing with "still names the removed update stage". The update guide now lists 2026.11.6 among the updaters that miss these steps.

Why This Change Was Made

  • Ownership: repairStagedRuntimeLauncher (src/infra/update-launcher-repair.ts) checks the launcher's owner uid against process.getuid() after it has proven the launcher is this installation's staged one, and before it writes anything. A mismatch throws a recorded reason, so the launcher lands in failed and is never renamed over.
  • Set-ID bits: the replacement is chmoded to stat.mode & 0o777, where it used 0o7777 before.
  • One base resolution: resolveLauncherShellFile in src/infra/update-runtime-relocation.ts returns the physical path only when the shim defines basedir_abs, and the path as reached otherwise. Detection (resolveRuntimeLauncherTargets) and the repair's relocation both use it. Before, detection used that rule but the repair always relocated from the physical directory.
  • Scope: no new stored field, config or schema. The repair's outcomes and callers are unchanged.

Update behavior: the repair runs from the new package (Doctor during an update, and Gateway startup), so this applies whenever a release with it is the package being installed. Shipped updaters are unchanged.

Evidence

Run on src/infra/update-launcher-repair.test.ts; all three new tests failed on base 44f7c52 and pass on this head:

  • "leaves another account's launcher unchanged and reports why". On base the launcher was repaired and replaced. Now failed holds the uid reason, the bytes are unchanged and no staging is left. This process's uid is stubbed to differ from the file's owner, because a test cannot chown without root; the stub is restored after each test.
  • "never carries set-ID bits into the repaired launcher". On base the mode was 0o4755 after the repair. Now it is 0o755.
  • "relocates a lexical shim from the bin path its shell and detection use". The bin directory is a symlink into a deeper directory. On base the repair failed with "The repaired launcher still names the removed update stage". Now the shim's target resolves lexically to the live entry. Node resolves its entry argument lexically.
  • Regression coverage: the existing repair cases still pass, including every quoting form, pnpm 11 grouped, a FIFO on PATH, and the four "cannot prove it is ours" refusals.
  • Commands: node scripts/run-vitest.mjs on the launcher repair, runtime relocation, package-update-swap.launchers, native stage and Gateway startup plugin tests (50 tests). Also pnpm tsgo:core, pnpm tsgo:core:test, pnpm check:baseline-ratchets, pnpm check:docs, oxlint and oxfmt, and git diff --check.

No real cell was run for this change. A foreign-owned launcher needs a second account and a root-run repair, and the shipped behavior is covered by the unit cases against real files and a real shell shim.

Not proven

  • A root-run Doctor against another account's launcher on a real host.
  • Windows; the repair is macOS and Linux only.
  • autoreview does not run on this machine.

… bits, from the shim's own base

- Launcher repair leaves a launcher owned by another account unchanged and
  reports why (uid of the owner and of this account) through the existing
  failed-repair message, instead of replacing it with this account's file.
- The replacement keeps permission bits only; setuid, setgid and sticky
  bits are never carried into a rewritten launcher.
- Detection and relocation share one answer for the base a shim's
  `$basedir` resolves from (physical only when the shim defines
  `basedir_abs`), so a symlinked bin directory cannot make them disagree.
- The update guide lists 2026.11.6 among the updaters that miss these
  steps and states the ownership rule.
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Nov 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR restricts pnpm launcher repair to the current account, removes special permission bits, and aligns relocation with the shim’s directory resolution.

Example: An account repairs its own staged pnpm launcher with mode 04755.

  • Before: The replacement retains mode 04755.
  • After: The replacement has mode 0755.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no identified correctness defect, but the required product-entry-point proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Automatic repair can replace another account’s launcher, preserve special permission bits, or fail to repair a lexical shim reached through a symlinked bin directory.
Reason: The maintainer-authored direction addresses verified source failures with a focused change and no new configuration or competing repair path.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses concrete gaps still present on main, and no introduced correctness defect was found.

Priority: P2
Reviewed head: 04b7ad6b49caaf7beab6cefee3cccf9c49eb32f4

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted Doctor or Gateway evidence covering a real foreign-owned launcher, removal of special bits, and execution of the repaired lexical shim, plus fresh-install and latest-stable upgrade results with existing settings and data intact; redact IPs, keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

Doctor and Gateway startup scan published pnpm launchers, identify references to a removed update stage, and either replace the verified launcher or report why repair failed.

flowchart TD
 A[Doctor or Gateway startup] --> B[Find pnpm launchers]
 B --> C[Verify installation and removed stage]
 C --> D[Check account ownership]
 D --> E[Resolve shim base and relocate]
 E --> F[Verify targets and strip special bits]
 F --> G[Replace launcher]
 D --> H[Report foreign owner]
Loading

Technical review

Best possible solution:

Keep the existing repair owner, check launcher ownership before writing, strip special permission bits, and share the shim-base resolver.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes all three paths, and the PR supplies focused before/after regression results; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch is the smallest complete repair using existing owners: one ownership check, a narrower permission mask, and one resolver reused by detection and relocation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d4866585915c.

Provenance checked

  • Launcher ownership and permission preservation changes intended behavior with a stated reason (dbc1aa0: The earlier repair restored broken published shims through a private temporary file and preserved their mode; this PR explains why foreign ownership and special bits require narrower handling.)
  • Lexical and physical shim bases keeps the original intent (dbc1aa0: Detection distinguished lexical shims from shims defining basedir_abs, while repair always used the physical directory; the earlier PR explicitly recorded that mismatch as unfinished work.)
  • Published-updater documentation keeps the original intent (dbc1aa0: The guide distinguishes installed-updater behavior from repairs supplied by the new package; the added release and ownership qualification retain that distinction.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit dbc1aa0 adds src/infra/update-launcher-repair.ts:105 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dbc1aa04e88f; files: src/infra/update-launcher-repair.ts)
  • Peter Steinberger: Raw commit d1a69c0 adds src/infra/update-runtime-relocation.ts:48 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d1a69c0b2095; files: src/infra/update-runtime-relocation.ts)

PR surface

Source +19, Tests +77, Docs +2. Total +98 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 26 7 +19
Tests 1 78 1 +77
Docs 1 5 3 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 109 11 +98

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair addresses account ownership, special file permissions, and a symlinked-bin failure with limited affected configurations and no demonstrated widespread outage from these specific gaps.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide the changed-behavior and upgrade evidence described in the proof assessment.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 22, 2026, 3:40 AM ET / 08:40 UTC.

@fuller-stack-dev
fuller-stack-dev merged commit 7a570c4 into openclaw:main Nov 22, 2026
137 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/update-launcher-repair-ownership branch November 22, 2026 09:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 23, 2026
… bits, from the shim's own base (openclaw#203447)

- Launcher repair leaves a launcher owned by another account unchanged and
  reports why (uid of the owner and of this account) through the existing
  failed-repair message, instead of replacing it with this account's file.
- The replacement keeps permission bits only; setuid, setgid and sticky
  bits are never carried into a rewritten launcher.
- Detection and relocation share one answer for the base a shim's
  `$basedir` resolves from (physical only when the shim defines
  `basedir_abs`), so a symlinked bin directory cannot make them disagree.
- The update guide lists 2026.11.6 among the updaters that miss these
  steps and states the ownership rule.
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
… bits, from the shim's own base (#203447)

- Launcher repair leaves a launcher owned by another account unchanged and
  reports why (uid of the owner and of this account) through the existing
  failed-repair message, instead of replacing it with this account's file.
- The replacement keeps permission bits only; setuid, setgid and sticky
  bits are never carried into a rewritten launcher.
- Detection and relocation share one answer for the base a shim's
  `$basedir` resolves from (physical only when the shim defines
  `basedir_abs`), so a symlinked bin directory cannot make them disagree.
- The update guide lists 2026.11.6 among the updaters that miss these
  steps and states the ownership rule.

(cherry picked from commit 7a570c4)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 68ac9c751d6087558291bebf53c9f9c6a3e333aa)
(cherry picked from commit 81eae68e7d4961bfdb3b134cab74b3d93d41a179)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant