Repository navigation
feat(crabbox): protect cloud setup secrets through egress - #171073
Conversation
Use destination-bound store references for setup and lifecycle jobs, retain snapshot eligibility, and migrate eligible setupEnv profiles through Doctor. Reparse cached recipes on upgrade so secret requests cannot bypass operator mapping.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8e29616cf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (profile.setupEnv !== undefined) { | ||
| if (!Array.isArray(profile.setupEnv)) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv must be an array"); | ||
| } | ||
| if (profile.setupEnv.length > 16) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv must contain at most 16 names"); | ||
| } | ||
| setupEnv = profile.setupEnv.map((name) => { | ||
| if (typeof name !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name)) { | ||
| throw new WorkerProviderError( | ||
| "Crabbox profile setupEnv must contain only valid POSIX environment variable names", | ||
| ); | ||
| } | ||
| if (name === "CRABBOX_ENV_ALLOW") { | ||
| throw new WorkerProviderError(`Crabbox profile setupEnv name ${name} is reserved`); | ||
| } | ||
| return name; | ||
| }); | ||
| if (new Set(setupEnv).size !== setupEnv.length) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv must not contain duplicate names"); | ||
| } | ||
| if (setupEnv.length > 0 && !setup) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv requires setup"); | ||
| } | ||
| throw new WorkerProviderError( | ||
| "Crabbox profile setupEnv is retired; run openclaw doctor --fix to migrate protected, destination-bound store entries to setupSecrets. Repair any reported entries before provisioning; plaintext forwarding is unavailable.", | ||
| ); |
There was a problem hiding this comment.
Keep maintenance compatible with legacy setupEnv profiles
When an upgrade leaves setupEnv unrepaired because a store entry is missing, unbound, or conflicting, this new throw also breaks provider.maintain() and explicit image deletion: resolveCrabboxCheckpointBinaries still parses every configured profile with parseCrabboxProfile, and that synchronous parse failure aborts the whole batch before its Promise.allSettled. Consequently, expired checkpoints for every Crabbox profile remain undeleted until the configuration can be repaired; use the cleanup-tolerant profile parser for maintenance and image cleanup as well.
AGENTS.md reference: AGENTS.md:L80-L81
Useful? React with 👍 / 👎.
Protect HTTPS setup traffic through the secret egress bridge while clearing inherited HTTP proxy settings. Plain HTTP package downloads stay direct and cannot receive substituted secrets.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 789d8c0328
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| createScript && Object.keys(params.setupSecrets ?? {}).length | ||
| ? await runCrabboxSetupEgress({ | ||
| ...params, | ||
| secrets: params.setupSecrets ?? {}, |
There was a problem hiding this comment.
Scope repository egress to requested secret names
When lifecycle execution is authorized and a profile maps multiple setup secrets, this passes the entire setupSecrets map to repository preparation even if the devcontainer requests only a subset—or no secrets at all. Core records the requested names in project.secretNames, but the Crabbox preparation and post-create/start paths never consume that field, so repository code can exercise every profile credential against its allowed host. Filter repository grants to the recipe's declared names while retaining the full map only for operator-authored profile setup.
Useful? React with 👍 / 👎.
| if (ref.source !== "store") { | ||
| throw new Error("Setup egress requires shared-store SecretRefs"); | ||
| } |
There was a problem hiding this comment.
Validate store provider aliases before reading the shared store
When a setup SecretRef names a typoed, unconfigured, or non-store provider alias, this path discards ref.provider and reads the matching ID directly from the team store. The canonical SecretRef resolver would reject that alias/source mismatch, but setup egress instead silently grants a different credential whenever the shared store contains the ID; preserve the normal provider validation before loading store metadata.
AGENTS.md reference: AGENTS.md:L74-L74
Useful? React with 👍 / 👎.
Assert the setup-secret inspection callback supplied to bundled worker-provider Doctor checks. Name Crabbox 0.77.0 in setup egress upgrade remedies and documentation while retaining native help-text feature detection.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c048047ab6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (profile.setupEnv !== undefined) { | ||
| if (!Array.isArray(profile.setupEnv)) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv must be an array"); | ||
| } | ||
| if (profile.setupEnv.length > 16) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv must contain at most 16 names"); | ||
| } | ||
| setupEnv = profile.setupEnv.map((name) => { | ||
| if (typeof name !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name)) { | ||
| throw new WorkerProviderError( | ||
| "Crabbox profile setupEnv must contain only valid POSIX environment variable names", | ||
| ); | ||
| } | ||
| if (name === "CRABBOX_ENV_ALLOW") { | ||
| throw new WorkerProviderError(`Crabbox profile setupEnv name ${name} is reserved`); | ||
| } | ||
| return name; | ||
| }); | ||
| if (new Set(setupEnv).size !== setupEnv.length) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv must not contain duplicate names"); | ||
| } | ||
| if (setupEnv.length > 0 && !setup) { | ||
| throw new WorkerProviderError("Crabbox profile setupEnv requires setup"); | ||
| } | ||
| throw new WorkerProviderError( | ||
| "Crabbox profile setupEnv is retired; run openclaw doctor --fix to migrate protected, destination-bound store entries to setupSecrets. Repair any reported entries before provisioning; plaintext forwarding is unavailable.", |
There was a problem hiding this comment.
Update the Control UI before rejecting setupEnv
When a user enters any “Setup environment names” value, the Control UI still serializes it as settings.setupEnv in ui/src/pages/cloud-workers/cloud-worker-config.ts:212-223, and the generic config schema accepts that patch. This new unconditional rejection therefore lets the UI save a profile that will fail every provisioning attempt; migrate the editor to the setupSecrets workflow or remove the retired input as part of this cutover.
AGENTS.md reference: AGENTS.md:L52-L53
Useful? React with 👍 / 👎.
Skip config cloning when no Crabbox profile needs setupEnv migration. Migrate empty setupEnv lists without invoking the inspection bridge, and defer loading the secret-store owner until a valid store name is selected. Add no-work proof for absent, ordinary, protected, and empty legacy profiles and for empty or unselectable host selections. Doctor E2E comparison (Node 24, matching CI's qaRuntime/prebuilt reader path): - origin/main 82296d5: 5 passed, 140.35 s wall; legacy case 54.730 s. - prior head c048047: 4 passed, 1 timed out, 163.90 s wall; legacy case 63.817 s with its unchanged 30-second limit. - repaired candidate: 5 passed, 100.33 s wall; legacy case 23.670 s. The primary empty-selection regression failed before the repair. Focused migration, egress, and health registration proof: 52 passed, 37.82 s wall. Typecheck, targeted lint, formatting, and fresh scoped review passed. The first cold main attempt stopped in package declaration generation before Vitest started (558.13 s). Matching CI runtime preparation completed separately. The test timings include fixture/module loading and do not establish exclusive timeout causality; no-profile worker registration was already guarded. No timeout was increased. The temporary main worktree was removed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07e012a2ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| !/(?:^|\n)\s+-{1,2}allow-public-destinations(?:\s|$)/u.test(output) || | ||
| !/(?:^|\n)\s+-{1,2}upstream-proxy-env(?:\s|$)/u.test(output) | ||
| ) { | ||
| throw new Error("Setup secrets require native egress; update Crabbox to 0.77.0 or newer"); |
There was a problem hiding this comment.
Install a setup-egress-capable managed Crabbox
When the host has no compatible Crabbox binary, Doctor and automatic repair still install CRABBOX_MIN_VERSION 0.73.0, and an existing 0.73–0.76 binary is considered supported, but this preflight rejects binaries lacking the flags documented as requiring 0.77.0. Consequently, the default repair path leaves every setupSecrets profile unable to provision; raise the managed/minimum version or add a feature-specific repair that installs a compatible release.
AGENTS.md reference: AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
| : await readWorkerProjectEnvironmentRecipe(project, signal) | ||
| : undefined; | ||
| : await readWorkerProjectEnvironmentRecipe(project, signal); | ||
| assertEnvironmentRecipeSecretsMapped(recipe, profile.setupSecrets); |
There was a problem hiding this comment.
Skip secret mapping checks when setup is disabled
When a repository declares devcontainer secrets but the caller explicitly sets runSetupScript: false—or lacks administrator setup authorization—this unconditional check rejects unmapped names even though the branch below deliberately retains an ordinary checkout without executing repository lifecycle commands. Gate this validation on the recipe actually being authorized to run so opting out of setup does not require granting unused secrets.
AGENTS.md reference: AGENTS.md:L83-L83
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d2b7d09c7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "Crabbox prepared workers require warm images and immutable setup inputs without setupEnv", | ||
| ); | ||
| const protectedSetup = Object.keys(parsed.setupSecrets ?? {}).length > 0; | ||
| const project = parsed.warmImage || protectedSetup ? options?.project : undefined; |
There was a problem hiding this comment.
Budget cold project preparation with setup secrets
When a profile combines warmImage: false, setupSecrets, and a prepared project, this now retains the project and runs up to CRABBOX_PROJECT_PREPARATION_TIMEOUT_MS of repository preparation. However, resolveProvisionTimeoutMs still returns zero additional time whenever warmImage is false, and core enforces that returned provider deadline. A slow but otherwise valid cold setup can therefore be aborted before the provider's own setupDeadline; include the project-preparation allowance for protected cold projects without adding the unused capture allowance.
Useful? React with 👍 / 👎.
| z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u), | ||
| z | ||
| .string() | ||
| .max(4096) |
There was a problem hiding this comment.
Accept the supported setup-secret size
When a protected store value is larger than roughly 3 KiB, its base64-encoded sentinel exceeds this 4096-character limit, so repository preparation and post-create/start fail even though the shared store and egress proxy deliberately support values up to 64 KiB (including PEM and service-account credentials). Profile setup bypasses this validator, making the same configured secret work there but fail in repository lifecycle commands; derive this bound from the canonical sentinel/store contract instead of imposing a smaller duplicate limit.
AGENTS.md reference: AGENTS.md:L74-L74
Useful? React with 👍 / 👎.
A live Gateway update on 2026-10-14 silently sent the next cloud session cold: #171073 had (deliberately) changed the warm-image profile fingerprint for every profile, and the only test touching the key asserted that it differed from an old value, never what it is. Golden tests now pin the exact Crabbox warm-image profile key and the preparation and cache keys for one canonical Linux profile without setup secrets, each with a note that changing the value invalidates every user's warm images on update and must be deliberate and explained. Test-only; no production change and no key change. Refs: #171880
…71073) Cloud setup used to forward host environment values through plaintext `setupEnv`, which disabled automatic snapshots and prepared workers. `settings.setupSecrets` replaces it: up to 16 POSIX environment names mapped to protected shared-store SecretRefs. One job-scoped egress owner gives profile setup, recipe preparation and postCreate/postStart commands only sentinels plus public CA trust; Crabbox native egress keeps the authenticated upstream proxy on the Gateway host, allows public HTTPS package downloads, and substitutes each secret only for its store-bound destinations. Grants revoke before process termination on cancellation. Devcontainer `secrets` requests resolve only through the operator-approved map; unmapped requests fail once, before repository commands run. Setup secrets no longer disable snapshots or prepared workers; images captured with protected egress use a distinct compatibility identity, so older plaintext images are never adopted. Requirements: an owned coordinator Linux lease and Crabbox 0.77.0 or newer with its matching runtime helper. Unsupported targets, a missing helper or login, an unavailable proxy, missing bindings and old CLIs fail visibly; there is no plaintext or direct-egress fallback. Update behavior: the Crabbox plugin's Doctor health repair migrates each `setupEnv` profile atomically, and only when every same-name protected store entry already has destination bindings and there is no conflicting host value or mapping. It writes through Doctor's backed-up config writer, never writes store values, never invents destinations, and stays lazy when no profile needs migration. Unrepaired profiles report a remedy (`openclaw doctor --fix`) instead of forwarding plaintext. No SQLite schema change. Merged with main after openclaw#170929 (empty-workspace cloud sessions): empty workspaces still require project-preparation support, so they stay cold on setup-command-only providers. Related: openclaw#170810, openclaw#170862, openclaw#170929 Refs: openclaw#171073
A live Gateway update on 2026-10-14 silently sent the next cloud session cold: openclaw#171073 had (deliberately) changed the warm-image profile fingerprint for every profile, and the only test touching the key asserted that it differed from an old value, never what it is. Golden tests now pin the exact Crabbox warm-image profile key and the preparation and cache keys for one canonical Linux profile without setup secrets, each with a note that changing the value invalidates every user's warm images on update and must be deliberate and explained. Test-only; no production change and no key change. Refs: openclaw#171880
What Problem This Solves
Cloud setup forwarded host environment values through
setupEnv, and those mutable plaintext inputs disabled automatic snapshots and prepared workers. Repository lifecycle commands also ran through a different transport after binding.Related: #170810, #170862. This is the setup-secrets lane of the cloud environment snapshot work.
Solution
Replace plaintext forwarding with
settings.setupSecrets: at most 16 POSIX environment names mapped to protected shared-store SecretRefs. One job-scoped egress owner gives profile setup, recipe preparation, and post-create/start commands only sentinels and public CA trust. Crabbox native egress keeps the authenticated upstream proxy on the Gateway host, permits public HTTPS package downloads, and substitutes each secret only for its store-bound destinations. Grants revoke before process termination on cancellation.Devcontainer
secretsrequests names from the operator-approved map. Unmapped requests produce one error before repository commands. A narrow optional provider lifecycle hook carries the owned workspace/HOME and live attached-lease/repository authority; no-secret commands retain the existing tunnel. Cold profiles with snapshots disabled still prepare protected repository commands. Upgrade admission reparses older cached devcontainer recipes that predate secret requests, then reuses the refreshed parsing facts.Remove the plaintext-based snapshot exclusions. Provider compatibility fingerprints sorted names/references under a distinct protected-egress identity, so older plaintext images cannot be adopted. Capture removes runner-owned CA directories and Crabbox env/script staging; the runner does not rewrite repository tool configuration.
Impact
Setup secrets no longer disable snapshots or prepared workers. Secrets require an owned coordinator Linux lease and Crabbox 0.77.0 or newer with its matching runtime helper. Unsupported targets, missing helper/login, unavailable proxy, missing bindings, and old CLIs fail visibly; there is no plaintext or direct-egress fallback. HTTP clients must honor the proxy and trust environment. Detached processes lose protected access when their lifecycle command finishes. An allowed host can reflect credentials, so bindings must identify trusted services.
Update behavior: the existing plugin Doctor health repair migrates each
setupEnvprofile atomically only when all same-name protected store entries already have destination bindings and no conflicting host value or mapping. Doctor's native backed-up, include-aware writer persists the config. It never writes store values or invents destinations. Existing update budgets may defer that phase with a warning; runopenclaw doctor --fixand repair reported entries afterward. Unrepaired profiles cannot provision. Existing legacy leases remain inspectable/releasable and cannot capture plaintext images. No SQLite DDL or record-format changes.Evidence
Focused tests passed; times below are wall times including repository harness and compiled worker preparation. Earlier runs invalidated by concurrent source edits were discarded, then rerun on settled sources.
Live proof used one owned coordinator AWS Linux lease with Crabbox main at
30150b9aand a matching locally verified runtime pack. A random synthetic protected store entry bound tohttpbin.orgsucceeded through Bearer and Basic auth: HTTP 200 and host-held credential digest matched, without printing the value. Host-side byte inspection of remote setup environment and selected disk files found the sentinel and no real credential. The lease was stopped; inspect confirmedreleased,cleanupStatus: complete, and no possible remaining resource. The temporary test store and local runtime pack were removed. Initial live fixture failures came from its isolated HOME hiding the saved Crabbox login/SSH key; they launched no repository code and were corrected by preserving the credential-owning host child HOME.Independent Codex autoreview: P1 scoped-clean. Touched-file type-aware lint and formatting,
git diff --check,pnpm docs:check-config-examples, andpnpm docs:check-linkspassed. The supportedbuild:ci-artifactsprofile passed runtime, canonical SDK declarations/exports, bootstrap guards, and UI budgets. An earlierpnpm buildwas interrupted after 1608.95 s while emitting untouched workspace package declarations; that full package/release build remains unrun. No budget, baseline, guard, inventory, snapshot cap, or SQLite schema was changed. PR CI supplies broad proof; no full local test suite was run. CI seconds will be available in the exact-head workflow.Release-note context
Cloud worker setup secrets now use destination-bound egress sentinels and remain eligible for snapshots. Repository secret declarations require operator-approved mappings. Doctor migrates eligible
setupEnvprofiles; unsupported or unrepaired profiles report a remedy instead of forwarding plaintext.