Skip to content

fix(kubernetes): Gateway refuses to start after an fsGroup volume remount widens its private stores - #194307

Merged
roboclaw-bot merged 6 commits into
openclaw:mainfrom
tssala23:fix/private-store-fsgroup-remount
Nov 9, 2026
Merged

roboclaw-bot merged 6 commits into
openclaw:mainfrom
tssala23:fix/private-store-fsgroup-remount

Conversation

@tssala23

@tssala23 tssala23 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Closes #192959.

A Kubernetes fsGroup volume broadens the permissions of every directory and file on the volume each time it is mounted, and Linux propagates the volume's setgid bit into directories created under it. OpenClaw's private-storage owners then refuse to open state this installation already owns, and the Gateway cannot start.

fsGroupChangePolicy: OnRootMismatch (#193010) only narrows when kubelet performs that walk. It does not restore permissions that have already been broadened, so an established deployment stays down.

User Impact

A Gateway on an fsGroup PVC starts again after a remount that widened its stores, instead of refusing with Client credential directory is unsafe and leaving the container unavailable across restarts. Existing PVC contents and installation identity are preserved.

Reported from three independent deployments: OpenShift with the AWS EBS CSI driver, k3s with a local-path PVC, and OpenClaw Enterprise running OpenClaw through OpenShell, which currently carries an external workaround for it.

Why This Change Was Made

ensureOpenClawStatePermissions already restores the shared state database's directory and files on every Gateway start, and it already runs before credential admission. It simply did not cover the sibling private stores. The parked reproduction volume showed exactly that asymmetry — state/ private at 0700 while every sibling was left broadened:

2770  uid=1000830000  d  /home/node/.openclaw
2770  uid=1000830000  d  /home/node/.openclaw.update-captures
2770  uid=1000830000  d  /home/node/.openclaw/client
0660  uid=1000830000  -  /home/node/.openclaw/client/credentials.sqlite
2770  uid=1000830000  d  /home/node/.openclaw/control
0660  uid=1000830000  -  /home/node/.openclaw/control/services.sqlite
0700  uid=1000830000  d  /home/node/.openclaw/state

So this extends that existing owner to the stores beside it rather than adding a new mechanism, and no admission check is modified. Every runtime refusal stays exactly as strict as before; the repair simply runs before the owners read their stores.

The restore is deliberately narrow:

  • an enumerated path list — the client credential store, the daemon runtime pin store, their SQLite sidecars, and the <stateDir>.update-captures sibling — never a recursive walk of the state tree
  • the state root itself is left as found, because a shared, group-accessible state root is a supported layout that config publication deliberately preserves; only the private stores under and beside it are restored
  • no ownership changes; restoring a mode is not ownership transfer
  • symlinks are skipped, not followed
  • paths owned by another UID are left alone
  • paths carrying world permission bits are left for their owner to refuse, because fsGroup never sets those, so the existing refusal of a world-accessible credential directory is preserved
  • an already-private path is untouched, so its ctime stays stable
  • group membership still grants no credential authority

Doctor restores these paths inside admitted maintenance, immediately before recovery capture and after a current-owner check. Diagnostic startup does not change their permissions.

Evidence

Published-stable upgrade qualification

The maintained published-upgrade survivor lane passed from npm [email protected] to the package-installed PR merge candidate. Team-accessible run receipt.

Source binding: PR head 2bf154862a4a03e4ffc7ec418ceeb63163f7f8f4 + trusted main ce7788f5a24e5e2d0ef146a5dcea3ef4d0bb0983 = clean merge tree 32247b3dead5bb4a6823bb64d4068b484efb7877. The remote-only synthetic preview was c10472ee7677f773d7b0013c583ea344f2065f77. This tests the actual proposed merge, not a downgrade to the raw PR branch's older 2026.11.1 package version.

  • Published baseline and candidate package versions: 2026.11.2. Frozen-tarball and installed-package identity assertions passed. The serving build ID contained c10472ee7677, ruling out a same-version no-op against published bytes.
  • All 16 baseline CLI configuration intents were accepted. Maintained settings, execution-approval, session/state, workspace, runtime-dependency and survival assertions passed through the real updater and a separate doctor --fix --non-interactive run. Opaque configuration for the intentionally unavailable plugin path was preserved.
  • Updater outcome: success; recovery required: none. Doctor passed in 133s. Gateway startup took 36s; /healthz and /readyz returned 200, with ready=true, coreReady=true, failing=[]. Authenticated WebSocket RPC passed with operator.read authority.
  • Secretless AWS, public networking, no Tailscale or instance role; IMDSv2 IAM credentials endpoint 404 verified before source execution. The runner was released with a blocking cleanup receipt.

This is the maintained deterministic base scenario with a manual foreground restart, not native service-manager activation, OpenShift/OCE cluster qualification, or live provider/channel/model-turn proof. Readiness reported CPU-degradation telemetry while remaining ready/core-ready; no storage guards, assertions, timeouts or readiness allowances were weakened. An initial packaging-umask setup failure was corrected before the successful complete run; private runtime ancestry stayed 0700.

Maintained lane invocation
OPENCLAW_DOCKER_E2E_SELECTED_SHA=c10472ee7677f773d7b0013c583ea344f2065f77 \
OPENCLAW_UPGRADE_SURVIVOR_PUBLISHED_BASELINE=1 \
[email protected] \
OPENCLAW_UPGRADE_SURVIVOR_CANDIDATE=current \
OPENCLAW_UPGRADE_SURVIVOR_SCENARIO=base \
OPENCLAW_UPGRADE_SURVIVOR_UPDATE_RESTART_MODE=manual \
bash scripts/e2e/upgrade-survivor-docker.sh

Required CI also passed for this PR head: completed successful CI run. The clean merge preview passes the test-line gate with 6 lines of slack, without increasing the shared ceiling.

Current follow-up evidence

Follow-up commit: 2bf154862a4a.

  • FIFO and pre-consent-mutation regressions: red on d4b87464d88e, green with the repair. Focused tests: 59 passed, 1 existing ACL skip.
  • Core and core-test typechecks, file-scoped lint, formatting, docs formatting, runtime build, and the assertion-safety ratchet passed. The obsolete assertion baseline was removed, not enlarged.
  • Real different-UID/shared-group, foreign-owner, symlink and hardlink checks preserved protected ownership, modes, ctimes and bytes; credential custody still refused access.
  • Real CLI checks on an existing installation after explicitly broadening owned directories/files to 2770/0660 passed through Doctor, then through direct Gateway startup after broadening the stores again. The existing identity was retained, recovery manifests remained available, and authenticated health checks passed.
initial-doctor: exit=0
initial-doctor: retained original-state capture verified
initial-gateway: readyz=200, authenticated health exit=0
remounted-doctor: exit=0
remounted-doctor: retained original-state capture verified
post-doctor-gateway: readyz=200, authenticated health exit=0
direct-remount-gateway: readyz=200, authenticated health exit=0
PASS: existing identity retained through Doctor and direct Gateway remount restarts; stores private

This follow-up used secretless AWS Linux and real UIDs/processes with synthetic credentials. It is not a new OpenShift/EBS/OCE cluster qualification or a model-turn test. Earlier cluster observations below are historical.

Team-accessible run receipts: focused regressions, type/lint/build and authority checks, real CLI restart proof. The middle run's initial fixture/ratchet failures are reconciled in the follow-up notes; it is not described as an all-green aggregate.

Earlier implementation evidence

Red on the base. src/state/openclaw-state-db-permissions.test.ts fails on the unfixed tree with the reported error, using only APIs the base already has:

× lets the credential owner admit a remounted installation
  → Client credential directory is unsafe.

Earlier implementation run: 7 passed. Unit sweep across the affected owners — client-credential-store, private-store-file, openclaw-state-db-open, openclaw-state-db.permissions, openclaw-agent-db.permissions, runtime-pin — all green.

Historical cluster A/B — earlier implementation, not current-head qualification. These logs predate descriptor restoration and shared-root preservation. Same PVC, no init-container chmod. OpenShift 4.21.16 / Kubernetes v1.34.7, RHCOS 9.6, ebs.csi.aws.com (gp3, fsGroupPolicy: File), fsGroup: 1000830000, fsGroupChangePolicy: Always, Gateway running as the namespace's arbitrary UID. Starting state: directories 2770, store files 0660.

Unfixed image:

Failing check state-schema (step-refused): Failed migrating shared state database
  schema: Error: Client credential directory is unsafe.
- Pre-repair recovery copy was unavailable: Private SQLite staging root must be
  owned by the current user and not writable by other users:
  /home/node/.openclaw.update-captures.
Failing check config-machine-state (blocked-by-prior-refusal)
→ exitCode 1, container restarting, never Ready

Fixed image, same volume, kubelet still leaving the volume broadened at each mount:

→ Doctor complete.  ready=true  restarts=0

0700  uid=1000830000  d  /home/node/.openclaw
0700  uid=1000830000  d  /home/node/.openclaw.update-captures
0700  uid=1000830000  d  /home/node/.openclaw/client
0600  uid=1000830000  -  /home/node/.openclaw/client/credentials.sqlite
0700  uid=1000830000  d  /home/node/.openclaw/control
0600  uid=1000830000  -  /home/node/.openclaw/control/services.sqlite
0700  uid=1000830000  d  /home/node/.openclaw/state
0600  uid=1000830000  -  /home/node/.openclaw/state/openclaw.sqlite

openclaw.json already present (preserved) throughout; no reseed, no empty-subpath switch, no relocation.

Review feedback already applied

CI caught two things, both now fixed and both worth stating plainly:

  • A real regression. Restoring the state root to 0700 broke src/config/io.write-config.test.ts, "preserves a shared state root when publishing private config" — a deliberate contract where the state root may stay group-accessible while the files inside remain private. The reported refusals were all on the stores under and beside the root rather than the root itself, so the root is no longer restored, and the regression suite now asserts a shared root is preserved. The fix is strictly smaller as a result.

  • A type error. The private-store path list was typed as readonly string[] rather than tuples, so destructuring produced string | undefined under strict index checking and tsgo rejected the core and core-test projects. That accounted for the typecheck and lint failures on the first run.

  • Alias handling, from the clawsweeper review. Restoration applied modes by pathname, which re-resolves every component, so it could change an object this installation does not own. Three cases, each now red on the base: a store file reached through a symlinked store directory was mutated although the directory itself was refused as an alias, because refusing the directory did not stop the walk into its children (0660 → 0600 on a file outside the installation); a store file carrying a second name outside the installation was mutated through that other name; and a store path that was not a regular file was mutated as if it were one (a directory chmodded to 0600). Admission now opens each store with O_NOFOLLOW and verifies type, identity, owner and link count on the descriptor before fchmod touches it; admitting a directory decides whether its children may be inspected at all, and the directory descriptor is re-verified before each child so an alias swapped in after admission cannot redirect the change.

  • A regression that fix introduced, caught before pushing. Opening requires read access where lstat did not, so a foreign-owned or owner-unreadable store would have thrown EACCES out of a function that runs on every Gateway start. EACCES and EPERM are now tolerated with a warning, keeping permission hardening best-effort as [Bug]: chmodSync in openOpenClawStateDatabase crashes gateway on filesystems without POSIX permission support #91919 requires, and a test asserts the call does not throw for a store directory the owner cannot read. That narrows behaviour deliberately: an unopenable store is left alone rather than repaired, because identity cannot be verified on an object that cannot be opened.

Scope and Limitations

  • Not fixed here, by design: the group-writable temp-ancestor failure (Kubernetes: /tmp emptyDir lacks sticky protection required by fs-safe, disabling session observer #156985), which the reporters and the issue both treat as separate.
  • Still operator work, and structurally so: Doctor's pre-repair recovery copy refuses a staging ancestor another user could replace, and it walks the whole ancestor chain to the kubelet-created mount point, which fsGroup leaves group-writable (/home/node, 2775 owner=0). I tested moving the state directory one level deeper under the mount; the check still names the mount point, so layout depth does not help. fsGroup is both the enabler and the blocker here: it is what makes the volume writable by an arbitrary UID, and it is what makes the mount point an untrusted ancestor. Recovery capture therefore needs a mount point provisioned with the Gateway's ownership before startup (OpenShell Bug: macOS app 'Browser Control' toggle doesn't start browser relay #5047; OpenClaw Enterprise does this with a preparation Deployment). Restoring modes is not ownership transfer and an unprivileged container cannot chown a foreign-owned mount point. The Gateway starts and Doctor completes either way; only the pre-repair recovery copy is unavailable.
  • Private-store sharing remains unsupported: group membership does not grant access to the same private stores across UIDs. Separate UID-owned private workload subpaths may share a group-accessible PVC root; the documentation now distinguishes these cases.
  • Newly created directories inheriting setgid already normalize correctly on current main (fix: initialize private stores under Linux setgid parents #188464); verified across parent modes 02700, 02770, 02775 and 0770, each yielding 0700/0600. No change was needed for that half.
  • Checks. The first CI run went red and one cause was mine: the private-store path list was typed as readonly string[] rather than tuples, so destructuring produced string | undefined under strict index checking and tsgo rejected the core and core-test projects. Fixed in the follow-up commit. tsgo -p tsconfig.core.json and run-tsgo-core-test-shards.mjs now both exit 0 locally, alongside file-scoped oxlint (0 errors, 0 warnings), format, docs-format, docs-MDX and the import-cycle check. I had been relying on file-scoped lint plus vitest, neither of which type checks, which is why this reached CI.
  • Ratchet qualification. The current raw branch reports 34 lines of inherited test-line debt: the follow-up adds exactly 127 test lines and exactly 127 allocation lines, so it does not increase that excess. No extra credit or shared-ceiling increase was added to hide it. The earlier reconciliation in #194509 was an earlier-main observation. Current-head merge CI has now passed the baseline-ratchet job, and the pinned clean merge preview passes with 6 lines of slack. The assertion-safety failure in the last reviewed CI run is repaired by the shared errno guard and the exact baseline shrink.
  • Cost budget. The follow-up adds 127 test lines across three files. The PR allocation is exactly 380 net test lines, with no shared scalar increase. The FIFO regression runs in a child with a bounded timeout rather than risking a hung test worker.
  • The other first-run failures came from the merge base rather than this branch: plugins:assets:build could not resolve ./client.js from extensions/deep-research/browser/index.tsx. That module is present on main now, so those jobs should pass on re-run. doctor-config-preflight.recovery.test.ts fails identically with and without this change in my environment.
  • The in-cluster validation used a patched image rather than a staged init container, because this environment's policy blocks chmod-bearing manifests.

Docs

docs/install/kubernetes.md records the restoration scope, narrowing rules, and cases that still require the storage owner. Earlier platform observations are retained above as historical evidence, not represented as qualification of the current build.

Follow-up repairs

  • File candidates use O_NONBLOCK before descriptor type checks, so a writerless FIFO cannot hang startup.
  • Doctor permission restoration runs after repair admission and maintenance ownership, before original-state capture. The selected maintenance environment is used, and cancellation/current ownership are checked immediately before the filesystem effect.
  • The assertion-safety CI failure is fixed by using the shared errno type guard, removing the now-unused per-file baseline entry rather than granting an exception.
  • Added bounded FIFO, diagnostic no-mutation, pre-capture ordering and stale-authority regressions. The allocation covers exactly 380 net PR test lines; the shared test-line ceiling is unchanged.

Follow-up evidence

  • The FIFO and pre-consent mutation regressions fail against d4b87464d88eae519cd58f810bde1e52df68222e and pass with these repairs.
  • Focused tests: 59 passed, 1 existing ACL skip, covering private-store permissions, Doctor startup/capture, credentials, SQLite permissions, and setgid creation.
  • Core and core-test typechecks and file-scoped lint passed. Runtime build completed successfully.
  • On a secretless AWS runner, real different-UID/shared-group and foreign-owned-store checks preserved ownership, modes, ctimes and bytes; credential admission still refused access. Symlinked and hardlinked store aliases were also refused without changing their outside targets.
  • Autoreview examined the full candidate through P2. It identified the two original P2s in the then-old index, explicitly confirmed their working-tree fixes, and established no additional P0–P2 code defect. The fixes are now staged together; a formatting-only correction and exact baseline shrink followed.

CLI restart/capture, authority and published-stable upgrade proof are complete as summarized above. Required CI passed for this head. The completed re-review found no actionable code findings; its remaining stable-upgrade evidence request is now supplied above for re-review. The raw-branch overage is recorded, while the actual merge preview and CI baseline gate pass without a shared-ceiling increase. No merge, OpenShift/OCE cluster rerun or live model turn is claimed.

…ount widens its private stores

Kubernetes re-applies fsGroup group permissions to every directory and file of
a volume on each mount, and Linux propagates the volume's setgid bit into
directories the Gateway creates under it. The private-storage owners then
refuse to open state this installation already owns and the Gateway cannot
start. fsGroupChangePolicy: OnRootMismatch narrows when kubelet performs that
walk; it does not restore permissions already broadened.

ensureOpenClawStatePermissions already restores the shared state database's
directory and files on every Gateway start, before credential admission. It
did not cover the private stores beside it. Extend it to an enumerated list of
installation-owned paths: the state directory, the client credential store, the
daemon runtime pin store, their SQLite sidecars, and the update-capture
sibling. Run the same restore at Doctor's earliest startup phase, because
Doctor's recovery capture reads these paths before database preflight.

No admission check changes. The restore repairs an enumerated path list rather
than walking the state tree, changes no ownership, skips symlinks, leaves
paths owned by another UID alone, and leaves any path carrying world
permission bits for its owner to refuse, because fsGroup never sets those.

Closes openclaw#192959
@clawsweeper

clawsweeper Bot commented Nov 6, 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: M labels Nov 6, 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR restores private permissions on installation-owned stores before Gateway admission and admitted Doctor recovery capture.

Example: A PVC remount changes client/ to 2770 and client/credentials.sqlite to 0660 for Gateway UID 1000830000.

  • Before: Gateway startup refuses with “Client credential directory is unsafe.”
  • After: The owned directory and file return to 0700 and 0600, and startup retains the existing identity.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, correct, and proven through shipped CLI entry points and a published-stable upgrade; one redundant static test adds little confidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Current-head Linux CLI output exercises initial and widened-store Doctor and direct Gateway restarts with retained identity, recovery captures, and authenticated health; real UID/alias checks and the production-owner revocation regression cover forbidden effects, and the newly supplied published-2026.11.2 upgrade preserves settings and state in a package-installed merge candidate bound to this head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A previously working Kubernetes Gateway cannot restart after volume permission widening.
Reason: Multiple deployments report the owned startup failure, and the repair restores existing private-storage contracts without adding configuration or relaxing credential admission.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current startup failure, preserves credential admission protections, and has no remaining actionable code findings.

Priority: P1
Reviewed head: 2bf154862a4a03e4ffc7ec418ceeb63163f7f8f4

Before merge

None.

Findings

None.

Tests

  • Low-value test src/state/openclaw-state-db-permissions.test.ts: Remove the resolver-literal inventory test: it does not exercise the restoration list, and the broadened-store behavior tests already use canonical resolvers and fail if restoration stops covering those paths.
Agent review details

How this fits together

Gateway startup and Doctor maintenance enter the existing state-permission owner, which repairs enumerated private stores before their credential, runtime-pin, and recovery owners inspect them.

flowchart TD
  A[Gateway startup] --> C[State permission owner]
  B[Admitted Doctor maintenance] --> C
  C --> D[Descriptor ownership and alias checks]
  D --> E[Private mode restoration]
  E --> F[Credential and runtime pin admission]
  E --> G[Doctor recovery capture]
Loading

Technical review

Best possible solution:

Land the bounded repair through the existing permission owner while retaining downstream admission and documented storage-layout requirements.

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

Current main deterministically rejects a 2770 credential directory, matching the linked report and supplied before-fix output; this review ran no target code.

Is this the best way to solve the issue?

The smallest complete repair extends the existing permission owner to enumerated sibling stores and invokes it after Doctor admission, with descriptor checks required by the demonstrated alias failures.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Kubernetes remount guidance changes intended behavior with a stated reason (0fd7cc7: Limit kubelet permission walks and distinguish prevention from recovery and storage adoption.)
  • Private-mode filesystem tolerance keeps the original intent (aeb5b79: Keep SQLite usable on filesystems that cannot enforce chmod; later WSL handling preserves already-private EROFS behavior.)
  • Shared-state permission handling keeps the original intent (11ad47f: Preserve writable foreign-owned shared storage and tolerate unsupported hardening without changing ownership.)
  • Doctor original-capture admission keeps the original intent (ecee1af: Separate read-only schema checks from live maintenance authority and require admitted capture and repair.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit aeb5b79 adds src/infra/private-mode.ts:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: aeb5b794c91a; files: src/infra/private-mode.ts)
  • Jason (Json): Raw commit ecee1af adds src/commands/doctor-original-capture-admission.ts:8 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ecee1affa92f; files: src/commands/doctor-original-capture-admission.ts)

PR surface

Source +263, Tests +380, Docs +32, Other +11. Total +686 across 9 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 3 270 7 +263
Tests 3 380 0 +380
Docs 1 44 12 +32
Config 0 0 0 0
Generated 0 0 0 0
Other 2 12 1 +11
Total 9 706 20 +686

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.

Review metrics

Metric Value Why it matters
Production versus regression code Production +270/-7; tests +380/-0 Most production growth implements descriptor-bound repair and refusal handling; tests exercise remount recovery, alias boundaries, nonblocking startup, and maintenance authority.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #192959
Summary: This PR owns the remount repair for the canonical issue; earlier merged work addresses prevention and first creation.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Existing Kubernetes installations can remain unavailable across pod restarts after private stores acquire group permissions.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-06T20:37:22.692Z sha 3e995ec :: needs real behavior proof before merge. :: [P2] Stop visiting files beneath a rejected store directory | [P2] Reject hardlinked files before restoring their modes | [P3] Keep capture fixtures inside the tracked temporary root
  • reviewed 2026-11-07T14:57:08.387Z sha d4b8746 :: needs real behavior proof before merge. :: [P2] Open store candidates without blocking on special files
  • reviewed 2026-11-09T18:48:28.811Z sha 2bf1548 :: needs real behavior proof before merge. :: none

Reviewed November 9, 2026, 2:55 PM ET / 19:55 UTC (Revision 4).

tssala23 added 4 commits November 6, 2026 16:02
The inner Object.freeze calls widened each entry to readonly string[], so
destructuring yielded string | undefined under the repository's strict index
checking and tsgo refused the core and core-test projects.
…te stores

A group-accessible state root is a supported layout: config publication
deliberately preserves its mode while keeping the files inside private
(src/config/io.write-config.test.ts, "preserves a shared state root when
publishing private config"). Restoring the state root to 0700 broke that
contract, and CI caught it.

Only the private stores under and beside the state root have to be private, and
the reported refusals were all on those paths rather than on the root, so drop
the root from the restored set and assert the shared root is preserved. Also
allocate the added test lines.
Pathname chmod re-resolves every component, so the restoration could change
an object this installation does not own:

- a store file reached through a symlinked store directory was mutated even
  though the directory itself was refused as an alias, because refusing the
  directory did not stop the walk into its children;
- a store file carrying a second name outside the installation was mutated
  through that other name, since a mode change travels with the inode;
- a store path that was not a regular file was mutated as if it were one.

Admission now opens each store with O_NOFOLLOW, verifies type, identity,
owner and link count on the descriptor, and applies the mode with fchmod to
that descriptor. Admitting a directory decides whether its children may be
touched at all, and the directory descriptor is re-verified before each child
so an alias swapped in after admission cannot redirect the change.

Opening needs read access where lstat did not, so EACCES and EPERM are
tolerated with a warning: permission hardening stays best-effort and must
never take the gateway down (openclaw#91919).

Reported by the clawsweeper review of openclaw#194307.
@tssala23

tssala23 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — both filesystem findings were real, and I verified them against the
code before fixing rather than taking them on trust.

Root cause was shared: modes were applied by pathname, which re-resolves every
component. Admission now opens each store with O_NOFOLLOW, verifies type,
identity (dev/ino), owner and link count on the descriptor, and applies the
mode with fchmod to that descriptor. Admitting a directory also decides
whether its children may be inspected at all, and the directory descriptor is
re-verified before each child, so an alias swapped in after admission cannot
redirect the change.

All three cases are red on the base, and the failures show the mutation
escaping the installation rather than just a missing guard:

  • store file via a symlinked store directory — expected 384 to be 432: the
    previous code took a file outside the installation from 0660 to 0600
  • store file with a second name outside the installation — expected 384 to be 432: the external alias changed too
  • store path that is not a regular file — expected 384 to be 1528: a
    directory was chmodded to 0600

Also fixed the capture-fixture leak: the tracked temporary directory is now the
shared parent of the state directory and its capture sibling.

One regression that fix introduced, caught before pushing: opening needs read
access where lstat did not, so a foreign-owned or owner-unreadable store would
have thrown EACCES out of a function that runs on every Gateway start. EACCES
and EPERM are now tolerated with a warning, keeping hardening best-effort per
#91919, with a test asserting the call does not throw. That narrows behaviour
deliberately: an unopenable store is left alone rather than repaired, since
identity cannot be verified on an object that cannot be opened. A genuinely
foreign-owned store still needs privileges to exercise, so that path is reasoned
about rather than proven.

On the resolver inventory test: I kept it and recorded why in a comment.
PRIVATE_STATE_STORES repeats those path literals, and nothing else fails if a
resolver moves a store while the constant stays put — the restore would quietly
stop covering it and #192959 would return. Every repair test reaches its paths
through the resolvers, so none of them can see that drift. Happy to drop it if
you still disagree, but I did not want to remove the only guard against that.

Verified: 11 tests in the permissions suite, plus io.write-config (103),
client-credential-store (20 + 1 skipped) and doctor-health-startup (7);
tsgo:core and all 12 tsgo:core:test shards; oxlint 0/0; format; import
cycles 0; temp-path guardrails. The test-lines ratchet now passes as well —
#194509 reconciled the inherited ceiling on main.

Still outstanding from your list: the cluster A/B in the body predates both this
descriptor change and the earlier state-root narrowing, so those logs were
produced by a different build. I would rather re-run it than let them stand as
evidence for code that did not produce them.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Nov 7, 2026
@sallyom sallyom self-assigned this Nov 9, 2026
Restore private store modes only after Doctor repair admission, preserve owner checks, and reject special files without blocking startup. Use the shared errno guard and retire its obsolete assertion baseline.

Co-authored-by: sallyom <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Nov 9, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Nov 9, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 9, 2026
@roboclaw-bot
roboclaw-bot merged commit bc914b5 into openclaw:main Nov 9, 2026
195 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

After careful consideration, we're accepting the residual compatibility risk and retaining automatic permission restoration rather than adding an opt-in gate. This records the decision to land the reviewed head 2bf154862a4a, now merged as bc914b586dd3.

The residual risk is that a custom helper or backup process running under another UID could lose group-based access when eligible private stores are tightened to 0700/0600. This behavior applies beyond Kubernetes on POSIX systems. We judge the expected compatibility risk to be low, not zero or quantitatively established, for these reasons:

  • The reported harm is concrete and severe: established deployments stop working after routine PVC remounts and cannot recover unattended.
  • The compatibility concern is plausible but unobserved: the review did not identify a working supported deployment that this PR actually breaks. Custom integration dependencies remain a possibility.
  • Private credentials already require owner-only access: group-accessible credentials are already rejected by the credential owner. This narrows the group-sharing concern without eliminating every custom-helper risk.
  • The repair is bounded: it covers enumerated private stores and SQLite sidecars, verifies ownership and object identity, and applies descriptor-bound changes. It does not transfer ownership, recursively chmod the volume, or tighten the shared state root.
  • The relevant proof is strong: existing-identity Doctor and direct-Gateway restart checks passed, real UID/alias refusal checks preserved the boundaries, and the maintained published-stable upgrade to the pinned merge candidate preserved settings and state. Required CI passed for the reviewed head. See the PR's Evidence section for the results and qualifications.

An opt-in gate would impose certain operator intervention on existing, unconfigured remount-affected deployments to protect against an unconfirmed integration dependency. We chose to retain unattended recovery and disclose the remaining risk. This does not claim that chmod repairs prior disclosure/tampering or removes the documented foreign-owned mount, recovery-ancestry, filesystem, and deployment-layout limitations.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…ount widens its private stores (openclaw#194307)

* fix(kubernetes): Gateway refuses to start after an fsGroup volume remount widens its private stores

Kubernetes re-applies fsGroup group permissions to every directory and file of
a volume on each mount, and Linux propagates the volume's setgid bit into
directories the Gateway creates under it. The private-storage owners then
refuse to open state this installation already owns and the Gateway cannot
start. fsGroupChangePolicy: OnRootMismatch narrows when kubelet performs that
walk; it does not restore permissions already broadened.

ensureOpenClawStatePermissions already restores the shared state database's
directory and files on every Gateway start, before credential admission. It
did not cover the private stores beside it. Extend it to an enumerated list of
installation-owned paths: the state directory, the client credential store, the
daemon runtime pin store, their SQLite sidecars, and the update-capture
sibling. Run the same restore at Doctor's earliest startup phase, because
Doctor's recovery capture reads these paths before database preflight.

No admission check changes. The restore repairs an enumerated path list rather
than walking the state tree, changes no ownership, skips symlinks, leaves
paths owned by another UID alone, and leaves any path carrying world
permission bits for its owner to refuse, because fsGroup never sets those.

Closes openclaw#192959

* fix(kubernetes): type the private store path list as tuples

The inner Object.freeze calls widened each entry to readonly string[], so
destructuring yielded string | undefined under the repository's strict index
checking and tsgo refused the core and core-test projects.

* fix(kubernetes): keep a shared state root's mode when restoring private stores

A group-accessible state root is a supported layout: config publication
deliberately preserves its mode while keeping the files inside private
(src/config/io.write-config.test.ts, "preserves a shared state root when
publishing private config"). Restoring the state root to 0700 broke that
contract, and CI caught it.

Only the private stores under and beside the state root have to be private, and
the reported refusals were all on those paths rather than on the root, so drop
the root from the restored set and assert the shared root is preserved. Also
allocate the added test lines.

* docs(kubernetes): record that a shared state root keeps its mode

* fix(kubernetes): bind private store restoration to admitted descriptors

Pathname chmod re-resolves every component, so the restoration could change
an object this installation does not own:

- a store file reached through a symlinked store directory was mutated even
  though the directory itself was refused as an alias, because refusing the
  directory did not stop the walk into its children;
- a store file carrying a second name outside the installation was mutated
  through that other name, since a mode change travels with the inode;
- a store path that was not a regular file was mutated as if it were one.

Admission now opens each store with O_NOFOLLOW, verifies type, identity,
owner and link count on the descriptor, and applies the mode with fchmod to
that descriptor. Admitting a directory decides whether its children may be
touched at all, and the directory descriptor is re-verified before each child
so an alias swapped in after admission cannot redirect the change.

Opening needs read access where lstat did not, so EACCES and EPERM are
tolerated with a warning: permission hardening stays best-effort and must
never take the gateway down (openclaw#91919).

Reported by the clawsweeper review of openclaw#194307.

* fix(kubernetes): keep permission repair nonblocking and admitted

Restore private store modes only after Doctor repair admission, preserve owner checks, and reject special files without blocking startup. Use the shared errno guard and retire its obsolete assertion baseline.

Co-authored-by: sallyom <[email protected]>

---------

Co-authored-by: sallyom <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 16, 2026
…ount widens its private stores (openclaw#194307)

Release-specific adaptation for 2026.11.4: Only existing Doctor capture root: descriptor-bound mode tightening under admitted authority. No shared-state root, child file, startup or runtime-pin changes. World-writable, foreign, alias and unsafe-ancestor refusal retained.

Source commit: bc914b5
Source PR: 194307

CI qualification pending; source-only verification completed.

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport the bounded private-store permission repair from #194307 and the
required startup placement from #197009 and first-create fix from #188464.
Keep descriptor identity, ownership, link and world-access refusals, and Doctor
current-authority admission.
Do not re-open sibling stores after each shared-state commit.

Adapt Kubernetes documentation to the stable branch. Exclude the companion
performance instrumentation, benchmarks and unrelated Telegram fixture edits.

(cherry picked from commit bc914b5)
(partially cherry picked from commit 2598631)
(cherry picked from commit 3a70caa)

Co-authored-by: sallyom <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Josh Avant <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

[Bug]: Gateway refuses to start after pod restart on Kubernetes: client credential directory rejected after fsGroup remount

3 participants