Skip to main content
Environment variables are the standard way to pass secrets (API keys, database passwords, tokens) to sandbox workloads. Declaw provides two mechanisms for protecting these secrets: masking patterns that prevent sensitive values from appearing in audit logs, and SecureEnvVar markers that prevent secrets from being returned in get_info() responses.
For the strongest isolation, use the Credential Vault instead. With env secrets the real value still lives inside the VM (these mechanisms only keep it out of logs and API responses). With the vault, the value never enters the VM at all — the sandbox sees only a declaw:vault-managed placeholder and the real credential is injected at the egress proxy, per allowed domain. Reach for env secrets when a process genuinely needs the value in-process; reach for the vault when the agent only needs to make authenticated requests.

Passing environment variables

The variables are available inside the sandbox:

EnvSecurityConfig

EnvSecurityConfig controls how secrets behave in logs and API responses.

EnvSecurityConfig model

Default masked patterns

Declaw automatically masks variables matching these patterns in audit logs, even without explicit configuration:
  • *_KEY
  • *_SECRET
  • *_TOKEN
  • *_PASSWORD
This means OPENAI_API_KEY, DATABASE_PASSWORD, and similar variables will not appear in audit log entries in plaintext.

SecureEnvVar

SecureEnvVar marks specific variables as secrets. Secret variables are passed to the sandbox but:
  • Never returned in get_info() or list() responses
  • Never logged in plaintext in audit entries
  • Not visible through the API after creation

SecureEnvVar model

Per-command environment variables

You can pass additional environment variables at the command level. These are also subject to masking rules.

Preventing credential exfiltration

Environment variables alone cannot prevent a compromised agent from exfiltrating secrets via outbound traffic. Use network policies and transformation rules to add defense-in-depth:
In this configuration:
  1. The sandbox can only reach api.openai.com
  2. Any sk-* pattern in outbound request bodies is stripped before transmission
  3. Audit logs mask the key name
  4. All blocked connections are logged
Environment variables are accessible to all processes running inside the sandbox. If you run untrusted code inside a sandbox, the code can read OPENAI_API_KEY from its environment. The network policy and transformation rules above prevent the key from being exfiltrated, but the code can still read the key value.

Auto-injected Declaw variables

These variables are always present and cannot be masked: