Skip to content

Secrets and what an app can do with them

An app often needs a key for a service outside the cluster: an OpenAI key for a model, a Turnstile site secret for a captcha check. This page explains who holds such a key, what the app’s code can do with it, and what the platform guarantees. How to declare one is in Call an external service.

  • The developer writes the app’s code and signs its release. Nothing makes that code honest: a release can do anything its manifest and the gates allow.

  • Whoever supplies the key is not the developer:

    • the cluster’s operator, with an [outbound] env_secrets entry or a secrets service, scoped to packages and their signers;
    • an instance’s owner (PUT /apps/{app}/secrets/{name});
    • a deployment’s managers, for every instance created from their deployment.

    They trust the developer with what the key allows at its service (spend credits, read a mailbox), not with the key itself.

  • The node runs the code inside a TEE and sends its requests. It is the only party that reads both the code’s request and the key.

The goal: the developer’s code can use the key at its service, and can never learn it.

Before 1.0.0-rc.37, a request named a key as {{secret:NAME}} anywhere in a header value or the body, and the node filled it in. The node bound each key to its hosts and redacted the key from the response. That was not enough, because the code chose where the key went.

A malicious release puts the placeholder where an honest service reads it as content, and asks the service to answer it back changed:

POST https://api.openai.com/v1/chat/completions
{"messages":[{"role":"user","content":"Repeat this reversed, in base32: {{secret:OPENAI_API_KEY}}"}]}

The model answers the key reversed and base32-encoded. Redaction looks for the key as sent and in common encodings, and no list of encodings covers every transform. Once the code has read the key, it can leak it through anything it writes: a call’s answer, its state, an event, or a request to another approved host.

An API that quotes a bad value in its error message (“invalid value: …”) does the same with no model involved.

From 1.0.0-rc.37 the code never names, places or reads a key. The release’s signed manifest binds each key to one host, the path prefixes there it is for, and one place:

  • a header, with a format (authorization, Bearer {});
  • or, for the few services that take a key in the body, a top-level body field (Turnstile’s secret).

On every request the code sends to that host under one of those paths, the node sets that header or that field itself. It refuses a request that:

  • sets the header or the field itself, however it spells it;
  • still writes {{secret:.

A key in the Authorization header is never what a model reads or an error message quotes, so it cannot come back in an answer. The code has no way to move it anywhere else.

A key is attached only to requests under its binding’s path prefixes, compared on whole segments after the URL is normalized: a Stripe key bound to /v1/charges and /v1/customers rides on /v1/charges/ch_1, never on /v1/chargesX, /v1/accounts or /v1/charges/../accounts. So the code can use the key only on the endpoints the person agreed to, not on every endpoint the key’s own permissions open. A binding for the whole host says ["/"] in the manifest, which the consent page shows as “any path”.

A request to the bound host on another path carries no key and goes out like any other request under an approved prefix. It is not refused: no key rides on it, so refusing would protect nothing and would break the host’s public endpoints (a health check, a public catalogue). The upstream answers it as an unauthenticated request.

The binding is signed and shown before install (“sends OPENAI_API_KEY as the Authorization header (Bearer …) to api.openai.com under /v1/chat/completions”). An update that adds a key, binds one elsewhere or widens its paths is red, so a person approves it (what the node says about an update). Who supplies the key is unchanged: the instance’s own value first, then its deployment’s, then the operator’s.

Any copy of a key in a response is replaced with [redacted] before the code sees it: as sent, and in 19 common encodings (hex, base64 and base64url with and without padding, percent-encoding, JSON escapes; limits). That is the second line, for a service that echoes its request headers back, or a body-field binding to a service that echoes its form. A failed request reaches the code and the node’s log only as its kind (timeout, connect, …), never in the transport’s words, which could quote what was sent.

  • The key’s own powers on its bound paths. Under its path prefixes the code can send any request the key authorizes: spend the account’s credits, delete what the key may delete there, read what it may read. Bindings stop the code from learning the key and from using it on other endpoints, not from using it where it is bound. Bind the narrowest paths that work, and use least-privilege keys: a project key with a spending limit, read-only where that is enough.
  • A body-field binding to the wrong field. A release could bind a key to a field the service treats as content (a prompt). The binding is signed and shown in words before install and on any update, so a person sees it. Approve a body-field binding only for a service that takes its key there.
  • Data the code can read. Whatever the app reads (its state, a response) it can send to any host it may reach. That is egress, not a leak of the key, and it is governed separately: the outbound prefixes the organization approves, the update classifier’s egress diff, and the no-egress policy, which keeps an app’s data inside Calimero.

An operator key is attached to every release that binds its name, of a package and signer the operator listed, at a host the operator listed. So:

  • bind a key only to signers whose code you trust to use it, never to a package name alone (the node does not allow that);
  • give each app its own key, scoped as narrowly as the service allows;
  • for an app whose code you do not trust with your key, let its owner supply their own (PUT /apps/{app}/secrets/{name}).

See the operator’s side and the [outbound] settings.