Skip to content

Proxy secrets

An ordinary (box) secret is put into the machine’s environment, so code running there can read it. A proxy secret never enters the machine at all. Its commands get a placeholder instead, and the machine’s egress path swaps the real value in on its way out — only on HTTPS, only to the hosts you named, and only in the place you said the credential goes.

Use it for a key that must not leak even if the code you run is hostile: a payment key, a production API token, an LLM key an agent uses.

Terminal window
# Inside the machine
$ printenv PAY_KEY
sist_ph_3f9c0a1b2d4e5f60718293a4b5c6d7e8
$ curl -sS -H "Authorization: Bearer $PAY_KEY" https://api.example.com/v1/charges
# → the request reaches api.example.com with the real key; the response comes back
# with any copy of the key replaced by the placeholder

The placeholder is worthless anywhere else: sent to another host, over plain http://, or in a different header, it is forwarded unchanged.

  • A locked network. Only a locked machine has the egress path that redeems the placeholder. Binding a proxy secret to an open machine is a 400.
  • Its hosts on the machine’s allow. A proxy secret never opens a host by itself: every one of its hosts must already be reachable, or the bind is a 400. A wildcard host (*.example.com) is covered only by the same wildcard.
  • The network stays compatible. While it is bound, opening the machine or dropping one of the secret’s hosts from allow is a 409 — unbind it first.

Secrets are created in the dashboard (Secrets in the sidebar). For a proxy secret, choose proxy custody and say where the credential goes:

Field Meaning
Hosts The only HTTPS hosts the value is ever sent to. Required
Presentation Where the request carries the placeholder — see below. Required
Method Optional: redeem only for this HTTP method (POST)
Path prefix Optional: redeem only for this path and the paths below it, by segment: /v1/charges covers /v1/charges/ch_1, not /v1/charges-evil
Presentation The request carries the placeholder… For example
bearer as Authorization: Bearer <placeholder> curl -H "Authorization: Bearer $KEY" …
basic as the Basic-auth user or password curl -u "user:$PASSWORD" …
header:<Name> inside that header (never Host) header:X-Api-Key → curl -H "X-Api-Key: $KEY" …
query:<param> as that query parameter’s value query:api_key → …?api_key=$KEY

The value must be at least 8 characters: it is masked out of every response from its hosts, so a very short one would rewrite ordinary text.

Bind it like any secret — "secrets": ["PAY_KEY"] on create, or POST /v1/machines/{id}/secrets. See Secrets.

All of these must hold, or the request is forwarded with the placeholder untouched:

  1. The request is HTTPS.
  2. Its host is one of the secret’s hosts (and on the machine’s allow).
  3. The Host header names the same host the connection was opened to.
  4. The placeholder is in the secret’s presentation slot.
  5. The method and path match, if you set them. A path that is not already clean — with . or .. segments, //, a backslash, or their %-encodings — never matches, and a method-override header (X-HTTP-Method-Override and the like) naming another method means the method does not match.

Responses are masked. If the upstream echoes the credential back — in a header or the body — the machine receives the placeholder instead. Masking matches the value as it was stored: an upstream that echoes it transformed — base64-encoded, JSON \u-escaped, HTML-escaped, split across fields — is not caught. Do not rely on masking to hide a credential from an API that returns it in another form. Plain and gzip responses are inspected; a response in any other encoding is refused (below) rather than passed through unchecked. Response trailers are dropped.

Allow-list changes reach open sessions. Removing a host from the machine’s allow closes connections already open to it, intercepted ones included, and every request on a kept-alive connection is checked against the current list.

The machine trusts its own certificate authority

Section titled “The machine trusts its own certificate authority”

To swap a value into an HTTPS request, the egress path has to read it, so it presents a certificate for those hosts from a certificate authority made for this one machine. The machine is set up to trust it: it is in the system trust store, and every command gets SSL_CERT_FILE, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE and NODE_EXTRA_CA_CERTS pointing at it. curl, Python, Node and most HTTP libraries work without changes.

  • Only the secret’s hosts are intercepted. Every other allowed host is passed through untouched, with end-to-end TLS to the real server.
  • A client with its own trust store (a pinned certificate, a bundled CA list, a JVM keystore) will refuse those hosts until it is pointed at the system bundle.
  • HTTP/1.1 only on those hosts. Clients negotiate it automatically.
  • No WebSocket (or other Upgrade) on those hosts — see below.

These come from the egress path, not from the API, and only on hosts a proxy secret is for. Each is a small JSON body with a code.

Status code Meaning Retry?
503 egress_secret_unavailable The value is not loaded on the egress path yet — for example just after it restarted. It is restored automatically within about a minute Yes
502 egress_upstream_unavailable The real host could not be reached Yes
502 egress_cannot_mask The response used an encoding other than gzip, so it could not be checked for the credential No
421 egress_host_mismatch The Host header named a different host from the connection’s No
501 egress_upgrade_not_supported A WebSocket or other protocol upgrade No
403 egress_domain_not_allowed The host was removed from the allow-list while the connection was open No
403 egress_address_not_public The host resolves only to a private or reserved address No

A request whose placeholder is never redeemed (wrong slot, wrong path, http://) gets no error from us — it reaches the upstream with the placeholder, which will usually answer 401.

Rotating in the dashboard gives every running machine it is bound to the new value before the rotate returns; stopped machines get it at their next start. If a running machine cannot be reached, the rotate says which one — the new value is stored, that machine keeps the previous one, and rotating again retries.

Unbinding and deleting work as for any secret: see When a change takes effect.

  • A command’s own env cannot set SSL_CERT_FILE, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE or NODE_EXTRA_CA_CERTS on a machine with proxy secrets — it would point HTTPS clients away from the machine’s certificate authority, and every call to the secret’s hosts would fail TLS. It is a 400 instead.
  • Protects against code on the machine reading the credential, copying it, or sending it anywhere — it never has the value.
  • Does not stop that code from using the credential against the hosts you named, within the method and path you allowed. Scope it as tightly as the API allows: a restricted key upstream, plus method and path_prefix here.
  • The value lives encrypted at rest in our database, and in memory on the egress path of the host running your machine while it is bound there. It is never written to that host’s disk, a log, or the Activity log.