Secrets
A project’s admins set, replace and delete its secrets. A value is never shown again, to anyone.
A trusted step is given those it names in secrets:, all of them when it has no secrets:, and none for an
empty list. It fails if one it would get is missing or cannot be read. Untrusted steps get none.
Set the keys on both Workers, fiber-api and fiber-engine: the first stores values, the second gives
them to agents. When replacing a key, do each step on both. Only
fiber-api reports a missing or malformed key as not ready; on fiber-engine, steps fail instead, or wait while a
Secrets Store entry that the binding names cannot be read.
| Setting | Meaning |
|---|---|
FIBER_SECRETS_KEY |
32 random bytes as 64 hex digits (openssl rand -hex 32). Without it nothing can be stored; malformed, the server is not ready. Keep a copy: values cannot be read without it, and Cloudflare does not show it again. |
FIBER_SECRETS_KEY_PREVIOUS |
Other keys, separated by commas. They decrypt and never encrypt. |
Each is a Worker secret (wrangler secret put), or a Secrets Store binding of that name with the
workers scope. Never put one in vars.
A name is an environment variable name and does not start with FIBER_. A value is at most 48 KiB
and not empty. A project has at most 100, and no more than can be masked in a step’s log: large
values of several lines reach that first.
Replace the key
Section titled “Replace the key”Setting a Worker secret deploys at once, and for a while old and new code run side by side. So change one setting at a time, and let each reach everywhere before the next:
- Set
FIBER_SECRETS_KEY_PREVIOUSto<old>,<new>. Everything can now read both. - Set
FIBER_SECRETS_KEYto<new>. New values use it. - Get the new key’s id:
printf %s "$NEW_KEY" | pnpm -s --filter @fiber/api secret-key-id. As an instance admin,POST /api/secrets/reencryptwith{"key": "<id>"}. Whilenextis not null, add"after": "<next>". A 409 means a server that has not got the new key yet answered, and changed nothing: try again. Go on untilleftis 0. - Wait a few minutes, and do step 3 again: a server with the old key may have stored one meanwhile.
When
leftis still 0, setFIBER_SECRETS_KEY_PREVIOUSto<new>, or remove it. Remove a binding before what it names in Secrets Store: one that cannot be read stops secrets being stored.
Keep the old key somewhere safe: a restored backup may need it.
unreadable counts values no configured key can read. They stay as they are, and stay in left; find
the key or have the project set them again.