---
title: "Secrets and network"
description: "Per-host egress and secret placeholders."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Secrets and network

An agent never holds a secret value. It sees only `${secret:NAME}`. The egress layer puts the value into a header, for one host, at request time. Every outbound call goes through the egress layer: MCP servers, `_apis` operations, scripts, generated code and model calls.

## Network

The default is deny. `network:` lists every host the agent can reach:

```yaml agent.yml
network:
  api.linear.app:
    headers: { Authorization: '${secret:LINEAR_TOKEN}' }
  api.dash0.com:
    headers: { Authorization: 'Bearer ${secret:DASH0_TOKEN}' }
  '*.slack.com': {}
secrets:
  LINEAR_TOKEN: { overridable: true }
  DASH0_TOKEN: {}
```

These hosts join the allow list automatically: the first `servers` host of each `_apis` file, each MCP server host, the `llm.gateway` host and the model provider host. Header templates still come from `network:`.

| Rule            | Detail                                                                                                                                                                                                                                           |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Match           | Exact host, or one leading `*.` wildcard over one or more labels. HTTPS on port 443 only.                                                                                                                                                        |
| Wildcards       | A wildcard host cannot carry a header template. Lint fails with `wildcard_header`.                                                                                                                                                               |
| OIDC            | An exact host can take an `oidc:` block. The egress layer then sends a Run OIDC token to that host. A wildcard host cannot take it (`oidc_wildcard`). Read [OIDC identity](https://docs.cloudraker.com/run/guides/oidc-identity).                                               |
| Private targets | Loopback, RFC 1918, link-local, CGNAT, `.local`, `.internal` and IP literals are refused, even when `network:` lists them.                                                                                                                       |
| Redirects       | At most 3 hops. Each hop is checked again. Injected headers and OIDC tokens are dropped on a hop to another host. The body is never resent.                                                                                                      |
| Agent headers   | Only content-negotiation headers pass. The agent cannot set `authorization`, `cookie` or `host`.                                                                                                                                                 |
| Response        | Capped at `limits.max_egress_bytes` per run and 16 MB per response. Injected values are redacted from the response before the agent reads it.                                                                                                    |
| Audit           | One row per request: host, method, path, status, bytes and secret names. A request with an OIDC token has the name `oidc:agent` or `oidc:user`. Never values, tokens, query strings or bodies. The console **Run detail** screen shows the rows. |

A blocked request fails the tool call with `egress_denied`. A request to an `oidc` host that cannot get a token fails the tool call with `identity_unavailable`. For an MCP server on that host, the engine cannot list its tools, so the tools are missing from the turn.

### Signed identity instead of a secret

A host can get a short signed token instead of a secret. The token names the agent, or the person of the turn. Your API verifies it with the public keys of your org issuer, `https://{org}.cloudraker.run`.

```yaml agent.yml
network:
  api.internal.acme.com:
    oidc:
      identity: user # agent | user
```

Read [OIDC identity](https://docs.cloudraker.com/run/guides/oidc-identity).

A [connector](https://docs.cloudraker.com/run/guides/connectors) has its own egress rule. Only the MCP client of that connector can reach its host with its token. Other tools reach that host only through `network:`, and never get the connector token.

## Secrets

Declare every secret name in `secrets:`. Lint scans the `network`, `llm`, `triggers` and `webhooks` strings of `agent.yml`, and the `headers` of each `mcp.json` server. An undeclared name fails with `secret_undeclared`. Then store the value.

Write a secret as `${secret:NAME}`. A name matches `^[A-Z][A-Z0-9_]*$`. In `agent.yml` and `mcp.json`, a bare `secret: NAME` fails lint with `secret_bare_name`.

In the console, go to **Secrets** and select **Add**. Or use the API with a token that has the `secrets` scope:

```bash
curl -X PUT "https://$ORG.cloudraker.run/_secrets/LINEAR_TOKEN" \
  -H "Authorization: Bearer $RUN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "value": "lin_api_…" }'
```

Add `?agent={agent}` to scope the value to one agent. `GET /_secrets` lists names, never values. `DELETE /_secrets/{name}` removes one.

| Rule          | Detail                                                                                                                                       |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Storage       | Encrypted at rest. Never readable after write.                                                                                               |
| Minimum       | 8 bytes. Shorter values are refused, because redaction of a short value is not safe.                                                         |
| Replacement   | Only inside a header template of the `network:` entry for the target host. A placeholder in a URL, a query string or a body stays a literal. |
| In prose      | `${secret:NAME}` in `AGENTS.md` is allowed. Nothing replaces it there.                                                                       |
| In the repo   | A push that contains a secret value fails with `secret_value`.                                                                               |
| Missing value | The deploy succeeds with a warning. The console lists the missing name. The first run that needs it fails with `secret_missing`.             |

### Per-run overrides

A run request can send values for secrets marked `overridable: true`. Use this to pass your end user's own token. One agent then serves many end users.

```bash
# $REPO: the base path of the repo (the repo name by default).
curl -N -X POST "https://$ORG.cloudraker.run/$REPO/linear-triage" \
  -H "Authorization: Bearer $RUN_TOKEN" \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{ "input": "Triage EGR-123", "secrets": { "LINEAR_TOKEN": "lin_api_end_user_…" } }'
```

An override lives for one turn. It is never stored, logged or shown in traces. A `turns` run needs it again on each turn. A name that is not overridable answers `422 secret_not_overridable`. An unknown name answers `422 secret_unknown`. A `public` agent refuses `secrets`.

Precedence, highest first:

1. The run request `secrets`, for this turn.
2. The agent-scoped value (`?agent={agent}`).
3. The org value.
4. None: the request fails with `secret_missing`, and the run fails with the same code.

## Threats this covers

| Threat                                                                       | Control                                                                                                |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| The model puts `${secret:X}` in a request to `evil.example`                  | The host is not in `network:`. If it were, the placeholder stays a literal outside header templates.   |
| The model sends secret B to host A                                           | Only host A templates apply. The agent cannot set `authorization`.                                     |
| Host A redirects to host B with the header                                   | The injected header is dropped on a cross-host hop.                                                    |
| A repo writer sends the OIDC token of a person to a host the writer controls | A user token has the audience of the receiving host. Your API refuses an audience that is not its own. |
| A secret value comes back in a response                                      | The egress layer redacts it before the agent reads it. Traces get the same redaction.                  |
| An attacker picks the LLM gateway host                                       | The host is config, not a secret. A run request cannot change it.                                      |
| Generated code reads a binding                                               | Code isolates get the egress outbound only. No other bindings.                                         |

Source: https://docs.cloudraker.com/run/guides/secrets-and-network/index.mdx
