Skip to main content
See Secrets for usage examples and security boundaries.

Functions

WithSecrets()

Append credential secrets to the sandbox. Each call appends, so multiple calls accumulate. Secrets never enter the VM; the network proxy substitutes them at the transport layer. Pass to CreateSandbox alongside the other options.

Parameters

Secret entries to attach, usually built with Secret.Env.

Returns

SandboxOption
Functional option for CreateSandbox.

Secret

The Secret factory is a package-level value. Call its methods to build SecretEntry values without populating struct literals by hand.

Secret.Env()

Build a SecretEntry that maps an environment variable to a real value. The guest sees a placeholder; the real value is substituted by the TLS proxy only when traffic goes to an allowed host. Supply at least one exact or wildcard host in Allow; an empty allow-list is rejected when the sandbox configuration is validated.

Parameters

envVarstring
Environment variable name holding the placeholder inside the sandbox. Must be non-empty and cannot contain = or NUL; shell-identifier syntax is not required.
valuestring
The real secret value. Passed to the native host runtime, never exposed inside the guest.
Allowed hosts, placeholder override, TLS requirement, and violation action.

Returns

Validation and lifecycle

Sandbox configuration validation rejects invalid environment names (empty or containing = or NUL), an empty allow-list, all substitution locations disabled, and invalid placeholders. Secret.Env() constructs a value; errors surface when the configuration is validated. Raw values are persisted in the durable sandbox configuration. See source references and live modification to rotate or remove secrets without restarting. Adding a secret or changing its guest-visible placeholder requires a restart. Live modification is local-only.

Types

SecretEntrystruct

accepted by WithSecrets() · returned by Secret.Env()

A single credential the network proxy substitutes at the transport layer. The value never reaches the guest VM. Usually produced by Secret.Env; exported for callers that prefer struct literals.

SecretEnvOptionsstruct

accepted by Secret.Env()

Tunes Secret.Env beyond the required envVar and value.

SecretSubstitutionstruct

substitution.Headers

Substitute in headers, including Basic authentication. Default: true when nil; use a pointer to set false.

substitution.HeaderFields

Restrict substitution to these header names. An empty list allows all headers. Requires header substitution to be enabled. Prefer only the intended credential header, such as Authorization, to prevent other headers from exposing a secret in a reflected response.

substitution.Query

Substitute in the URL query string. Default: false.

substitution.Body

Substitute in supported HTTP/1 bodies. Default: false. Fixed-length bodies up to 16 MiB update Content-Length; larger bodies are blocked. Chunked bodies are decoded and re-encoded. Encoded bodies pass through unchanged. HTTP/2 body substitution is unsupported, and matching placeholders are blocked. At least one substitution location must remain enabled. On verified allowed hosts, disabled locations forward the placeholder unchanged. Other destinations must match the passthrough policy or follow the violation action.

ViolationActionstring enum

field of SecretEntry · NetworkConfig

What happens when a secret placeholder cannot be substituted or passed through. Passthrough is a separate per-secret host policy, not a violation action. Configure the sandbox-wide default on NetworkConfig.SecretViolationAction; override per-secret with SecretEntry.ViolationAction.