Credential vault (Preview)
Keep the secrets your sandboxed agents need in a vault bound to the one host each may go to, so the agent sees only a placeholder. Preview.
Preview
The credential vault is a preview feature of OpenShell sandboxes on Linux and macOS, for per-user installs and managed computers.
Coding agents leak credentials because they hold them: a key in the agent's environment can end up in the model's context, a transcript, a file or a commit. The vault keeps your secrets out of the agent's reach.
Each secret is bound to the one host it may be sent to. A sandbox started with --vault NAME gives the agent only a placeholder in $NAME. OpenShell puts the real value in on the way out, to that host only.
run --vault: value and host
placeholder in $STRIPE_API_KEY
request with the placeholder
swaps in the real value, bound host only
request with the real value
Text version of this diagram
Participants
- Your vault (data store). Keeps each secret with the one host it may be sent to. Readable by your account only, and never mounted into a sandbox.
- Agent (agent). The coding agent in the sandbox. It sees a placeholder in $STRIPE_API_KEY and never the value.
- OpenShell (component). Holds the real value outside the agent's reach and puts it into requests for the bound host.
- api.stripe.com (external service). The host the secret is bound to, and the only place its value is sent.
Messages, in order
- Your vault to OpenShell (async): run --vault: value and host
- OpenShell to Agent (async): placeholder in $STRIPE_API_KEY
- Agent to OpenShell: request with the placeholder
- Note on OpenShell: swaps in the real value, bound host only
- OpenShell to api.stripe.com: request with the real value
Before you start
- Sandboxes are set up on Linux or macOS.
- Only terminal agents that run in a sandbox can use the vault: Claude Code, Codex, Copilot CLI, OpenCode, Kiro, Hermes and Antigravity's
agy. Desktop apps and IDE agents do not run in an OpenShell sandbox.
Add a secret
defenseclaw sandbox vault add STRIPE_API_KEY --host api.stripe.comThe value is typed with echo off. To pipe it instead:
printf '%s\n' "$VALUE" | defenseclaw sandbox vault add STRIPE_API_KEY --host api.stripe.com --value-stdinNAME is the environment variable the sandbox sees. --host is the only host the value is ever sent to: a host name, with :port when it is not 443. URLs, paths and wildcards are refused.
Use it in a sandbox
defenseclaw sandbox run claude --vault STRIPE_API_KEY--vault takes one name and repeats. The run's banner lists each secret and its host on the Secret line. Inside the sandbox the agent uses the variable as usual ($STRIPE_API_KEY in a header). It never holds the value.

- A secret works only against its host. Sent anywhere else, the placeholder is a meaningless string.
- Do not let the agent print the variable. OpenShell refuses every request whose body carries a placeholder, so once a placeholder lands in the conversation (the agent ran
env, say), later model calls of that conversation fail. Start a new conversation withdefenseclaw sandbox connect NAME. - A sandbox keeps the secrets it was created with. To give it a new or replaced secret, delete it and start a new one.
Check it worked
defenseclaw sandbox vault list shows the secret with its host and when a sandbox last used it.
Secrets DefenseClaw captures for you
When a secret with a well-known shape shows up in any hook call of a sandboxed agent (your prompt, a tool call, a tool's output, the agent's reply), DefenseClaw moves it into your vault. The value is removed from the call before DefenseClaw checks, records or forwards it.
| Kind | Vault name | Bound to |
|---|---|---|
| Anthropic API key | ANTHROPIC_API_KEY | api.anthropic.com |
| OpenAI API key | OPENAI_API_KEY | api.openai.com |
| GitHub token (classic or fine-grained) | GITHUB_TOKEN | api.github.com (gh and the API; git push over HTTPS goes to github.com and is not covered) |
| Slack token | SLACK_TOKEN | slack.com |
| Stripe live secret key | STRIPE_API_KEY | api.stripe.com |
| Google API key | GOOGLE_API_KEY | no host: bind one before use |
A second, different secret of the same kind gets _2, _3 and so on. AWS access keys are not captured: AWS signs each request with the key, which a placeholder swap cannot do.
Every captured secret starts unconfirmed, and no sandbox gets it until you run defenseclaw sandbox vault confirm NAME. An agent in a sandbox can make a call that looks like your prompt, so a captured value may be one it planted. confirm shows where the secret came from and the last 4 characters of its value before it asks.
What happens where the secret shows up
| Where | What happens | What you do |
|---|---|---|
| A prompt that is stopped (Claude Code, Codex) | The prompt is stopped before it reaches the model. The secret stays unconfirmed. Claude Code puts the prompt back in its input box. | Delete the value and send the prompt again. Confirm the secret and start a sandbox with --vault NAME to let the agent use it. The agent's session log still holds the stopped prompt, so delete the sandbox when you are done. |
| A prompt that reaches the model (Copilot CLI, Hermes, Kiro) | Their hooks cannot keep a prompt from the model, so the secret is marked exposed: rotate. The agent is told not to use it where the agent allows that. | Rotate it with its issuer, then run defenseclaw sandbox vault replace NAME. |
| A tool call | The tool call is stopped. The model wrote the value, so the secret is marked exposed: rotate. | Rotate it and run vault replace NAME (the same value is refused). A sandbox started with it before keeps it until you delete that sandbox. |
| A tool's output | The model has read the value, so it is marked exposed: rotate, including a key a command put together as it ran. Where the hook can answer the model, the agent is told not to reuse it; elsewhere DefenseClaw raises an alert. | Rotate it and run vault replace NAME. |
| The agent's reply or another hook event | The value is removed from what DefenseClaw records and passes on. A secret the vault already holds is marked exposed: rotate. A value the vault does not hold is not stored. | Rotate it with its issuer. |
Only a value written out in a tool call is seen. A command that makes up a value as it runs (from /dev/urandom, say) or builds it from parts is not; the value is captured, marked exposed, when it shows up in the tool's output.
In observe mode nothing is stopped: a secret is still moved into the vault and reported, and a prompt that goes on to the model is marked exposed: rotate.


Where each agent captures
| Agent | Prompt | Tool call (stopped, exposed) | Tool output (exposed) |
|---|---|---|---|
| Claude Code | stopped, unconfirmed | PreToolUse, PermissionRequest | PostToolUse (answered block), PostToolBatch, PostToolUseFailure |
| Codex | stopped, unconfirmed | PreToolUse, PermissionRequest | PostToolUse (answered block) |
| Copilot CLI | exposed (userPromptSubmitted) | preToolUse, permissionRequest | postToolUse, postToolUseFailure |
| OpenCode | no prompt hook | tool.execute.before | tool.execute.after |
| Hermes | exposed (pre_llm_call) | pre_tool_call | post_tool_call, transform_tool_result |
| Kiro | exposed (userPromptSubmit) | preToolUse | postToolUse |
Antigravity (agy) | not sent to hooks | PreToolUse | not sent to hooks |
Capture in Kiro and Antigravity is in Preview. Antigravity's hooks receive neither your prompt nor a tool's output, so a secret there is captured only when the model writes it into a tool call. Amp, Cursor Agent and Devin CLI do not run in a sandbox yet, so they cannot use the vault.
Turn capture off
Set openshell.vault.auto_capture: false (configuration). On a managed computer your administrator's setting applies.
See and change your secrets
defenseclaw sandbox vault list
Values are never printed. The sandbox CLI reference has every flag.
| Command | What it does |
|---|---|
vault show NAME | One secret's details. |
vault confirm NAME | Accepts a captured secret. |
vault replace NAME | Sets a new value. |
vault bind NAME | Sets the host. |
vault rename NAME | Changes the variable name. |
vault remove NAME | Deletes it. |
A sandbox keeps the secrets it was created with. If you later replace, rebind or remove one of them, or it is marked exposed, that sandbox is not started again (start, connect or a new run in its folder): delete it and start a new one.

On a per-user install, the TUI's Vault tab (K) shows the same list and makes the same changes: a add, v replace value, e set host, n rename, d delete, Enter details. A value is typed in a hidden field and goes to the command on standard input. On a managed computer defenseclaw tui is not available; use defenseclaw sandbox vault there (Managed command availability).

In the macOS app, the Sandboxes view has a Vault (Preview) card with the same list and changes: Add…, Replace value…, Set host…, Rename…, Remove… and Confirm…. A value is typed in a hidden field and goes to the command on standard input.
The app does not show the last 4 characters of a captured secret: run defenseclaw sandbox vault confirm NAME in Terminal to see them. If a command refuses on a managed computer, the card says so; run defenseclaw sandbox vault list in Terminal to see why (Managed command availability).
Where the vault lives
| Install | Vault file |
|---|---|
| Per-user (Linux, macOS) | ~/.defenseclaw/vault/vault.json |
| Managed computer, Linux | ~/.local/state/defenseclaw-sandbox/vault/vault.json |
| Managed computer, macOS (Preview) | ~/Library/Application Support/DefenseClaw Sandbox/vault/vault.json |
The directory is readable by your account only (mode 0700, the file 0600), and the vault is never mounted into a sandbox. On a managed computer the managed gateway never receives a value. While capture is on, a sandboxed harness's own telemetry and notify calls are masked the same way (Codex sends the prompt in its telemetry).
DefenseClaw encrypts each value with a key in your macOS Keychain or Secret Service keyring when one is usable. vault list says how the vault is kept on its first line. How sealing works, and what it protects, is in Vault sealing.
Undo
defenseclaw sandbox vault remove NAME deletes a secret. Delete the sandboxes that hold it with defenseclaw sandbox delete NAME.
Limits
- The vault serves sandboxes only. An agent outside a sandbox gets nothing from it.
- Secrets are your own. Your administrator's floor (
allowed_credentials, the egress rules) applies to vault secrets exactly as to--credential. - A host that echoes the
Authorizationheader back would return the value to the agent. Bind secrets to the API host itself. - Any program in the sandbox can use a secret against its host.
- A test fixture that looks exactly like a real key (the right prefix and length) is captured as one. Give fixtures an obviously fake shape.
- Each sandbox keeps at most 8 unconfirmed secrets from its prompts and 8 unreplaced ones from its tool calls and output. All captures together stop at 48, so at least 16 entries always stay for secrets you add yourself. A program in a sandbox can fill only that sandbox's room. Past a limit the call is still answered and the value removed, but nothing more is stored until you confirm, replace or remove some (
vault listshows the sandbox each came from).
Next
- Vault sealing: how values are encrypted and what that protects.
- Give the agent a project secret for one run
Network and egress
Learn how DefenseClaw's egress proxy decides each site a sandboxed agent contacts: open, balanced and strict profiles, blocklist, unblocks and asks.
Vault sealing (Preview)
Learn how the sandbox credential vault seals each value with a macOS Keychain or Secret Service key, what the seal pin checks and covers. Preview.