Skip to content

feat(secrets): add scoped setup egress grants - #170810

Merged
steipete merged 2 commits into
mainfrom
snap/secret-jobs
Oct 13, 2026
Merged

steipete merged 2 commits into
mainfrom
snap/secret-jobs

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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 their allowed_hosts policy. 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, and Proxy-Authorization remains 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 remoteEnv from host-only authenticated hostEnv, returns public CA contents and synchronous revoke(), and joins proxy shutdown before removing CA files. Abort fencing precedes termination listeners registered inside the callback. Expose withSetupSecretEgress through the existing private official-plugin secret-egress-runtime facade; 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):

Command Wall time Result
pnpm test src/secrets/egress-proxy/proxy-server.test.ts --maxWorkers=1 267.97 s 35 passed
pnpm test src/secrets/job-egress.test.ts src/secrets/model-egress.test.ts src/secrets/egress-proxy/proxy-worker.test.ts --maxWorkers=1 340.74 s 24 passed; setup proof repeated through the SDK below
pnpm test src/secrets/store/secret-store-metadata.worker.test.ts src/secrets/job-egress.test.ts --maxWorkers=1 197.53 s 13 passed, including real store reads and SDK lifecycle
pnpm tsgo 378.30 s passed
node 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.ts 386.74 s passed
GOMAXPROCS=2 pnpm build:runtime 510.69 s passed, including existing UI budgets

Also passed: pnpm format:check for all 15 changed files, pnpm plugin-sdk:check-exports, pnpm plugin-sdk:surface:check, pnpm docs:check-links (0 broken links), and git 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 full installed 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.

@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T08:53:33.826183Z d5f6427 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: d5f6427443a309a8642a078634781309f43fc22c
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/secrets/egress-proxy/proxy-server.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/job-egress.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/model-egress.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/store/secret-store-metadata.kernel.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/store/secret-store.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/store/secret-store.types.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime plugin: file-transfer size: L and removed security-sensitive-changed labels Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/secrets/job-egress.ts
Comment on lines +80 to +83
if (ref.source !== "store") {
throw new Error("Setup egress requires shared-store SecretRefs");
}
return { envName, name: ref.id };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@steipete
steipete merged commit 4e3e64e into main Oct 13, 2026
124 checks passed
@steipete
steipete deleted the snap/secret-jobs branch October 13, 2026 09:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
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
steipete added a commit that referenced this pull request Oct 14, 2026
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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime plugin: file-transfer security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant