SecretBuilder
Builder for one secret configuration.secret.env()
$MSB_<varName> (or a custom placeholder), never the real value. Names must be non-empty and cannot contain = or NUL; shell-identifier syntax is not required. Required.
Parameters
varNamestringEnvironment variable name (non-empty, no
= or NUL).secret.value()
Parameters
valuestringThe actual credential or token.
secret.placeholder()
$MSB_<envVar>. Use this when you need a specific format or when the placeholder must match a particular byte length. Placeholders must be non-empty, at most 1024 bytes, and cannot contain NUL, CR, or LF.
Parameters
placeholderstringCustom placeholder string: non-empty, up to 1024 bytes, no NUL/CR/LF.
secret.allow()
Example
Example
*.suffix pattern matches the suffix itself and its single- or multi-label subdomains. The proxy checks the host against the connection’s verified TLS identity and observed DNS history. Can be called multiple times to allow several hosts. At least one allowed host (exact, pattern, or any) is required.
Parameters
hoststringHostname or wildcard pattern, e.g.
“api.example.com” or “*.example.com” (ASCII case-insensitive).secret.allowAnyHostDangerous()
iUnderstand is true. Only use this when the secret is not sensitive or the sandbox network is fully locked down. This is the one allow-list pattern that skips DNS and TLS-identity pinning.
Parameters
iUnderstandbooleanMust be
true to take effect.secret.requireTlsIdentity()
true, the secret is only substituted on TLS-intercepted connections where the proxy has verified it is performing MITM and the SNI matches an allowed host. Bypassed TLS is opaque and never receives substitution. Disable only when you know the traffic path is safe and explicitly supports non-TLS substitution. Default: true.
Parameters
enabledbooleanRequire verified TLS identity. Default:
true.secret.substituteInHeaders()
Authorization: Bearer $MSB_... and similar patterns. Default: true.
Parameters
enabledbooleanSubstitute in headers. Default:
true.secret.substituteInQuery()
?key=value portion of the request line). Default: false.
Parameters
enabledbooleanSubstitute in query parameters. Default:
false.secret.substituteInBody()
Content-Length; larger fixed-length bodies are blocked. Chunked HTTP/1 bodies are decoded and re-encoded with fresh chunk sizes. Encoded bodies pass through unchanged. HTTP/2 DATA-frame body substitution is unsupported, and matching body placeholders are blocked. Default: false.
Parameters
enabledbooleanSubstitute in request bodies. Default:
false.secret.allowPlaceholderFor()
allowPassthroughFor() remains a deprecated alias. This never grants permission to receive the real secret; use allow() for substitution. Credential-allowed hosts already permit unchanged placeholders outside enabled substitution locations once the secret’s host and TLS identity checks pass. Without either permission, the configured blocking action applies.
secret.violationAction()
"block-and-log". Invalid action strings throw an error. Passthrough is a separate per-secret host policy, not a violation action.
Example
Example
secret.build()
SecretEntry. Called for you by SandboxBuilder.secret, so you rarely call it directly. If placeholder was not set, it defaults to $MSB_<envVar>. Consumes the builder; do not reuse it afterward. Throws if env or value was not set, or if the allow-list is empty. Sandbox configuration validation also rejects invalid environment names or placeholders and configurations with every substitution site disabled.
Returns
The materialized secret entry.
SandboxBuilder
Two methods onSandboxBuilder for adding secrets without reaching into a NetworkBuilder. Both automatically enable TLS interception.
sandbox.secret()
Example
Example
SecretBuilder closure. The builder’s build() is called for you.
Parameters
configure(s: SecretBuilder) => SecretBuilderConfigure the secret.
sandbox.secretEnv()
Example
Example
$MSB_<envVar> and allows substitution only on allowedHost. The default injection scopes apply (headers and Basic Auth enabled, query and body disabled).
Parameters
envVarstringEnvironment variable name (non-empty, no
= or NUL).valuestringSecret value.
allowedHoststringAllowed destination host (exact match).
NetworkBuilder
The same secret configuration is available insideSandboxBuilder.network(n => ...) for callers who are already configuring networking. These methods set the secrets and the sandbox-wide violation policy directly on the network.
network.secret()
Example
Example
SecretBuilder closure. Identical in behavior to SandboxBuilder.secret.
Parameters
configure(s: SecretBuilder) => SecretBuilderConfigure the secret.
network.secretEnv()
SandboxBuilder form but lets you provide the placeholder explicitly instead of auto-generating $MSB_<envVar>.
Parameters
envVarstringEnvironment variable name (non-empty, no
= or NUL).valuestringSecret value.
placeholderstringExplicit placeholder: non-empty, up to 1024 bytes, no NUL/CR/LF.
allowedHoststringAllowed destination host (exact match).
network.secretEnvSimple()
NetworkBuilder. Auto-generates the placeholder as $MSB_<envVar>, matching SandboxBuilder.secretEnv. Like NetworkBuilder.secret() and NetworkBuilder.secretEnv(), it enables TLS interception while preserving other TLS settings. The guest receives only the placeholder. Earlier SDK versions incorrectly exposed the supplied secret as the placeholder in this helper. Code that intentionally needs a raw guest environment value should use ordinary environment configuration; this helper keeps the credential on the host. Updating the SDK does not rewrite existing sandbox configurations; recreate or explicitly reconfigure sandboxes created with the affected helper.
Parameters
envVarstringEnvironment variable name (non-empty, no
= or NUL).valuestringSecret value.
allowedHoststringAllowed destination host (exact match).
network.secretViolationAction()
SecretBuilder.violationAction() overrides it per secret. This method belongs to NetworkBuilder, so configure it through SandboxBuilder.network().
Example
Example
Types
SecretEntry
Returned by SecretBuilder.build()
The materialized object produced bySecretBuilder.build(). Configure secrets through the builder; its output is not the sparse live-modification input.
SecretSubstitution
Used by SecretEntry.substitution
The materialized substitution settings. Set them through thesubstituteIn* methods on SecretBuilder. At least one location must remain enabled. On credential-allowed hosts that pass the secret’s identity checks, disabled locations forward the placeholder unchanged. Other destinations require explicit placeholder permission or follow the violation action.
ViolationAction
Used by SecretBuilder.violationAction() · NetworkBuilder.secretViolationAction()
TheViolationActions array enumerates these values. Per-secret settings override the network default; passthrough is configured separately.