Repository navigation
feat(secrets): add scoped setup egress grants - #170810
Conversation
|
🦞👀 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: 0f64db3e01
ℹ️ 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 (ref.source !== "store") { | ||
| throw new Error("Setup egress requires shared-store SecretRefs"); | ||
| } | ||
| return { envName, name: ref.id }; |
There was a problem hiding this comment.
Validate the SecretRef provider before reading the store
When an official plugin supplies a store ref whose provider is missing or configured for another source—for example { source: "store", provider: "vault", id: "TOKEN" } when vault is an exec provider—this path ignores ref.provider and grants the team-store TOKEN. Normal SecretRef resolution rejects unconfigured and source-mismatched providers, so bypassing that owner can disclose a different credential than the reference identifies; pass configuration through the canonical provider validation or narrow this API to an explicitly provider-free store selector.
AGENTS.md reference: AGENTS.md:L74-L74
Useful? React with 👍 / 👎.
|
Merged via squash.
|
Repository setup needs protected shared-store credentials through egress without copying plaintext into a remote environment or reusable image. The previous exec reader loaded all eligible entries, Basic authentication encoded sentinels before the proxy could recognize them, and model egress owned a separate proxy lifecycle. Select only named, live team-store secret rows and their allowed_hosts policy through the existing read worker, preserving admission and size limits without adding main-thread SQL or schema changes. Decode sentinel-bearing origin Authorization: Basic credentials, validate their shape, authorize each sentinel for the destination, and re-encode after substitution. Ordinary Basic headers remain unchanged. Other base64 headers and bodies are not decoded, and Proxy-Authorization is removed before forwarding. Share one worker-owned job lifecycle between setup and configured-model egress. Register only selected secrets, separate remoteEnv from host-only authenticated hostEnv, revoke grants on cancellation, and join proxy shutdown before removing CA files. Expose setup egress through the existing private official-plugin secret-egress-runtime facade. No config keys, stored-record formats, SQLite DDL, or data migrations change. This is the Gateway foundation; cloud-profile setup cutover and the packaged remote bridge remain separate work. Validation: focused proxy, setup/model lifecycle, worker, and selected-store integration tests; types, targeted lint/format, runtime build, SDK exports/surface, docs links; exact-head CI and independent scoped-clean review. Refs: openclaw#170810
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 #170929 (empty-workspace cloud sessions): empty workspaces still require project-preparation support, so they stay cold on setup-command-only providers. Related: #170810, #170862, #170929 Refs: #171073
…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
Problem
What Problem This Solves
Repository setup needs to use protected shared-store credentials through egress without copying plaintext into a remote environment or image. The existing exec reader loads all eligible store entries, and origin HTTP Basic authentication encodes sentinels before the proxy can recognize them. Standalone model egress also owns a separate in-process proxy lifecycle.
Solution
Add a selected-secret read operation to the existing shared-state read worker. One SQL statement selects only named, live team-store
kind: "secret"rows with theirallowed_hostspolicy. It preserves existing size limits and admission checks without adding main-thread SQL or schema changes.Decode only origin
Authorization: Basic ...credentials containing sentinels, validate their encoding and credential shape, authorize each sentinel for the destination, and re-encode after substitution. Ordinary Basic headers stay unchanged. Other base64 headers and bodies are not decoded, andProxy-Authorizationremains proxy authentication and is removed before forwarding.Introduce one worker-owned job lifecycle shared by setup and configured-model egress. It seals and registers only selected values, separates
remoteEnvfrom host-only authenticatedhostEnv, returns public CA contents and synchronousrevoke(), and joins proxy shutdown before removing CA files. Abort fencing precedes termination listeners registered inside the callback. ExposewithSetupSecretEgressthrough the existing private official-pluginsecret-egress-runtimefacade; its integration tests call that facade.Impact
Destination-bound Basic credentials now work through secret egress. Official setup callers can request multiple shared-store secrets for one revocable job without loading or registering unrelated credentials. Configured model commands retain their route, output-redaction, and cancellation contracts while moving network work into the existing proxy worker.
Update behavior: no config keys, Doctor transforms, SQLite DDL, stored-record formats, or data migrations change. Existing global egress settings retain their behavior. This is the Gateway foundation only: the cloud profile key and setup-runner cutover follow separately, as does the packaged remote bridge helper. No Crabbox worker or UI changes are included.
Evidence
Focused proof (wall times include worker compilation, artifact-lock waits, and contention on the shared local host):
pnpm test src/secrets/egress-proxy/proxy-server.test.ts --maxWorkers=1pnpm test src/secrets/job-egress.test.ts src/secrets/model-egress.test.ts src/secrets/egress-proxy/proxy-worker.test.ts --maxWorkers=1pnpm test src/secrets/store/secret-store-metadata.worker.test.ts src/secrets/job-egress.test.ts --maxWorkers=1pnpm tsgonode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/plugin-sdk/secret-egress-runtime.ts src/secrets/egress-proxy/proxy-server.test.ts src/secrets/egress-proxy/proxy-server.ts src/secrets/egress-proxy/proxy-worker.test.ts src/secrets/job-egress.test.ts src/secrets/job-egress.ts src/secrets/model-egress.test.ts src/secrets/model-egress.ts src/secrets/store/secret-store-metadata.kernel.ts src/secrets/store/secret-store-metadata.worker.test.ts src/secrets/store/secret-store.ts src/secrets/store/secret-store.types.tsGOMAXPROCS=2 pnpm build:runtimeAlso passed:
pnpm format:checkfor all 15 changed files,pnpm plugin-sdk:check-exports,pnpm plugin-sdk:surface:check,pnpm docs:check-links(0 broken links), andgit diff --check. Independent Codex autoreview found no actionable P0–P2 findings. The existing private SDK entrypoint remains private; no public API baseline changes are needed.Security proof covers wrong hosts, unregistered and tampered sentinels, raw/malformed Basic credentials, revoked grants, redirected destinations, multi-secret registration, cancellation during registration, sibling-grant isolation, and host proxy credentials absent from remote env. The selected-reader regression took 3.61 s of test execution on the busy host; it needs real workers to prove caller-thread SQL exclusion. Other time in the store suite comes from existing broker/SQLite integration fixtures. No new timers, sleeps, Gateway boots, serial configs, or budget exceptions were added. CI timing is pending attachment to this head.
Preparation notes:
node scripts/worktree-setup.mjs fullinstalled dependencies, but its broad package declaration phase was canceled after 21m15s on an overloaded host; the supported runtime build above passed. Initial fixture failures (a Unicode raw bearer header and a thread-lane test lacking the host broker) were corrected. One store rerun correctly stopped when lint edits changed compiled-worker inputs; the final stable-source invocation passed. No leases were used. Integrated live AWS proof belongs to the lead's later combined campaign.Release-note context
Protected secret egress supports destination-authorized HTTP Basic credentials and selected multi-secret setup jobs, with host-only credentials and cancellation revocation shared with model egress. This supplies the Gateway capability for setup secrets that can stay opaque in reusable cloud images.