---
title: "Security"
description: "How opod core authenticates callers and workers, how to encrypt the north side, what it stores, and every network call it can make."
url: "https://opod.io/docs/core/security/"
markdown_url: "https://opod.io/docs/core/security.md"
section: "Core"
last_updated: "2026-11-08"
---

# Security

> How opod core authenticates callers and workers, how to encrypt the north side, what it stores, and every network call it can make.

## In short

Every caller needs an API key, and every leader-to-worker call is signed with a per-worker HMAC key. Opod core assumes a **trusted network** between its leader and workers (your LAN, or a VPN you run): it encrypts the north side when you give it a certificate, but it ships no mesh of its own. This page says what is protected, what is not, and how to lock a leader down.

1. **Give the leader a certificate**

   ```bash
   OPOD_TLS_CERT=/etc/opod/tls.crt OPOD_TLS_KEY=/etc/opod/tls.key opod up
   ```

2. **Make workers trust exactly that certificate**

   ```bash
   OPOD_LEADER_CA=/etc/opod/ca.crt opod join "https://leader.example.com:8080?token=sk-orc-<node-token>"
   ```

3. **Give each person their own key, with an expiry**

   ```bash
   opod token create alice --ttl 30d
   opod token revoke k_abc        # when alice leaves
   ```

4. **Keep the admin key off logs**

   The admin key lives in `~/.opod/admin.key`. Do not paste it into tools; `opod token create ops --admin` mints another when you need one.

## Check it worked

```bash
curl -s https://leader.example.com:8080/v1/models --cacert /etc/opod/ca.crt
```

```text
{"error":{"type":"missing_api_key","message":"Authorization header required"}}
```

A request with no key is refused with `401`. The same request with `-H "Authorization: Bearer sk-orc-<alice-key>"` answers `200`. `curl http://…` (plain) to the TLS port fails.

## API keys

- Format: `sk-orc-` followed by 24 random bytes, base64url-encoded.
- Stored as SHA-256 hashes. The plaintext appears once, when the key is created.
- One scope per key: `user` (`/v1/*`), `admin` (`/v1/*` and `/admin/v1/*`) or `node` (worker register and heartbeat).
- Optional expiry: `--ttl` or `--expires-at`. An expired key gets `401 key_expired`.
- Revocable at any time with `opod token revoke`.

A key is sent as `Authorization: Bearer sk-orc-…`. The gateway also accepts `X-Api-Key: sk-orc-…` (Anthropic style) and a `?key=` query parameter (for clients that cannot set headers, such as a browser `EventSource`). A query-string key can end up in access logs that record URLs.

`auth.require_keys: false` (or `OPOD_REQUIRE_KEYS=0`) lets `/v1` requests through without a key, for local development only. `/admin/v1` always needs a key.

```bash
OPOD_REQUIRE_KEYS=0 opod up   # local development only
```

### The admin key file

The first standalone `opod up` saves the admin key to `~/.opod/admin.key` with mode `0600`, so CLI commands on that host work without typing it. Protect that file like an SSH key. A managed leader started with `OPOD_ADMIN_TOKEN` writes no key file.

## Leader and worker authentication

- A worker joins with a `node` key (the join token) or a client certificate.
- After the join, every call between leader and worker is signed with HMAC-SHA256 using that worker's token. The header is `X-Opod-Auth: v=1,id=<node id>,ts=<unix seconds>,sig=<hex>`. The signed string is `v1`, the method, the path and the timestamp, joined by newlines. A signature older or newer than 5 minutes is refused, so keep clocks in sync (NTP).
- The body is not signed, and the traffic is not encrypted by opod.
- A worker also accepts a bearer token from the leader, for upgrades. `OPOD_REJECT_BEARER=1` on the worker accepts HMAC only.
- The leader stores each worker's token in the `nodes` table. A stolen `state.db` lets an attacker act as a worker; encrypt the disk if you cannot trust the host. `opod node show` and `GET /admin/v1/nodes` include the token.

### Worker certificates

A worker can be identified by a client certificate instead of a token:

- On the worker: `OPOD_NODE_CERT` and `OPOD_NODE_KEY` (PEM). The node id comes from the certificate's SPIFFE URI SAN, `spiffe://<domain>/opod/node/<id>`, read from the verified chain only.
- On the leader, in the auth snapshot: `nodeMtls` (`off`, `allow` or `require`), `nodeCertCa` (the CA PEM) and `revokedCerts` (serial numbers, lowercase hex).

| `nodeMtls`     | Effect on register and heartbeat                                                               |
| -------------- | ---------------------------------------------------------------------------------------------- |
| `off` or empty | Certificates are ignored. The token is the credential.                                         |
| `allow`        | A certificate signed by `nodeCertCa` authenticates the worker. Without one, the token is used. |
| `require`      | A join or heartbeat without such a certificate is refused.                                     |

The default is `off`. A worker that joins with a certificate and no token creates its own secret for HMAC and sends it to the leader over the TLS connection.

## Encrypt the north side

Give the leader a certificate and it serves `/v1`, `/admin/v1`, the probes and the join path over HTTPS:

```bash
OPOD_TLS_CERT=/etc/opod/tls.crt OPOD_TLS_KEY=/etc/opod/tls.key opod up
```

Workers trust exactly that certificate through `OPOD_LEADER_CA=/etc/opod/ca.crt`. Leader-to-worker traffic stays plain HTTP, HMAC-signed. A reverse proxy (Caddy, nginx) in front of the leader is a fine alternative.

Two extra listeners trade encryption for convenience. Both are off by default:

| Setting                              | Serves                                                         | Use it when                                                                                                                                                                                                                        |
| ------------------------------------ | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `probe_listen` / `OPOD_PROBE_LISTEN` | `/healthz`, `/readyz`, `/loadz`, `/metrics` only, always plain | a scraper or autoscaler should read numbers without the CA. Nothing authenticated is routed there.                                                                                                                                 |
| `plain_listen` / `OPOD_PLAIN_LISTEN` | the **whole** API, always plain                                | a load balancer cannot originate TLS to each leader. Prompts, answers and keys cross the network in clear text: bind it only where a firewall or network policy decides who connects. A leader that cannot bind it does not start. |

```bash
OPOD_TLS_CERT=/etc/opod/tls.crt OPOD_TLS_KEY=/etc/opod/tls.key \
  OPOD_PROBE_LISTEN=:8081 opod up       # probes and /metrics in plain on :8081
OPOD_PLAIN_LISTEN=:8082 opod up         # the whole API in plain on :8082 — firewall it
```

## Request data

- Request and response bodies are not stored. A usage row holds metadata only: key id, user, model, protocol, token counts, latency, time to first token, outcome and node.
- Spans carry serving facts only; no key, user or team is put on a span.
- `/healthz`, `/readyz`, `/loadz`, `/gatewayz` and `/metrics` need no key. They carry no prompts and no key ids.
- **Client address.** Behind a proxy, the leader takes the caller's address from `True-Client-IP`, then `X-Real-IP`, then the leftmost `X-Forwarded-For` entry; a value that is not an IP address is skipped. It uses that address only as a label, on the access log line and the request's span. It never trusts it: the loopback check on the bootstrap admin key and the audit actor read the TCP peer. Anyone can set these headers, so do not read the logged address as proof of who called. There is no trusted-proxy list.

## Weights and catalog supply chain

- `opod fetch` and model loads can pin a Hugging Face revision (`OPOD_MODEL_REVISION`) and check a SHA-256 (`OPOD_MODEL_SHA256`). A mismatch removes the file and fails the load.
- Catalog files in directories can be signed with minisign and verified with `OPOD_CATALOG_PUBKEY`; `OPOD_CATALOG_REQUIRE_SIGNED=1` refuses unsigned ones. See [Models](https://opod.io/docs/core/models/#signed-catalog-files).
- `block_private_targets: true` (`OPOD_BLOCK_PRIVATE_TARGETS=1`) refuses outbound catalog-probe and similar calls to loopback, link-local and private addresses. For example `OPOD_BLOCK_PRIVATE_TARGETS=1 opod up`.
- `trust_proxy_headers` is off by default: `X-Forwarded-Host` and `X-Forwarded-Proto` are ignored when the leader builds its public URL. Turn it on only behind a proxy you control.

## Container images

Release images are signed keyless with cosign (Sigstore) and carry an SPDX SBOM as an attestation:

```bash
cosign verify \
  --certificate-identity-regexp 'https://github.com/opod-io/' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  ghcr.io/opod-io/opod-leader:<version>
```

Pin images by digest. If verification fails, do not run the image.

## Every network call opod can make

Opod sends no telemetry. With no OTLP endpoint configured, a leader calls only the engines and nodes you chose.

| Direction                                                 | When                                                               | How to turn it off                                                           |
| --------------------------------------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
| to the engine endpoint                                    | every inference request                                            | choose another engine                                                        |
| leader and workers                                        | heartbeats every 5 s, model loads, requests; HMAC-signed           | `opod node remove`, or do not join                                           |
| to Hugging Face (or `HF_ENDPOINT`) or the Ollama registry | when weights are pulled, and the HEAD check in `model add`         | pre-place weights; set `HF_ENDPOINT` to a mirror; `OPOD_SKIP_SOURCE_CHECK=1` |
| to `api.github.com` and GitHub Releases                   | only when you run `opod update`                                    | do not run it                                                                |
| to an OTLP collector (traces)                             | when `OPOD_OTLP_ENDPOINT` is set                                   | unset it                                                                     |
| to an OTLP collector (logs)                               | when `OPOD_OTLP_LOGS_ENDPOINT` is set                              | unset it                                                                     |
| to the policy's `routing.fallbackUrl`                     | only when a manager set one and the leader has no serving capacity | remove it from the policy                                                    |

## Threat summary

| Threat                               | Mitigation                                                                          |
| ------------------------------------ | ----------------------------------------------------------------------------------- |
| A worker is compromised              | Workers hold no admin scope. Each worker's calls are signed with its own token.     |
| A user key leaks                     | Revoke it. An expiry bounds its life.                                               |
| Node traffic is sniffed              | North side: TLS listener. Leader to worker: signed, not encrypted — use a VPN.      |
| A leaked join token registers a node | Use worker certificates with `nodeMtls: require`; revoke serials in `revokedCerts`. |
| The leader is compromised            | The leader is the trust root. Rotate admin keys.                                    |
| Tampered weights or catalog          | SHA-256 pins and signed catalog files.                                              |

## If it fails

| Symptom                                                                            | Fix                                                                                 |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `401` `missing_api_key` "Authorization header required"                            | Send `Authorization: Bearer sk-orc-…`, `X-Api-Key`, or `?key=`.                     |
| `401` `invalid_api_key` "Invalid or revoked API key"                               | The key is wrong or revoked. Mint a new one.                                        |
| `401` `key_expired`                                                                | Renew it: `opod token renew ID --ttl 30d`.                                          |
| A worker cannot join a TLS leader: `x509: certificate signed by unknown authority` | Set `OPOD_LEADER_CA` on the worker to the leader's CA.                              |
| Leader-to-worker calls refused after a reboot                                      | Clock skew over 5 minutes. Fix NTP on both machines.                                |
| `401 this endpoint requires a worker client certificate (nodeMtls=require) …`      | Give the worker `OPOD_NODE_CERT` and `OPOD_NODE_KEY`, or set `nodeMtls` to `allow`. |
| `403 certificate revoked (serial …)`                                               | The serial is in `revokedCerts`. Issue the worker a new certificate.                |

## Report a vulnerability

Do not open a public issue. Open a private advisory at [github.com/opod-io/opod-core/security/advisories/new](https://github.com/opod-io/opod-core/security/advisories/new). Fixes ship on `main` and in the next release; older releases are not patched.
