Skip to content

fix: initialize private stores under Linux setgid parents - #188464

Merged
joshavant merged 1 commit into
mainfrom
fix/linux-private-store-setgid-20261030
Oct 30, 2026
Merged

joshavant merged 1 commit into
mainfrom
fix/linux-private-store-setgid-20261030

Conversation

@joshavant

@joshavant joshavant commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes first-use setup and private-store writes on Linux when a containing state directory has inherited setgid permissions.

User Impact

Private control and credential stores can initialize on the first attempt while their parent directories and existing data stay intact. Other unsafe-directory and permission failures remain refusals; no operator configuration or dependency change is required.

Why This Change Was Made

Linux can create a directory with mode 02700 even when mkdir requests 0700. The private creation helper then reports a published directory that failed admission. The shared store creator now normalizes only that exact Linux case through a no-follow, current-owner descriptor, verifies the named directory and parent identities, and confirms the final 0700 mode. The normal private creation path stays enabled.

Evidence

  • Native Linux x64, Node 26.12.1, full frozen dependencies including @openclaw/fs-safe 0.26.14; tested base 4cc05039cfa184303ff73e6acc91750c678b6c0a; final candidate c3aef28e9da099ebc27f371efc96856e593f9cc6.

  • The new first-create regression fails on the unmodified owner with the expected helper-failed / insecure-permissions refusal. With the repair, all four cases pass, including forbidden group/sticky modes and failed normalization. The test file takes 3.25 seconds including wrapper overhead.

  • Tooling limitation: the native run used existing Crabbox 0.78.1, below the current guide’s 0.79.2 minimum for direct leases. Those hash-bound results are supporting observations; the run is not claimed as fully compliant. Independent current-head hosted proof has now passed as detailed below; no gate was waived.

  • Existing client-credential tests: 19 passed, one Darwin-only case skipped on Linux. Existing runtime-pin tests: 10 passed. Targeted type-aware lint, infra test typecheck, format and git diff --check pass.

  • Added one exact 68-line regression allocation under the current test-cost policy; the shared baseline is unchanged. Hosted test-line ratchets and broader CI have passed.

  • Canonical autoreview (GPT-6.1 Sol, P0–P2) reviewed the complete local candidate against the tested base: scoped-clean, no actionable findings. Exact locked dependency source was supplied. The helper refused additional unchanged credential-store caller context by filename policy; that independent-review limitation remains, and the caller was inspected directly and exercised by its existing suite. Local ClawSweeper was unavailable on this host; the actual hosted final-head review has now completed with no actionable findings. No duplicate request was posted while queued.

  • Hosted CI41079702062 completed successfully. Actual checkout d885f412d4ad390bc483712890c5e6bc63bde507 merges final candidate into base 3c8bd4daf66d6958442ad95ae6d361b3e0a3a648. The owner4cases, runtime-pin10cases, and credential19passed/1Darwin-onlyskip suites ran under pinned Bun 1.4.4-canary.1+191755ec1 (openclaw-v1.4.4-20261026-191755ec11-webkit-b82bc917e9), with Node24.22.1 as the driver and fs-safe0.26.14. These hosted Bun results are distinct from native Node26 observations.

  • At2026-10-30T15:32:50Z the final head is mergeable/CLEAN; all127attached contexts are success/skip/neutral, including required aggregate CI, dependency and security-sensitive review gates. No native non-Linux or rebuilt-release claim is inferred from selected/skipped jobs. The subsequent exact-head ClawSweeper review has completed as recorded below.

  • Actual final-head ClawSweeper review completed at2026-10-30T15:49:42Z: findings0, Before merge:None, ready for maintainer review. It could not open the downstream first-use artifact and therefore independently verified source/owner-boundary evidence rather than that entire product replay. That limitation remains explicit; no source changes followed this review.

Commands: OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs run src/infra/private-store-file.test.ts --maxWorkers=1; repeat with src/daemon/runtime-pin-state.test.ts src/infra/client-credential-store.test.ts; targeted run-oxlint.mjs, run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.infra.json --incremental, and run-format.mts --check.

This focused proof covers native Linux x64. It does not establish native macOS/Windows behavior, a rebuilt current-main release, or deployed-fleet delivery. The recovery is Linux-only; broader proof belongs to PR CI and normal release qualification.

@clawsweeper

clawsweeper Bot commented Oct 30, 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.

@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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR normalizes newly created private Linux store directories from inherited mode 02700 to 0700.

Example: Create control/services.sqlite beneath a Linux state root with mode 02700.

  • Before: Directory creation publishes control with mode 02700, then throws an admission error before creating the store.
  • After: The owned control directory becomes 0700 and services.sqlite is created with mode 0600; the containing root retains 02700.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct with meaningful filesystem regression coverage and green CI; independently inspectable behavior evidence is at the in-process owner boundary.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; it reports native failing-base/passing-head filesystem coverage, passing caller suites and a linked downstream first-use replay, whose artifact was inaccessible here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Linux first-use setup can fail before private credential or control stores initialize beneath a setgid directory.
Reason: This restores intended private-store creation without changing operator settings; collaborator authorship establishes direction, and the source verifies the reported defect.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a concrete Linux first-use failure still present on main, and review found no actionable introduced defect.

Priority: P2
Reviewed head: c3aef28e9da099ebc27f371efc96856e593f9cc6

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The target PR's inspectable coverage exercises the filesystem owner; the reported downstream shipped first-use replay could not be opened from this environment.
Agent review details

How this fits together

The shared private-store preparation owner receives credential or daemon-store paths and creates private filesystem entries before the callers open their SQLite databases.

flowchart LR
  A[Credential store caller] --> C[Private store preparation]
  B[Daemon runtime pin caller] --> C
  C --> D[Exclusive filesystem creation]
  D --> E[Linux setgid normalization]
  E --> F[Private SQLite file]
Loading

Technical review

Best possible solution:

Retain the focused recovery in the shared store creator while preserving private-directory admission and existing store contents.

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

Current main and the locked dependency show the exact failure path, and the PR reports a failing-base/passing-head native regression; this read-only review executed no reproduction.

Is this the best way to solve the issue?

The repair serves both existing callers through their shared owner, narrowly restores the intended 0700 result, and introduces no competing storage owner or configuration option.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current main retains the failing ordering: Private directory creation runs before applyPrivateModeSync, so a creation admission refusal prevents normalization. (src/infra/private-store-file.ts:31, 1d6f75fd7450)
  • Narrow recovery in the existing shared owner: Recovery requires a published insecure-permissions failure, Linux, current-user ownership, exact mode 02700, a no-follow directory descriptor, matching named identity, and repeated parent identity checks; final mode must be 0700. (src/infra/private-store-file.ts:23, c3aef28e9da0)
  • Locked dependency contract and applicable policy: The patch imports and executes this package's creation and identity primitives, establishing the dependency-policy signal. At locked version 0.26.14, private POSIX directory admission rejects special permission bits; createDirectorySync preserves the published directory and wraps that refusal in helper-failed. (src/creation-boundary.ts:53, de8e85e1247e)
  • Focused regression coverage: The real-filesystem regression checks first-attempt creation, unchanged containing-root mode, 0700/0600 results, and retained existing bytes; separate fault cases check group/sticky modes and failed normalization. (src/infra/private-store-file.test.ts:10, c3aef28e9da0)
  • Reviewed head is mergeable with passing aggregate gates: Live REST reads confirm the reviewed head remains open, non-draft and mergeable/clean; CI 41079702062 completed successfully, and dependency, security-sensitive and aggregate CI statuses are successful. (c3aef28e9da0)
  • Downstream first-use report: fix(runtime): complete private-store first use with patched OpenShell openclaw-enterprise#4213 reports the original native Sandbox first-use failure and a repaired initializer/setup/model replay using the matching bridge. The linked Crabbox report was inaccessible here; its deployment and runtime-qualification claims are not independently verified by this review.

PR surface

Source +67, Tests +68, Other +2. Total +137 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 69 2 +67
Tests 1 68 0 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 139 2 +137

Labels

Label changes:

  • add P2: A concrete first-use failure affects Linux installations with inherited setgid state directories, with limited configuration-specific blast radius.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A concrete first-use failure affects Linux installations with inherited setgid state directories, with limited configuration-specific blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 30, 2026, 11:49 AM ET / 15:49 UTC.

@joshavant
joshavant merged commit 3a70caa into main Oct 30, 2026
159 checks passed
@joshavant
joshavant deleted the fix/linux-private-store-setgid-20261030 branch October 30, 2026 16:47
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
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

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

1 participant