These credential stores and authentication flows apply to local sandboxes. Cloud credentials require separate setup: see Authenticate cloud agents .
Most agents need an API key for their model provider. An HTTP/HTTPS proxy on your host intercepts outbound requests from the sandbox, looks up the matching credential on the host, and overwrites the auth header on HTTPS requests before forwarding. The real credential stays on the host when proxy management is active; the sandbox sees only a sentinel value. See Trust boundaries for how credential isolation fits into the broader sandbox security model.
How credential injection works
When a sandbox makes an outbound request, the host-side proxy decides three things: whether the request matches a service the kit (or built-in agent) declares, what header to write, and what value to inject. The kit declares the match and the header; you provide the value on the host. For proxy-managed credentials, the real value never enters the sandbox — the agent sees only a sentinel like proxy-managed .
Use HTTPS for external endpoints that rely on host-credential injection, including API keys, OAuth tokens, registry credentials, and custom secrets. Ordinary HTTP requests still follow network policy, but the proxy forwards them without substituting host credentials. Credentials supplied directly by the client aren't stripped from these requests.
Managed OAuth token exchanges also require HTTPS. The proxy rejects plaintext token exchanges with HTTP 403 before forwarding them, for both initial sign-in and token refresh. If your endpoint uses HTTP, switch its URL to HTTPS.
A kit can set OAuth passthrough: true to opt out of sentinel masking. This sends the real token response into the sandbox and reduces credential isolation. See the oauth kit fields .
There are several ways to provide that value. When more than one source has a value for the same service, the stored secret takes precedence.
Providing a value and approving its use are separate steps. Credential bindings record which mechanisms and domains you authorize a kit to use. They don't store the credential value.
For multi-provider agents (OpenCode, Docker Agent), the proxy selects credentials based on the API endpoint being called. See individual agent pages for provider-specific details.
sbx secret set stores credential values or dynamic secret sources in your OS keychain, keyed on a service identifier. Built-in agents declare a fixed set of services. Custom kits can declare their own. The same sbx secret set flow works for both.
Secrets whose names start with mcp: are reserved for the host's MCP gateway . See MCP secrets for how these differ from agent and provider credentials.
Where secrets are stored
The store backing sbx secret set depends on your operating system:
macOS: the system Keychain.
Windows: the Windows Credential Manager.
Linux: the Secret Service exposed by your desktop keyring, such as GNOME Keyring or KDE Wallet.
The Ubuntu package recommends GNOME Keyring and installs it by default. You can omit GNOME Keyring when installing the package on hosts without a desktop keyring.
On Linux hosts without a running Secret Service — headless servers and some WSL setups — sbx falls back to a file under your user config directory $XDG_CONFIG_HOME/com.docker.sandboxes , which defaults to ~/.config/com.docker.sandboxes when $XDG_CONFIG_HOME is unset. The fallback is automatic and needs no configuration. When running as root, sbx ignores XDG_CONFIG_HOME and uses ~/.config/com.docker.sandboxes under root's registered directory. See Storage paths when running as root .
When you store a secret this way, sbx prints a notice:
sbx stores the file in a directory with 0700 permissions, the same file-permission model used for ~/.docker/config.json . Any user or process that can read the file can retrieve the stored credentials, so treat the directory as sensitive. Where available, prefer a keychain, which mediates access per application.
If you start a Secret Service on the host later, sbx stores new secrets in the keychain again. For more on running sandboxes without a desktop keyring, see Can I use Docker Sandboxes on headless Linux?
This prompts you for the secret value interactively. Service secrets are global by default, so the secret is available to all sandboxes. To scope a secret to a specific sandbox instead:
Adding, updating, or removing a service secret takes effect in existing local sandboxes without a restart, including secrets configured with --command or --ref . Sandbox-scoped secrets take precedence over global secrets.
The MCP gateway uses the same host credential store for OAuth client secrets and custom request header secrets. These records have names starting with mcp: and appear in sbx secret ls . They stay on the host and aren't injected into sandboxes. The gateway uses them to authenticate connections to MCP servers on behalf of sandboxed agents.
For setup instructions, see OAuth client secrets and custom request headers . Header secrets use the global scope and have their own restart requirements .
Use a dynamic secret source
Dynamic secret sources let sbx retrieve a credential from an authenticated host tool when the proxy needs it. The secret store contains the reference or command instead of the credential value. Resolution and caching happen on the host, and the sandbox still receives only the proxy-managed placeholder.
Use --ref with a 1Password secret reference or an AWS Secrets Manager ARN:
The corresponding op or aws CLI must be installed and authenticated on the host, with its installation directory listed as an absolute path in the host's PATH . Built-in reference providers ignore empty and relative PATH entries.
Each reference resolution runs the provider CLI in a fresh temporary directory on the host, outside the project directory. Use absolute paths for any provider configuration files you specify. If you use a version manager such as asdf or mise, configure the provider version globally rather than relying on a project-only selection. Keep provider tools, their dependencies, and the host's temporary directory outside writable sandbox mounts.
Note To resolve a reference with a specific 1Password account or AWS profile, set OP_ACCOUNT or AWS_PROFILE when you run sbx secret set . sbx uses that account or profile whenever it resolves the secret. If neither variable is set, the provider CLI uses its default.
To resolve a reference with a specific 1Password account or AWS profile, set OP_ACCOUNT or AWS_PROFILE when you run sbx secret set . sbx uses that account or profile whenever it resolves the secret. If neither variable is set, the provider CLI uses its default.
Use --command for another host tool that prints a secret to standard output:
sbx runs the command through the host shell and trims its output. The command text is stored and replayed by the daemon. Don't embed a secret directly in the command because the text can appear in shell history and process listings.
Secret commands run from a fresh temporary directory on the host during verification and refresh. Relative paths such as ./credential-helper resolve from that temporary directory. This applies to both sbx secret set --command and sbx secret set-custom --command .
Store helpers and any code or configuration they load outside writable sandbox mounts. Run a helper by name from an absolute directory on the host's PATH , use its absolute path, or explicitly change to its private directory in the command. Keep the host's temporary directory outside writable sandbox mounts as well.
Resolved service secrets are cached for 55 minutes by default. To change the cache duration, use --refresh . To resolve the source for every credential use instead of caching it, pass --refresh on-demand :
--ref and --command are mutually exclusive. They can't be combined with --token , --oauth , or --registry .
Import from environment variables
If you already have API keys set in your shell, sbx secret import reads them and stores them in the keychain without typing each value manually:
This scans your current session for the environment variables in the built-in services table below and prompts you to confirm each one before writing. To import a single service:
Pass --all to import everything without prompting (new entries only; existing entries are left unchanged), or --force to overwrite existing entries:
Pass --dry-run to preview what would be imported without writing anything. Run sbx secret ls afterwards to confirm what's stored. For setting up credentials in CI, see CI and headless use .
Each built-in service name maps to the environment variables sbx secret import reads and the API domains the proxy injects credentials into:
When you store a secret with sbx secret set , the proxy injects it into requests to the listed API domains.
Services declared by kits
Use the service identifier from the kit's documentation when storing its credential. For a kit that declares my-service , run:
There's no separate registration step. The stored value and the kit's request use the same identifier. Approve the kit's credential request when prompted. See Credential bindings .
When authoring a kit, declare how it uses that service. V3 uses a credential capability, and v2 uses a top-level credentials list. Both examples declare the service and permit access to its API host:
For API keys, specify both the HTTP header and its value format, as in this example. sbx doesn't use apiKey.inject[].scheme in v3 kits.
For OAuth, use JSON credential files and a provider that returns the refresh token in refresh_token . sbx doesn't support TOML credential files or a different refresh-token field.
Credentials declared for the install phase are available during install hooks. Add the domains that receive these credentials to the network policy's install.allow list. An entry in runtime.allow alone doesn't grant access during installation. If a hook reads a credential environment variable, include that name in its env list.
In sbx , the proxy stops injecting credentials into install-only domains before the agent launches. A domain remains available for credential injection if any runtime credential targets it, even under a different service name. If you declare the same service for both phases, sbx uses the runtime declaration's credential settings in both phases.
Each service declares apiKey , oauth , or both. When both resolve at runtime, the API key takes precedence and OAuth acts as the fallback. For complete kit-side configuration, see V3 credential definition or V2 credentials .
List and remove secrets
List all stored secrets:
To remove a sandbox-scoped secret, pass --sandbox :
Removing a sandbox-scoped secret restores the global secret for that service, if one is available.
Note Running sbx reset deletes all stored secrets along with all sandbox state. You'll need to re-add your secrets after a reset.
Running sbx reset deletes all stored secrets along with all sandbox state. You'll need to re-add your secrets after a reset.
The github service gives the agent access to the gh CLI inside the sandbox. Resolve your existing GitHub CLI token on the host:
The daemon refreshes the token from the host command after the default cache period. This is useful for agents that create pull requests, open issues, or interact with GitHub APIs on your behalf.
SSH agent forwarding is enabled by default. V3 kits must also request ssh-agent@1 for the phase where they need it. Without that request, no agent socket is forwarded to a v3 sandbox.
When SSH_AUTH_SOCK is set, Docker Sandboxes uses the value from the client that creates, starts, or joins each sandbox. It forwards that agent into the sandbox and sets SSH_AUTH_SOCK there.
If your agent exposes a stable socket path, such as the 1Password SSH agent, configure that path for every sandbox:
An empty ssh.agentSocketPath , which is the default, uses the agent supplied by each client instead. Use ssh.agentForwardingEnabled to turn forwarding on or off.
After changing forwarding or the socket selection, restart the daemon so existing sandboxes use the new configuration:
The private keys stay on your host. Processes inside the sandbox can request signatures from the forwarded agent, but they can't read or copy a private key.
Use SSH agent forwarding for Git operations over SSH and SSH-based commit signing. The signing key must be loaded in the host SSH agent for sandboxed commit signing to work. Outbound SSH connections are still subject to sandbox network policy. For details, see Commit signing .
Important Custom secrets are experimental. Behavior, flags, and the placeholder format may change without notice.
Custom secrets are experimental. Behavior, flags, and the placeholder format may change without notice.
For credentials that don't fit the service-identifier model — for example, when an agent validates the environment variable format at boot — use sbx secret set-custom . The secret is keyed on one or more target domains, an environment variable name, and an optional placeholder string, instead of a service identifier.
Prefer the service-based flow whenever it's an option — the kit handles the wiring; you only provide the value.
Custom secrets are global by default. Pass --sandbox to scope one to a specific sandbox. Values must be at least eight characters long, including values returned by dynamic sources. Existing shorter values aren't substituted and must be replaced with longer values.
To read the value from standard input, set API_KEY in your host environment and pipe it with --value-stdin :
This keeps the value out of the sbx command arguments. Omit --value-stdin to enter the value at a prompt instead. --value-stdin can't be combined with --value , --token , --ref , or --command .
Warning Passing a literal secret with --value or --token records it in shell history and exposes it in process arguments. Expanding an environment variable with --value "$API_KEY" still exposes the value in process arguments. Use the prompt or standard input instead.
Passing a literal secret with --value or --token records it in shell history and exposes it in process arguments. Expanding an environment variable with --value "$API_KEY" still exposes the value in process arguments. Use the prompt or standard input instead.
Inside the sandbox, API_KEY is set to a generated placeholder (for example, sbx-cs- ). When a sandboxed process sends a request to any of the configured hosts over HTTPS and the placeholder appears in a request header configured for that secret, the proxy replaces it with the real value. Replacement applies only to those request headers, not request bodies.
Choose request headers
Use --header to name the header your service reads. Repeat the flag to bind the secret to more than one header. In other headers, the placeholder is sent unchanged.
Without --header , local custom secrets, including existing secrets without header bindings, use the headers listed in secret.custom.defaultHeaders . If your service uses another header, bind it explicitly.
Cloud custom secrets use Authorization by default instead; see cloud credentials .
To change a secret's header bindings, find its placeholder with sbx secret ls , then update only its headers:
For a sandbox-scoped secret, include --sandbox . This keeps the value, hosts, environment variable, and dynamic source unchanged. Setting the secret again without --header preserves its existing header bindings. Alternatively, change the default-header setting for all secrets that follow it.
Header names are case-insensitive. The CLI rejects invalid names and headers controlled by the proxy, such as Host and Content-Length .
When a service returns a secret
A service might include a secret in its response, for example in an error message that repeats the request headers. When the proxy inserts a custom secret into a request, it checks the response headers and body and masks matching secret values before returning the response to the sandbox. It recognizes the original value and JSON-escaped, percent-encoded, and base64 forms.
This filtering cannot guarantee that a secret stays hidden. It doesn't inspect WebSocket messages or recognize every way a service could transform a secret, such as splitting it across separate fields. Filtering applies only when the proxy inserted a custom secret into the request.
Masking a secret can change the response format and make it unreadable by the client.
For these requests, the proxy returns 502 Bad Gateway instead of forwarding partial responses ( 206 ) or responses with unsupported content encodings.
If credential approval blocks authentication on a kit-declared route, the proxy removes authentication headers such as Authorization and x-api-key . This also removes custom secrets placed in those headers. Custom secrets in other headers aren't affected. See Credential bindings .
To find stored custom secrets by host, use --host :
To filter by environment variable name, use --env-name :
Add --sandbox to list only matching secrets stored for a specific sandbox:
The header column shows explicit bindings or (default) for secrets that follow the default-header setting.
Target multiple hosts
Repeat --host to cover multiple domains with the same secret — useful when an API is split across related hostnames or when two unrelated endpoints a credential:
A --host value can also use wildcards, with the same syntax as network rule hostname patterns : * matches a single label ( *.example.com covers api.example.com ) and ** matches any number ( **.example.com covers api.example.com and v2.api.example.com ).
Resolve custom secrets dynamically
Custom secrets also accept dynamic secret sources . Replace --value with either --ref or --command :
Dynamic custom secrets resolve on demand by default. Pass --refresh with a duration to cache the resolved value. The verification and error-output flags work the same as they do for service secrets. --ref and --command can't be combined with --value or --token .
Install npm packages from GitHub Packages
The built-in github service doesn't inject credentials into requests to npm.pkg.github.com . To install private npm packages from GitHub Packages, add a custom secret for that host.
On the host, authenticate the GitHub CLI with a token that can read the package. GitHub documents a personal access token (classic) with at least read:packages scope for this use. See Authenticating to GitHub Packages . Then register the token source, replacing my-sandbox with your sandbox's name:
The command prints a generated placeholder. For an existing sandbox, set NODE_AUTH_TOKEN to that placeholder using sbx run -e for an agent session, or /etc/sandbox-persistent.sh for future sessions. See Set environment variables . Use the placeholder, not the actual GitHub token.
Inside the sandbox, add the following entries to your project's .npmrc , replacing @my-org with the package's scope. Keep ${NODE_AUTH_TOKEN} literal so npm reads the environment variable:
Install the package inside the sandbox:
Replace @my-org/my-package with your package name. npm sends the placeholder to npm.pkg.github.com , and the proxy replaces it with the token retrieved by gh auth token on the host.
Kits shipped with sbx don't need separate credential approval. Other kits ask you to approve the credentials they request and the domains that can receive them. sbx saves these approvals in credentials.yaml at ~/.config/sbx/credentials.yaml , or %APPDATA%\sbx\credentials.yaml on Windows. You can also write entries by hand.
Each entry under bindings is keyed by a service identifier . Each service lists its approved domains separately for API keys and OAuth:
apiKey.domains controls where the proxy can send the stored API key.
oauth.domains controls where the proxy can send OAuth tokens, including API keys obtained through OAuth.
Approval under one list doesn't grant approval under the other. If a kit requests additional domains, sbx asks you to approve them.
The file stores your approvals, not your secrets. An entry with both domain lists empty grants no access and is treated as missing. Declining a credential writes no entry at all.
When a kit needs a credential that has no binding, sbx walks you through approving one. For an API key, you can use a value already in the secret store or enter one at the prompt. For OAuth, you approve the sign-in flow. In both cases, you approve the domains declared by the kit. sbx writes the entry to credentials.yaml .
In non-interactive contexts (CI or --detach ), there's no one to answer the prompt. In sbx , the sandbox starts with the credential withheld when no binding exists or the binding lists no domains for either mechanism. For a required credential, sbx prints a warning rather than failing sandbox creation. This is a limitation of sbx enforcement: kit authors shouldn't rely on a required credential being available merely because the sandbox started.
Pre-create the binding by running the kit interactively once or by writing credentials.yaml directly before running unattended.
The kit's credential injection rules and network permissions still constrain which requests can carry the credential.
Kits that require a binding
Approval is required regardless of schema version. If a kit extends a built-in agent, you must approve its use of the inherited credentials. You must also approve a kit that requests the same service itself.
Registry credentials authenticate to private OCI registries when pulling templates or kits , and can also let the agent pull and push images from inside the sandbox through the host-side proxy. Use sbx secret set --registry to store them. For Docker Hub, sbx reuses your sbx login session — no registry secret needed. For other registries (GitHub Container Registry, ECR, ACR, self-hosted Nexus, and so on), store credentials with sbx secret set --registry .
Choose the scope by adding --all-sandboxes , adding --sandbox SANDBOX , or passing neither:
Host-only (no scope flag): sbx uses it to pull templates and kits when creating a sandbox. The credential stays on the host and is never available inside the sandbox.
All sandboxes ( --all-sandboxes ): same as host-only, plus the proxy authenticates registry login requests from sandboxes. The credential stays on the host and is never written to the sandbox filesystem. Use it when agents build and publish container images.
Sandbox-scoped ( --sandbox SANDBOX ): same proxy behavior as --all-sandboxes , but only for the named sandbox. Use it when only one sandbox needs registry access.
Store registry credentials
Pipe a token from stdin and target the registry hostname:
For registries that require a username (for example, ACR with an admin account), add --username :
Add --all-sandboxes to make the credential available to every new sandbox:
Store all-sandboxes registry credentials before creating a sandbox. Existing sandboxes don't pick up all-sandboxes registry credentials added later. To add registry access to an existing sandbox, use a sandbox-scoped credential instead.
To scope the credential to a single sandbox, store it under that sandbox's name:
For v2 kits on Docker Hub, sbx kit pull and sbx kit push use the session from sbx login . For other registries, both commands use these credentials. Both commands fall back to the Docker credential store, so credentials from docker login also work. V3 kits are published with Docker Buildx , which uses the credentials from docker login .
Trust a private registry authentication endpoint
Use --registry-auth-endpoint with --registry when a self-hosted registry authenticates sandbox requests through a separate host. For example, a self-hosted GitLab registry at registry.example.com might advertise as the realm in its Registry v2 WWW-Authenticate: Bearer challenge.
Store the credential and trust that endpoint for a specific sandbox:
Replace the example hosts with your registry and authentication hosts, and set GITLAB_USER and GITLAB_PAT to your GitLab username and personal access token.
This authorizes the proxy to send the stored registry credential to to exchange it for a registry token. The advertised realm must use HTTPS and match the configured host and path exactly. Other paths on that host, including /jwt/auth/ , aren't covered. The endpoint URL must contain no embedded credentials, query string, or fragment. Token requests can still include protocol parameters such as service and scope .
Without this flag, the proxy accepts authentication endpoints on the registry's own host and built-in registry relationships, such as Docker Hub's authentication host. Other authentication hosts require explicit configuration.
Remove registry credentials
Remove both the host-only and all-sandboxes entries for a registry:
To remove only the all-sandboxes entry and leave the host-only credential in place, pass --all-sandboxes :
To remove a sandbox-scoped credential, pass the sandbox name:
Use stored secrets to provide credentials. The OS keychain protects them at rest; on Linux hosts without a keychain they are held in a permission-protected file instead. See Where secrets are stored .
Don't set API keys manually inside the sandbox. Sandbox agents are pre-configured to use proxy-managed credentials.
Registry credentials stay on the host and are injected by the proxy when a sandbox authenticates to the registry. Reserve them for sandboxes that need registry access, and prefer sandbox scope over --all-sandboxes to limit exposure.
Several agents support OAuth as another secure option: the flow runs on the host, so the token is never exposed inside the sandbox. If you haven't stored a credential, the agent prompts you to authenticate — Codex prompts on the host from sbx run codex , while Claude Code, Cursor, and Droid prompt interactively inside the sandbox. To authenticate ahead of time, run sbx secret set openai --oauth for Codex or use /login inside Claude Code; Cursor and Droid have no ahead-of-time option, so their sign-in prompt appears when the agent starts. See the individual agent pages for each agent's flow.
If you store credentials in 1Password or AWS Secrets Manager, see Sourcing credentials from 1Password and Sourcing credentials from AWS Secrets Manager .
Custom templates and placeholder values
When building custom templates or installing agents manually in a shell sandbox, some agents require environment variables like OPENAI_API_KEY to be set before they start. Set these to placeholder values (e.g. proxy-managed ) if needed. The proxy injects actual credentials regardless of the environment variable value.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
