secrets
openclaw secrets
Section titled “openclaw secrets”Use openclaw secrets to manage SecretRefs and keep the active runtime snapshot healthy.
Command roles:
reload: gateway RPC (secrets.reload) that re-resolves refs and swaps runtime snapshot only on full success (no config writes).audit: read-only scan of configuration/auth/generated-model stores and legacy residues for plaintext, unresolved refs, and precedence drift (exec refs are skipped unless--allow-execis set).configure: interactive planner for provider setup, target mapping, and preflight (TTY required).apply: execute a saved plan (--dry-runfor validation only; dry-run skips exec checks by default, and write mode rejects exec-containing plans unless--allow-execis set), then scrub targeted plaintext residues.
Recommended operator loop:
openclaw secrets audit --checkopenclaw secrets configureopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --dry-runopenclaw secrets apply --from /tmp/openclaw-secrets-plan.jsonopenclaw secrets audit --checkopenclaw secrets reloadIf your plan includes exec SecretRefs/providers, pass --allow-exec on both dry-run and write apply commands.
Exit code note for CI/gates:
audit --checkreturns1on findings.- unresolved refs return
2.
Related:
- Secrets guide: Secrets Management
- Credential surface: SecretRef Credential Surface
- Security guide: Security
Reload runtime snapshot
Section titled “Reload runtime snapshot”Re-resolve secret refs and atomically swap runtime snapshot.
openclaw secrets reloadopenclaw secrets reload --jsonNotes:
- Uses gateway RPC method
secrets.reload. - If resolution fails, gateway keeps last-known-good snapshot and returns an error (no partial activation).
- JSON response includes
warningCount.
Scan OpenClaw state for:
- plaintext secret storage
- unresolved refs
- precedence drift (
auth-profiles.jsoncredentials shadowingopenclaw.jsonrefs) - generated
agents/*/agent/models.jsonresidues (providerapiKeyvalues and sensitive provider headers) - legacy residues (legacy auth store entries, OAuth reminders)
Header residue note:
- Sensitive provider header detection is name-heuristic based (common auth/credential header names and fragments such as
authorization,x-api-key,token,secret,password, andcredential).
openclaw secrets auditopenclaw secrets audit --checkopenclaw secrets audit --jsonopenclaw secrets audit --allow-execExit behavior:
--checkexits non-zero on findings.- unresolved refs exit with higher-priority non-zero code.
Report shape highlights:
status:clean | findings | unresolvedresolution:refsChecked,skippedExecRefs,resolvabilityCompletesummary:plaintextCount,unresolvedRefCount,shadowedRefCount,legacyResidueCount- finding codes:
PLAINTEXT_FOUNDREF_UNRESOLVEDREF_SHADOWEDLEGACY_RESIDUE
Configure (interactive helper)
Section titled “Configure (interactive helper)”Build provider and SecretRef changes interactively, run preflight, and optionally apply:
openclaw secrets configureopenclaw secrets configure --plan-out /tmp/openclaw-secrets-plan.jsonopenclaw secrets configure --apply --yesopenclaw secrets configure --providers-onlyopenclaw secrets configure --skip-provider-setupopenclaw secrets configure --agent opsopenclaw secrets configure --jsonFlow:
- Provider setup first (
add/edit/removeforsecrets.providersaliases). - Credential mapping second (select fields and assign
{source, provider, id}refs). - Preflight and optional apply last.
Flags:
--providers-only: configuresecrets.providersonly, skip credential mapping.--skip-provider-setup: skip provider setup and map credentials to existing providers.--agent <id>: scopeauth-profiles.jsontarget discovery and writes to one agent store.--allow-exec: allow exec SecretRef checks during preflight/apply (may execute provider commands).
Notes:
- Requires an interactive TTY.
- You cannot combine
--providers-onlywith--skip-provider-setup. configuretargets secret-bearing fields inopenclaw.jsonplusauth-profiles.jsonfor the selected agent scope.configuresupports creating newauth-profiles.jsonmappings directly in the picker flow.- Canonical supported surface: SecretRef Credential Surface.
- It performs preflight resolution before apply.
- If preflight/apply includes exec refs, keep
--allow-execset for both steps. - Generated plans default to scrub options (
scrubEnv,scrubAuthProfilesForProviderTargets,scrubLegacyAuthJsonall enabled). - Apply path is one-way for scrubbed plaintext values.
- Without
--apply, CLI still promptsApply this plan now?after preflight. - With
--apply(and no--yes), CLI prompts an extra irreversible confirmation.
Exec provider safety note:
- Homebrew installs often expose symlinked binaries under
/opt/homebrew/bin/*. - Set
allowSymlinkCommand: trueonly when needed for trusted package-manager paths, and pair it withtrustedDirs(for example["/opt/homebrew"]). - On Windows, if ACL verification is unavailable for a provider path, OpenClaw fails closed. For trusted paths only, set
allowInsecurePath: trueon that provider to bypass path security checks.
Apply a saved plan
Section titled “Apply a saved plan”Apply or preflight a plan generated previously:
openclaw secrets apply --from /tmp/openclaw-secrets-plan.jsonopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --allow-execopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --dry-runopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --dry-run --allow-execopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --jsonExec behavior:
--dry-runvalidates preflight without writing files.- exec SecretRef checks are skipped by default in dry-run.
- write mode rejects plans that contain exec SecretRefs/providers unless
--allow-execis set. - Use
--allow-execto opt in to exec provider checks/execution in either mode.
Plan contract details (allowed target paths, validation rules, and failure semantics):
What apply may update:
openclaw.json(SecretRef targets + provider upserts/deletes)auth-profiles.json(provider-target scrubbing)- legacy
auth.jsonresidues ~/.openclaw/.envknown secret keys whose values were migrated
Why no rollback backups
Section titled “Why no rollback backups”secrets apply intentionally does not write rollback backups containing old plaintext values.
Safety comes from strict preflight + atomic-ish apply with best-effort in-memory restore on failure.
Example
Section titled “Example”openclaw secrets audit --checkopenclaw secrets configureopenclaw secrets audit --checkIf audit --check still reports plaintext findings, update the remaining reported target paths and rerun audit.