Repository navigation
fix(update): repair only this account's pnpm launcher and never keep set-ID bits - #203447
Conversation
… 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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +19, Tests +77, Docs +2. Total +98 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 22, 2026, 3:40 AM ET / 08:40 UTC. |
|
Merged via squash.
|
… 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.
… 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)
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
repairStagedRuntimeLauncher(src/infra/update-launcher-repair.ts) checks the launcher's owner uid againstprocess.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 infailedand is never renamed over.chmoded tostat.mode & 0o777, where it used0o7777before.resolveLauncherShellFileinsrc/infra/update-runtime-relocation.tsreturns the physical path only when the shim definesbasedir_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.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 base44f7c52and pass on this head:failedholds 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 cannotchownwithout root; the stub is restored after each test.0o4755after the repair. Now it is0o755.node scripts/run-vitest.mjson the launcher repair, runtime relocation,package-update-swap.launchers, native stage and Gateway startup plugin tests (50 tests). Alsopnpm tsgo:core,pnpm tsgo:core:test,pnpm check:baseline-ratchets,pnpm check:docs, oxlint and oxfmt, andgit 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
autoreviewdoes not run on this machine.