Skip to main content

Your instance's wrapped secrets

When your application is provisioned as a per-tenant instance, the secrets it needs are generated for that instance and placed in its environment. Some of them can be placed there wrapped — ciphertext your application exchanges for the real value once, at start-up — so that the host's disk holds nothing usable.

This page is what your application does with them.

What can be wrapped, and what cannot​

An encryption key for data your application stores is the usual first thing to wrap, because losing it is unrecoverable: every row already written depends on it. But that is one purpose, not the purpose. A signing secret or an application-only API token is just as readable on a stolen disk, and worth wrapping for the same reason — replacing one of those costs a reset rather than the data, which makes them less urgent, not less exposed.

The real boundary is who reads the value, not how sensitive it is. Only secrets your application itself reads can be wrapped, because only your application can ask for them to be opened:

ExampleWrappable
Your application reads itencryption key, signing secret, application-only tokenyes
Another container in the instance reads itdatabase password, object-store credentialsno

The database password is handed to an off-the-shelf database image, and object-store credentials to a storage image. Those containers have no idea what a wrapped value is and would fail to start. Your deploy definition therefore names what to wrap explicitly — nothing is inferred.

Why wrap at all​

An instance's environment file sits on a host. Whoever obtains that host's disk — a stolen machine, a volume snapshot, a backup copied somewhere — obtains whatever is in that file.

A wrapped value is ciphertext that names who can open it. The host holds nothing that can open it: the wrapping is done with a public key, and only the control plane holds the private half. Your application asks for the value once at boot and keeps it in memory for the life of the process.

This is why a resolved secret must never be written back anywhere — not to a file, not to a cache, not into a log. A single copy written to disk undoes the whole mechanism.

The one rule​

A value you read arrives in one of two forms, and your application must handle both:

  1. Read the configured value as you do today.
  2. If it does not begin wrapped1., it is the value. Use it unchanged. Make no call — an instance that has not been migrated must not need the control plane reachable in order to start.
  3. If it does, exchange it for the value with one call (below).
  4. If that exchange fails for any reason, fail the start-up.

Step 4 is the rule that matters most, and the one a hurried implementation gets wrong. The tempting alternative is to carry on with the value you were given. For an encryption key, an application that does this starts, reports healthy, and encrypts every new row under something that is not the key — while every row already stored stays unreadable. A deployment that refuses to start is an incident somebody fixes that morning. A deployment that starts and quietly writes unrecoverable data is discovered much later, and by then the damage is the data.

The call​

POST {ORCHESTRATOR_BASE_URL}/tenants/{slug}/secrets/unwrap
Authorization: Bearer <token for your instance's own OIDC client>
Content-Type: application/json

{"wrapped": "wrapped1.orchestrator.k1.…"}

Answering:

{"secret": "…"}

Authenticate as yourself. The bearer token comes from a client_credentials grant using the OIDC client issued to your instance — the OIDC_CLIENT_ID and OIDC_CLIENT_SECRET already in your environment. That client is what proves the caller is this tenant, and no other credential does. A platform-scoped token is refused here like any other caller that is not this tenant: it is both more authority than an instance should hold and silent about which tenant is asking.

The slug and the control plane's address are in your environment too, as ARCHENSTACK_TENANT_SLUG and whatever your deploy definition maps {orchestrator.baseUrl} to.

ResponseMeans
200the value, in secret
403you are not the client registered for that tenant
400not a wrapped value, names a different authority, or was wrapped under a key the control plane does not hold — the body says which
400it belongs to a different tenant, was altered, or cannot be opened — reported uniformly, so the answer never reveals which

Every unwrap is recorded against your instance and the client that asked. The secret itself is never logged.

Declaring it​

In the env block of your deploy definition:

{
"env": {
"generated": {
"APP_ENCRYPTION_KEY": { "bytes": 32, "enc": "base64" },
"JWT_SIGNING_SECRET": { "bytes": 48, "enc": "base64url" },
"DB_PASSWORD": { "bytes": 24, "enc": "base64url" }
},
"dataAtRest": ["APP_ENCRYPTION_KEY"],
"wrapped": ["APP_ENCRYPTION_KEY", "JWT_SIGNING_SECRET"],
"wrappingAuthority": "orchestrator",
"platform": {
"ORCHESTRATOR_BASE_URL": "{orchestrator.baseUrl}"
}
}
}

Note what is not in wrapped: DB_PASSWORD, because the database container reads it.

  • wrapped — which generated secrets are stored as ciphertext on the host.
  • wrappingAuthority — who your application will ask. Declaring it is what makes the provisioning agent write wrapped values instead of plain ones.
  • ORCHESTRATOR_BASE_URL — how your application learns where to ask. Name the variable whatever your application already expects; {orchestrator.baseUrl} is the part that matters.

dataAtRest is a different statement​

It answers what is unrecoverable if lost, not what is stored wrapped. It drives a separate protection: the agent refuses an update that would mint a fresh value for one of these, because every row already stored depends on the old one. Without it, that case looks like any other missing value and is replaced silently.

Declare it whether or not you wrap anything. An encryption key usually appears in both lists; a signing secret usually appears only in wrapped.

Ship the declaration and the implementation together​

wrappingAuthority is what switches the agent over, so an image that declares it without being able to open a wrapped value will start and then fail on the first secret it reads.

Depend on the library rather than writing this​

You do not have to implement any of the above. The instance side ships as a library in five languages, each depending on nothing but its language's standard library — Rust excepted, because std has no HTTP client:

LanguagePackageImport
Pythonarchenstack-instance-envarchenstack_instance_env
Node.js@archenstack/instance-env@archenstack/instance-env
Javaio.archenstack:archenstack-instance-envio.archenstack.instanceenv
Gogithub.com/archenstack/archenstack-instance-env-goinstanceenv
Rustarchenstack_instance_envarchenstack_instance_env

Open the values before your configuration is read and put them back into the environment. Each library does exactly that and nothing more: it reads the variables an image declares as wrapped, exchanges the wrapped ones, and leaves a plain value untouched without making any call at all.

The five are held to one contract by e2e/wrapped_secret_probe.py in this repository, which serves both endpoints itself and inspects the requests that arrive — so what the libraries send is pinned, not merely described. If you are implementing this in a sixth language, that probe is how you check your work: point it at your own entry point and it runs the same thirty-four assertions against it.

The per-language demos in the separate demo repository each carry their own copy of the reader rather than depending on these packages, so that every demo reads standalone. For a real application, depend on the library.

Open them before your configuration is read, and put the opened values back into the environment. Every ${VAR} reference you already have then reads exactly the variable it always read, and nothing else in your application learns that the mechanism exists. That is what makes adopting this a change to one place rather than to every consumer of the secret.

What happens to an existing instance​

Nothing, until it is updated to an image that declares wrappingAuthority. At that update the agent wraps the values the instance is already using and writes the wrapped form — the values themselves do not change, only how they are stored, so nothing already encrypted is affected. There is no separate migration to run.

Moving an instance back to an image that declares no authority is refused, because neither the host nor that image can turn the wrapped values back.

What this does not protect​

Wrapping protects secrets at rest on the host. It does not protect a running instance: while your application is up, the values are in its memory, which is what lets it serve requests at all.

It also does not make a lost control plane unrecoverable for you. Every generated secret — wrapped or not — is escrowed in its plain form when the instance is first provisioned, sealed to a different key pair. That separation is deliberate: losing the wrapping key costs a re-wrap, not your data.

See also​