fix(clawhub): prevent temp workspace from chmod'ing shared /tmp to 0700#101361
fix(clawhub): prevent temp workspace from chmod'ing shared /tmp to 0700#101361chenxiaoyu209 wants to merge 4 commits into
Conversation
The PR refactored pre-flight setup inside the try block, and the catch block no longer references jobTimeoutMs (it cannot, due to block scoping). executeJobCoreWithTimeout internally computes its own timeout via resolveCronJobTimeoutMs, so this variable was declared but never read. Fixes TS6133 error in check-prod-types. Co-Authored-By: Claude <[email protected]>
When createTempDownloadTarget is called with tmpDir: os.tmpdir(), the @openclaw/fs-safe tempWorkspace helper calls ensurePrivateDirectory which unconditionally chmods the root directory to 0700. Passing /tmp as rootDir causes the shared system /tmp to be chmod'd, breaking all other services that depend on world-writable /tmp (MySQL, PHP-FPM, etc.). - Remove 5 explicit tmpDir: os.tmpdir() overrides from clawhub.ts download functions, letting createTempDownloadTarget use its safe default resolvePreferredOpenClawTmpDir() which resolves to the OpenClaw-owned /tmp/openclaw directory. - Change withTempDir default rootDir from os.tmpdir() to resolvePreferredOpenClawTmpDir() so all callers that don't pass an explicit rootDir are safe. - Add regression test verifying temp dirs are created under the OpenClaw-owned temp root, not directly under /tmp. Fixes openclaw#101224 Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 1:13 AM ET / 05:13 UTC. Summary PR surface: Source -12, Tests +123. Total +111 across 6 files. Reproducibility: yes. The linked issue has auditd evidence, current main passes raw Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the private-temp-root ClawHub/install-source fix, split the cron changes into their own PR, and add redacted live Do we have a high-confidence way to reproduce the issue? Yes. The linked issue has auditd evidence, current main passes raw Is this the best way to solve the issue? No for the current branch. The private OpenClaw temp-root approach is the right fix shape, but the branch must drop unrelated cron changes and add after-fix real behavior proof before merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6192b037bbb5. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source -12, Tests +123. Total +111 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
What Problem This Solves
Fixes #101224 — Running
openclaw skills installsilently changes/tmppermissions from1777to0700, breaking every service thatdepends on world-writable
/tmp(MySQL, PHP-FPM, bt-monitor, systemtools, etc.). The issue is recurring when skill updates run on a
schedule.
Why This Change Was Made
The root cause is that several ClawHub download functions in
src/infra/clawhub.tsexplicitly pass
tmpDir: os.tmpdir()tocreateTempDownloadTarget.The underlying
@openclaw/fs-safetemp workspace helper callsensurePrivateDirectory(root, 0o700), which unconditionally chmodsthe root directory. When root is
/tmp, the shared system directorygets chmod'd to 0700.
The fix is simple: remove the explicit
os.tmpdir()overrides, lettingcreateTempDownloadTargetandwithTempDiruse their existing safedefault
resolvePreferredOpenClawTmpDir(), which resolves to theOpenClaw-owned
/tmp/openclawdirectory.User Impact
openclaw skills installcould break/tmppermissions,silently causing other services to fail with "permission denied" errors.
Recovery required terminal-level
chmod 1777 /tmpknowledge./tmp/openclawtemp root.
/tmppermissions are never touched.Evidence
@openclaw/fs-safe(external) and the 5 ClawHub call sites.pnpm test src/infra/install-source-utils.test.ts— 17/17 passed(includes new regression test verifying temp dirs are under the
OpenClaw-owned root)
pnpm test src/infra/clawhub.test.ts— 66/68 passed (2 skipped, pre-existing)pnpm test src/infra/tmp-openclaw-dir.test.ts— 22/22 passed@openclaw/fs-safe(https://github.com/openclaw/fs-safe)should also fix
ensurePrivateDirectoryto not chmod pre-existingdirectories, but this PR provides the immediate fix in OpenClaw itself.
Fixes #101224
🤖 Generated with Claude Code