Skip to content

Secrets and rotation

Where secrets live in a Taimen installation, with what permissions, how to track expiry, and how to change each kind of secret: scheduled rotation and replacement after compromise. This article is for the operations engineer and the person responsible for security.

Principles

  • The class of a secret decides where it lives. Infrastructure secrets of the platform (database passwords, signing keys, bootstrap tokens, credentials of the components' service accounts) live only in .env and the secrets/ directory of the superproject clone (both in .gitignore) and in the credential files of workstations and the runner host. This article covers them. Agent secrets are files on fleet nodes (see below).
  • Permissions are 0600 for a file and 0700 for a directory. The control-plane client refuses to read ~/.config/iam/credentials.json if the file is accessible to anyone other than its owner (iam_credentials_file_permissions).
  • Platform scripts do not print secrets: make secrets and deploy/bootstrap.py write them straight to files with 0600 and output only identifiers and public PAT prefixes.
  • A secret that has passed through a chat, ticket, screenshot, or shell history is considered compromised and is reissued.

Inventory

Platform host: .env

Variable Who uses it How to replace
CP_POSTGRES_PASSWORD, IAM_POSTGRES_PASSWORD, MEMORY_POSTGRES_PASSWORD, NOTIFY_POSTGRES_PASSWORD Databases and services ALTER ROLE in the database, then .env, then recreate the service (see below)
KEYCLOAK_DB_PASSWORD The keycloak role in keycloak-db The same way as the database passwords
CP_BOOTSTRAP_TOKEN Control Plane POST /api/v1/bootstrap .env and up -d control-plane-api
IAM_BOOTSTRAP_TOKEN IAM administrative operations (X-IAM-Bootstrap-Token) .env and recreate iam-service
MEMORY_API_KEY Static memory key: memory-service, the core before it switches to a service account .env and recreate all consumers
KEYCLOAK_ADMIN_PASSWORD The initial Keycloak administrator See "Keycloak"
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY MinIO root account; only minio-bootstrap uses it See Object storage
CP_S3_ACCESS_KEY_ID, CP_S3_SECRET_ACCESS_KEY The Control Plane user in object storage (its own bucket only), created by minio-bootstrap .env, rerun minio-bootstrap, then recreate control-plane-api, control-plane-worker, context-adapter; for an external S3, change it at the provider first (see Object storage)
LLM_API_KEY Key of the OpenAI-compatible LLM provider for memory and executors At the provider, then .env and recreate the consumers

make secrets fills all the listed passwords, bootstrap tokens, MEMORY_API_KEY, the Keycloak administrator password, and MinIO keys with random values if they are empty.

There are no secrets with default values in deploy/local/compose.yml: the database passwords and bootstrap tokens of all profiles, including experimental ones, are declared required (${VAR:?…}) and are generated by make secrets. If a key is missing from .env (the file was created from an old .env.example or the line is commented out), make secrets adds it.

Platform host: secrets/

File What Who writes it Who reads it
iam-signing.pem Private access token signing key (RSA 3072) make secrets iam-service (uid 10001, docker secret)
harness-pat Operator PAT (read/write/admin) bootstrap, step 4 Moved to the operator's workstation
control-plane-iam.env CP_IAM_CLIENT_ID, CP_IAM_CLIENT_SECRET: the core service account bootstrap, step 2a docker compose (env_file of the three core processes)
runtime-console-oidc-secret Secret of the console OIDC client runtime-console (the same as in the IdP); 0600, owned by uid 10001 make secrets or the OIDC client setup script console (uid 10001, docker secret)
runtime-console-cookie-secret Console cookie key, at least 32 bytes; 0600, owned by uid 10001 make secrets console (uid 10001, docker secret)

Permissions: everything is 0600. Files mounted into a container (signing keys) must be owned by uid 10001 on Linux:

sudo chown 10001:10001 secrets/iam-signing.pem \
  secrets/runtime-console-oidc-secret secrets/runtime-console-cookie-secret
sudo chmod 600 secrets/runtime-console-oidc-secret secrets/runtime-console-cookie-secret
sudo chmod 600 secrets/*.pem

Do not relax permissions to 644 instead of using chown: these are private keys and tokens. Env files (*.env) are read by docker compose on the host; their owner is whoever runs compose.

Runner host and workstations

Where Secret Comment
Runner Agent PAT A container secret file or the runner user's ~/.config/iam/credentials.json
Runner CLAUDE_CODE_OAUTH_TOKEN The coding agent's subscription token; it belongs to a person, not to the agent. Issued with claude setup-token on a machine with a browser
Runner Forge token (for pushing task branches) Minimal permissions: write only to the task repositories, read the neighbors
Operator ~/.config/iam/credentials.json A JSON object: the key is the IAM address, tenant, and principal separated by a vertical bar; the value has a token field; mode 0600

Fleet nodes

A secret of an agent is a file in the secretsDir directory on the node: one file per secret, with the file name matching the name in the agent description's placement.secrets (see Nodes and fleet). Agent PATs are not in this directory: fleet-controller issues them and delivers them to the node sealed with the node key.

File in secretsDir For whom What
claude-oauth-token claude-code coding agents The subscription token; it belongs to a person
github-token Coding agents and the git-connector observation source Forge token: for coding agents, publishing task branches; for the connector, reading repositories and, if ciRuns is enabled in observe, CI runs (ci.run_observed)

The directory is 0700, the files 0600, owned by the executor image's uid (10001). The node offers a new file to the controller with its next report; restarting the node is not needed.

Credential lifetimes

Credential Lifetime Parameter
IAM access token 300 s IAM_TOKEN_TTL_SECONDS (default)
PAT, default lifetime 30 days IAM_PAT_DEFAULT_TTL_SECONDS=2592000
PAT, maximum lifetime 365 days IAM_PAT_MAX_TTL_SECONDS=31536000; longer gives 422 expiry_too_long
PAT issued by deploy/bootstrap.py 180 days The --pat-ttl argument (seconds)
Freshness of a person's sign-in for PAT issuance 300 s IAM_PAT_MAX_AUTHENTICATION_AGE_SECONDS
Service account (client credentials) No expiry Revocation: …/service-accounts/{client_id}:revoke

IAM parameters are not passed through in deploy/local/compose.yml: to change the defaults, add them to the environment of the iam-service service via compose.override.yml.

Rotation does not extend a PAT

POST …/platform-access-tokens/{id}:rotate changes only the secret: the new token inherits the predecessor's audiences, scope ceiling, and expiresAt. It is a tool for leaks, not for extension. To extend access, issue a new PAT and revoke the old one.

How to track expiry

source <(grep -E '^(IAM_BOOTSTRAP_TOKEN|IAM_TENANT_ID)=' .env)
curl -s "http://127.0.0.1:18010/api/v1/tenants/$IAM_TENANT_ID/platform-access-tokens" \
  -H "X-IAM-Bootstrap-Token: $IAM_BOOTSTRAP_TOKEN" \
  | python3 -c 'import json,sys; [print(t["expiresAt"][:10], t["publicPrefix"], t["name"]) for t in sorted(json.load(sys.stdin), key=lambda t: t["expiresAt"])]'

The response contains only active tokens (includeRevoked=true includes revoked ones), with the fields publicPrefix, name, principalId, expiresAt, lastUsedAt. Set a reminder two weeks before the nearest expiresAt.

Procedures

All examples below use these environment variables:

IAM=http://127.0.0.1:18010
T=<tenant-id>                       # IAM tenant
H="X-IAM-Bootstrap-Token: $IAM_BOOTSTRAP_TOKEN"

Reissuing an agent PAT (scheduled)

An agent (a principal of kind agent) has no human sign-in, so it does not need a fresh authentication context.

# 1. New PAT; Idempotency-Key is required (without it: 400 idempotency_key_required)
curl -s -X POST "$IAM/api/v1/tenants/$T/principals/<agent-principal-id>/platform-access-tokens" \
  -H "$H" -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"name": "runner-2026-q3", "audiences": ["control-plane"],
       "scopeCeiling": ["control-plane:read", "control-plane:write"],
       "expiresInSeconds": 15552000}' > /tmp/pat.json
# the token field is a secret and is shown exactly once
  1. Install the token on the runner host (a container secret file or the runner user's credentials.json, 0600), and delete /tmp/pat.json.
  2. Restart the executor and make sure it claimed a task or at least opened a session (no invalid_token in the logs).
  3. Revoke the previous PAT:
curl -s -X POST "$IAM/api/v1/tenants/$T/platform-access-tokens/<old-credential-id>:revoke?reason=superseded" \
  -H "$H"          # 204

scopeCeiling must be a subset of the allowedScopes of the specified audiences; otherwise you get 422 invalid_scope_ceiling. A PAT is issued only to a principal of kind human or agent; for service_account you get 422 principal_kind_not_allowed (services have their own client credentials flow).

Reissuing a person's PAT

IAM issues a PAT to a person only with a fresh (no older than 300 s) authentication context. Recording the context and issuing the token run one right after the other:

curl -s -X POST "$IAM/api/v1/tenants/$T/principals/<human-principal-id>/authentication-contexts" \
  -H "$H" -H "Content-Type: application/json" \
  -d '{"issuer": "https://platform.example.com/iam", "acr": "bootstrap", "amr": ["bootstrap-script"]}'

curl -s -X POST "$IAM/api/v1/tenants/$T/principals/<human-principal-id>/platform-access-tokens" \
  -H "$H" -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"name": "operator-2026-q3", "audiences": ["control-plane"],
       "scopeCeiling": ["control-plane:read", "control-plane:write", "control-plane:admin"],
       "expiresInSeconds": 15552000}'

If more than 300 s pass between the calls, you get 403 authentication_context_expired; if there is no context at all, 403 authentication_context_required. deploy/bootstrap.py does the same for the operator if the secrets/harness-pat file does not exist: delete (rename) the file and run bootstrap again, then revoke the previous PAT.

Replacing a leaked PAT

  1. Cut off access in Control Plane immediately: revoke the identity binding. This closes access at once, without waiting for already issued access tokens to expire (up to 300 s):

    curl -s -X POST https://platform.example.com/api/v1/iam-bindings/<binding-id>:revoke \
      -H "Authorization: Bearer <admin access token>"
    
  2. Revoke the PAT in IAM (:revoke), or the owner revokes their own token without bootstrap authority:

    curl -s -X POST "$IAM/api/v1/platform-access-tokens:revoke-self" \
      -H "Content-Type: application/json" -d '{"token": "<leaked PAT>", "reason": "leaked"}'
    
  3. Issue a new PAT (procedures above) and restore the binding with another POST /api/v1/principals/<principal-id>/iam-bindings with the same permissions.

  4. Review the IAM audit and the Control Plane log for the period of the leak.

The detailed scenario is in Emergency procedures.

Rotating a service account secret

Bootstrap changes the secret of the core and platform service accounts (control-plane-iam.env, notification-iam.env, fleet-iam.env): if the env file does not exist, it asks IAM for a new secret of the same account (PATCH {"rotateSecret": true}, see Service accounts) and writes it to the file at once; the old secret stops working. The principal and the clientId do not change.

mv secrets/control-plane-iam.env secrets/control-plane-iam.env.old
python3 deploy/bootstrap.py --env .env --name <env>
tools/compose up -d control-plane-api control-plane-worker context-adapter
shred -u secrets/control-plane-iam.env.old

Rotating the IAM signing key

IAM publishes one key in /.well-known/jwks.json: the current one. Services verify signatures against JWKS with a cache and refresh it when they encounter an unknown kid.

  1. Generate a new key and give it a new kid:

    openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out secrets/iam-signing.new.pem
    sudo chown 10001:10001 secrets/iam-signing.new.pem && chmod 600 secrets/iam-signing.new.pem
    
  2. In .env: IAM_SIGNING_KEY_FILE=./secrets/iam-signing.new.pem, IAM_SIGNING_KEY_ID=<new kid>.

  3. tools/compose up -d iam-service.
  4. Check curl -s $IAM/.well-known/jwks.json: it shows the new kid.

What happens: PATs and service account secrets do not depend on the signing key and stay valid. Access tokens signed with the old key (they live up to 300 s) stop passing verification as soon as a service refreshes JWKS; clients get 401 and exchange the PAT again. Rotate during a period of low activity. Keep the old key file until the end of the window as a rollback point.

Signing key compromise

A leak of iam-signing.pem lets an attacker forge an access token for any principal. Rotate the key immediately and restart the services that verify tokens (control-plane-api, memory-service, and others) so they drop the JWKS cache with the old key.

Database passwords

The PostgreSQL image applies POSTGRES_PASSWORD only when it initializes an empty volume. Changing .env on an existing database does not change the password; the service simply stops connecting. The order:

# 1. Change the role password in the database
tools/compose exec control-plane-db psql -U control_plane -d control_plane \
  -c "ALTER ROLE control_plane PASSWORD '<new password>'"
# 2. Write the same password to .env (CP_POSTGRES_PASSWORD)
# 3. Recreate the consumers
tools/compose up -d control-plane-api control-plane-worker context-adapter

For the keycloak role in keycloak-db, the same: tools/compose exec keycloak-db psql -U keycloak -d keycloak -c "ALTER ROLE keycloak PASSWORD '…'", then KEYCLOAK_DB_PASSWORD and tools/compose up -d keycloak.

Keycloak

Secret Specifics Replacement procedure
KEYCLOAK_ADMIN_PASSWORD The variable creates a temporary administrator only on the first start, when there is no administrator Change the administrator password in the Keycloak console or through the Admin API; keep .env consistent for the scripts

Realm user passwords are changed through the Admin API, the admin console, or deploy/keycloak/keycloak-users.py; see Keycloak as the external IdP. The realm has one client secret: the confidential console client runtime-console uses the secrets/runtime-console-oidc-secret file; the other clients (human-harness, iam-service) are public or bearer-only. To replace the console secret, rerun deploy/keycloak/keycloak-runtime-console-client.py with the new file (the script brings the client in line with the file) and recreate the console container.

Coding agent subscription token and forge token

  • A person issues the subscription token on a machine with a browser (claude setup-token); you cannot sign in interactively on the runner host. Replacement: new token → the executor's secret file or env file → restart.
  • The subscription token is revoked on the provider's side. After revocation the executor keeps claiming tasks and failing them, so stop it.
  • The forge token is replaced the same way; to verify, check that the next task's branch is published successfully (the commit artifact has published: true).
Frequency Action
Weekly List PATs with expiresAt within 30 days
2 weeks before expiry Reissue the PATs of executors and operators
Quarterly Rotate MEMORY_API_KEY, the LLM provider key, service account secrets
Yearly Rotate the IAM signing key and database passwords
Immediately Any secret that has passed through correspondence or logs

See also