Repository navigation
fix(kubernetes): Gateway refuses to start after an fsGroup volume remount widens its private stores - #194307
Conversation
…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
|
🦞👀 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 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +263, Tests +380, Docs +32, Other +11. Total +686 across 9 files. Added test files: 2. 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. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
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 HistoryReview history (3 earlier review cycles)
Reviewed November 9, 2026, 2:55 PM ET / 19:55 UTC (Revision 4). |
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.
|
Thanks — both filesystem findings were real, and I verified them against the Root cause was shared: modes were applied by pathname, which re-resolves every All three cases are red on the base, and the failures show the mutation
Also fixed the capture-fixture leak: the tracked temporary directory is now the One regression that fix introduced, caught before pushing: opening needs read On the resolver inventory test: I kept it and recorded why in a comment. Verified: 11 tests in the permissions suite, plus io.write-config (103), Still outstanding from your list: the cluster A/B in the body predates both this @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
|
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 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
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. |
…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]>
…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]>
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]>
What Problem This Solves
Closes #192959.
A Kubernetes
fsGroupvolume 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
fsGroupPVC starts again after a remount that widened its stores, instead of refusing withClient credential directory is unsafeand 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
ensureOpenClawStatePermissionsalready 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 at0700while every sibling was left broadened: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:
<stateDir>.update-capturessibling — never a recursive walk of the state treefsGroupnever sets those, so the existing refusal of a world-accessible credential directory is preservedDoctor 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 maince7788f5a24e5e2d0ef146a5dcea3ef4d0bb0983= clean merge tree32247b3dead5bb4a6823bb64d4068b484efb7877. The remote-only synthetic preview wasc10472ee7677f773d7b0013c583ea344f2065f77. This tests the actual proposed merge, not a downgrade to the raw PR branch's older 2026.11.1 package version.c10472ee7677, ruling out a same-version no-op against published bytes.doctor --fix --non-interactiverun. Opaque configuration for the intentionally unavailable plugin path was preserved./healthzand/readyzreturned 200, withready=true,coreReady=true,failing=[]. Authenticated WebSocket RPC passed withoperator.readauthority.This is the maintained deterministic
basescenario 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 stayed0700.Maintained lane invocation
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.d4b87464d88e, green with the repair. Focused tests: 59 passed, 1 existing ACL skip.2770/0660passed 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.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.tsfails on the unfixed tree with the reported error, using only APIs the base already has: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: directories2770, store files0660.Unfixed image:
Fixed image, same volume, kubelet still leaving the volume broadened at each mount:
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
0700brokesrc/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 producedstring | undefinedunder strict index checking andtsgorejected 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→0600on 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 to0600). Admission now opens each store withO_NOFOLLOWand verifies type, identity, owner and link count on the descriptor beforefchmodtouches 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
lstatdid not, so a foreign-owned or owner-unreadable store would have thrownEACCESout of a function that runs on every Gateway start.EACCESandEPERMare now tolerated with a warning, keeping permission hardening best-effort as [Bug]:chmodSyncinopenOpenClawStateDatabasecrashes 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
fsGroupleaves 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.fsGroupis 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.main(fix: initialize private stores under Linux setgid parents #188464); verified across parent modes02700,02770,02775and0770, each yielding0700/0600. No change was needed for that half.readonly string[]rather than tuples, so destructuring producedstring | undefinedunder strict index checking andtsgorejected the core and core-test projects. Fixed in the follow-up commit.tsgo -p tsconfig.core.jsonandrun-tsgo-core-test-shards.mjsnow both exit 0 locally, alongside file-scopedoxlint(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.plugins:assets:buildcould not resolve./client.jsfromextensions/deep-research/browser/index.tsx. That module is present onmainnow, so those jobs should pass on re-run.doctor-config-preflight.recovery.test.tsfails identically with and without this change in my environment.Docs
docs/install/kubernetes.mdrecords 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
O_NONBLOCKbefore descriptor type checks, so a writerless FIFO cannot hang startup.Follow-up evidence
d4b87464d88eae519cd58f810bde1e52df68222eand pass with these repairs.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.