Repository navigation
config(io): add OPENCLAW_SKIP_STATE_DIR_HARDEN opt-out for multi-uid sidecar deployments (AI-assisted) - #71205
chrislangston wants to merge 2 commits into
Conversation
Greptile SummaryThis PR adds a Confidence Score: 5/5Safe to merge; the change is strictly opt-in and leaves the default hardening path untouched. All findings are P2 style suggestions (missing logAcceptedEnvOption call for observability). The logic is correct, the test is solid, and no existing behavior is altered when the env var is unset. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/config/io.ts
Line: 209-211
Comment:
Other `OPENCLAW_*` env-var opt-outs call `logAcceptedEnvOption` (from `src/infra/env.ts`) so operators can confirm via logs that the env var was read and honoured. Without this call, a misconfigured container (e.g. env var misspelled or not injected) will silently fall back to the hardening path with no observable signal, making it harder to diagnose the original `EACCES` cascade.
```suggestion
if (isTruthyEnvValue(params.env.OPENCLAW_SKIP_STATE_DIR_HARDEN)) {
logAcceptedEnvOption({
key: "OPENCLAW_SKIP_STATE_DIR_HARDEN",
description: "skipping state-dir chmod hardening for multi-uid shared-volume deployment",
});
return;
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "config(io): add OPENCLAW_SKIP_STATE_DIR_..." | Re-trigger Greptile |
| if (isTruthyEnvValue(params.env.OPENCLAW_SKIP_STATE_DIR_HARDEN)) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Other
OPENCLAW_* env-var opt-outs call logAcceptedEnvOption (from src/infra/env.ts) so operators can confirm via logs that the env var was read and honoured. Without this call, a misconfigured container (e.g. env var misspelled or not injected) will silently fall back to the hardening path with no observable signal, making it harder to diagnose the original EACCES cascade.
| if (isTruthyEnvValue(params.env.OPENCLAW_SKIP_STATE_DIR_HARDEN)) { | |
| return; | |
| } | |
| if (isTruthyEnvValue(params.env.OPENCLAW_SKIP_STATE_DIR_HARDEN)) { | |
| logAcceptedEnvOption({ | |
| key: "OPENCLAW_SKIP_STATE_DIR_HARDEN", | |
| description: "skipping state-dir chmod hardening for multi-uid shared-volume deployment", | |
| }); | |
| return; | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/io.ts
Line: 209-211
Comment:
Other `OPENCLAW_*` env-var opt-outs call `logAcceptedEnvOption` (from `src/infra/env.ts`) so operators can confirm via logs that the env var was read and honoured. Without this call, a misconfigured container (e.g. env var misspelled or not injected) will silently fall back to the hardening path with no observable signal, making it harder to diagnose the original `EACCES` cascade.
```suggestion
if (isTruthyEnvValue(params.env.OPENCLAW_SKIP_STATE_DIR_HARDEN)) {
logAcceptedEnvOption({
key: "OPENCLAW_SKIP_STATE_DIR_HARDEN",
description: "skipping state-dir chmod hardening for multi-uid shared-volume deployment",
});
return;
}
```
How can I resolve this? If you propose a fix, please make it concise.|
Addressed in d500b555e — added |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open, but this PR is not merge-ready: the proposed opt-out only bypasses one helper, while current main still hardens the config directory through the atomic writer with Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes for the patch defect: source inspection shows that after this new guard would return, Is this the best way to solve the issue? No. The env guard is a plausible direction, but this implementation is too narrow for current main; the best fix must cover the atomic writer boundary or use a broader maintainer-approved state permission policy. Security review: Security review needs attention: The diff changes a local state-directory permission hardening boundary, and the opt-out is incomplete against current main's atomic write path.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 8ed6c78b7891. |
c153b83 to
bd4e8a9
Compare
…sidecar deployments
bd4e8a9 to
6efe2ef
Compare
|
FYI: a third codepath with the same unconditional chmod-on-state-dir |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
tightenStateDirPermissionsIfNeededinsrc/config/io.tsunconditionally callschmod(configDir, 0o700)on every config save when the config dir matches the state dir. Multi-uid shared-volume deployments (e.g. Fly Machines running a bridge + gateway sidecar pair under different uids on a group-writable setgid state dir) get their sibling-uid access stripped — the dir mode drops from2770 owner:shared-groupto0700 owner:none-for-group, and the sibling process (bridge, uid 1001) can no longer traverse the state dir to read/write the files it needs (bridge-readysentinel, etc.). That cascades into a workspace-bootstrap retry storm; each retry triggers another config save, which re-hardens and re-locks the sibling out.configDir !== stateDir— both of which are fragile.OPENCLAW_SKIP_STATE_DIR_HARDEN=1). When set,tightenStateDirPermissionsIfNeededreturns early before stat/chmod. Everything else (the win32 skip, theconfigDir !== stateDirskip, the0o077-already-zero skip) is untouched. Default behavior is preserved — this is strictly opt-in."tightens world-writable state dir…"test still passes unchanged, which is the regression guard for the default path.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
No existing issue — surfaced while debugging a downstream multi-uid sidecar deployment. Happy to open a tracking issue first if maintainers prefer.
Root Cause
tightenStateDirPermissionsIfNeededwas designed for the single-uid home-directory case (~/.openclaw). It doesn't account for deployments where the state dir is a setgid group-writable shared volume between two uids, which is a common Fly Machine / Docker sidecar pattern.OPENCLAW_SKIP_*/OPENCLAW_ALLOW_*flags (OPENCLAW_SKIP_BROWSER_CONTROL_SERVER,OPENCLAW_ALLOW_MULTI_GATEWAY,OPENCLAW_SKIP_CHANNELS, etc.) that exist for the same class of concern in other subsystems.src/infra/bonjour.tsandsrc/infra/path-env.tsalready use theisTruthyEnvValue(process.env.OPENCLAW_*)pattern for similar behavioral opt-outs; this PR follows the same idiom.Regression Test Plan
src/config/io.write-config.test.tsOPENCLAW_SKIP_STATE_DIR_HARDEN=1is set, a state dir pre-created with0o2770(setgid + group-rwx, as a multi-uid deployment would mount it) retains mode0o2770after a config write — not0o700."tightens world-writable state dir when writing the default config", L115) that still passes unchanged. The new test is a direct mirror with the env var flipped, so any regression that re-introduces unconditional chmod would fail this specific case.User-visible / Behavior Changes
OPENCLAW_SKIP_STATE_DIR_HARDEN. When set to a truthy value (1/on/true/yes),tightenStateDirPermissionsIfNeededreturns without stat'ing or chmod'ing the config dir. Default behavior is unchanged when the var is unset.Diagram
Security Impact
Repro + Verification
Environment
clawsharedgroup (gid 1002) and a Fly Volume mounted at/home/node/.openclawwith setgid 2770node:clawsharedOPENCLAW_SKIP_STATE_DIR_HARDEN=1+GATEWAY_URL=ws://127.0.0.1:18789Steps to reproduce the original bug (without this PR)
mkdir -p /srv/state && chown node:clawshared /srv/state && chmod 2770 /srv/stateHOME=/srv— state dir resolves to/srv/state, matches configDir/srv/statevia the clawshared group/srv/stateis mode 0o700, the uid-1001 process hitsEACCESopening anything insideExpected (with this PR)
With
OPENCLAW_SKIP_STATE_DIR_HARDEN=1set in the gateway's environment,/srv/stateretains mode0o2770after gateway config writes, and the uid-1001 sibling continues to access files via group membership.Actual
Verified via new unit test
"leaves state dir mode alone when OPENCLAW_SKIP_STATE_DIR_HARDEN=1"— test passes: pre-set0o2770mode is preserved throughwriteConfigFile.Evidence
pnpm exec vitest run src/config/io.write-config.test.ts— all 12 tests pass (11 existing + 1 new)pnpm build— cleanHuman Verification
"tightens world-writable state dir…"test still passes (default-path regression guard)src/infra/env.tsisTruthyEnvValueto confirm accepted truthy values match existing peer varsOPENCLAW_SKIP_*/OPENCLAW_ALLOW_*convention used elsewhere (seesrc/infra/bonjour.ts:29,src/infra/path-env.ts:87,src/entry.respawn.ts:38)"1") → chmod skipped, mode preserved (new test passes)"0","false","no") →isTruthyEnvValuereturns false, default behavior (covered by existing test's empty-env case)process.platform === "win32"check above the new one)Review Conversations
Compatibility / Migration
OPENCLAW_SKIP_STATE_DIR_HARDENenv var (opt-in only).Risks and Mitigations
OPENCLAW_SKIP_STATE_DIR_HARDEN=1on a single-uid deployment and leaves their state dir world-writable.0o077-already-zero check still applies — a dir that's already 0o700 stays 0o700 regardless. The feature is scoped to deployments that are explicitly managing state-dir perms themselves.OPENCLAW_SKIP_STATE_DIR_HARDENidentifier in the repo.AI-assisted