# Environment variables and secrets

Control whether configuration is exposed to the hosted worker, sandbox, or both.

Salambo separates non-secret environment configuration from secrets and makes the exposure boundary explicit.

## Non-secret values

```yaml
env:
  APP_MODE:
    value: standard
    description: Application behavior mode.
    exposeTo:
      - runtime
```

## Secrets

```yaml
secrets:
  OPENAI_API_KEY:
    fromEnv: OPENAI_API_KEY
    description: Provider credential.
    exposeTo:
      - runtime
```

The CLI reads `OPENAI_API_KEY` from the deployer's environment. It does not store the plaintext value in `salambo.yaml`.

## Exposure targets

| Target    | Meaning                                                                   |
| --------- | ------------------------------------------------------------------------- |
| `runtime` | Available to the trusted worker brain                                     |
| `sandbox` | Available to sandbox tools or extensions through the supported projection |

Declare the narrowest exposure required.

Provider keys used only for worker-owned provider calls normally need:

```yaml
exposeTo:
  - runtime
```

## Sandbox-exposed secrets

A secret exposed to the sandbox requires an egress host allowlist:

```yaml
secrets:
  PARTNER_TOKEN:
    fromEnv: PARTNER_TOKEN
    exposeTo:
      - sandbox
    allowedHosts:
      - api.partner.example
```

Sandbox-exposed secrets use the managed egress boundary. They are not a reason to inject broad plaintext credentials into every process.

The sandbox receives a time-limited sealed placeholder, not the plaintext value. Use that environment value in a supported HTTP authorization or API-key header. The managed outbound proxy releases the plaintext only after the run policy, destination, secret host scope, session binding, and expiry all pass validation.

See [sandbox security architecture](/docs/architecture/sandbox-security) for the complete sealed-secret and managed HTTPS flow.

## Security rules

* Never commit real secrets.
* Never use a `value` field under `secrets`.
* Use uppercase environment names.
* Use host-only allowlist entries.
* Rotate secrets by updating the deployment environment and deploying again.
* Remove unused entries from `salambo.yaml`; deployment reconciliation removes obsolete remote configuration.
* Do not print secret values in extension errors, artifacts or diagnostic messages.
