TExcelTAD

The Secret Lifecycle

A secret is not a value you set once. It has a lifecycle, and most incidents happen at a stage the team never designed for: nobody knows who still uses an old key, or rotating it requires a deploy freeze, or revoking it breaks three services nobody remembered.

create ──► store ──► distribute ──► use ──► rotate ──► revoke ──► (audit at every step)
Stage Questions to answer Good answer
Create Who generates it? How random? generated by a machine (Vault, the cloud provider, openssl rand), never chosen by a person
Store Where does the master copy live? one secrets store (Vault, a cloud secrets manager), or encrypted files (SOPS); never a wiki, chat or .env in Git
Distribute How does it reach the workload? the workload authenticates with its identity and fetches it; humans don't copy it around
Use Where does it exist in plain text? in the process memory and maybe a tmpfs file; not in logs, images, environment dumps or plans
Rotate Can you replace it on a Tuesday afternoon without an outage? yes, routinely, by automation (Rotation Without Downtime)
Revoke Can you kill it within minutes after a leak? yes, and you know every consumer
Audit Who read it, when? an audit log per access (Vault's audit devices, CloudTrail for AWS Secrets Manager)

Static vs dynamic secrets

A static secret is created once and shared: the database password in a KV store, an API key from a SaaS dashboard. It lives until someone rotates it, and every consumer has the same value, so a leak can't be traced to one consumer.

A dynamic secret is created on demand, per consumer, with a lease: Vault's database engine creates a fresh PostgreSQL user for each instance of linkly, valid for one hour, and drops it when the lease ends (Dynamic Database Credentials). Cloud identities work the same way: an IAM role assumed through OIDC hands out credentials that expire in minutes.

The model compares how long a leaked credential stays useful under three regimes. A leak happens at a random time; the attacker can use the credential until it is rotated or expires:

python · try it yourself
import random

random.seed(7)
HOURS = 24 * 365                     # one year, hour by hour
regimes = {
    "static, rotated yearly":   24 * 365,
    "static, rotated monthly":  24 * 30,
    "dynamic, 1h lease":        1,
}
leaks = [random.uniform(0, HOURS) for _ in range(10_000)]

for name, period in regimes.items():
    # the credential leaked at time t stays valid until the next rotation boundary
    exposure = [period - (t % period) for t in leaks]
    avg = sum(exposure) / len(exposure)
    print(f"{name:26} average exposure {avg:8.1f} h   worst {max(exposure):7.1f} h")
static, rotated yearly     average exposure   4393.6 h   worst  8758.7 h
static, rotated monthly    average exposure    365.8 h   worst   719.9 h
dynamic, 1h lease          average exposure      0.5 h   worst     1.0 h

The average exposure is half the rotation period, so a credential that never rotates is exposed for as long as it lives. Short-lived, per-consumer credentials don't make leaks impossible; they make them expire.

Secret zero

Every scheme has a first credential the workload must already hold to fetch the others: Vault's AppRole secret_id, an age private key, a cloud access key. This is the secret zero problem. The goal is to make secret zero something the platform provides instead of something a person copies:

  • Cloud and Kubernetes identities: the pod's service-account token, the VM's instance identity, a CI job's OIDC token. Nobody handles them; the platform signs them and they expire (Kubernetes Auth, JWT/OIDC Auth for CI).
  • Response wrapping: when a secret zero must be delivered, deliver it once, wrapped in a single-use token, so interception is detectable (Auth Methods).
  • KMS-held keys: SOPS or Sealed Secrets keys that never leave a KMS or a controller.

Ownership

Every secret needs an owner (a team), a consumer list and a rotation story. In Vault this is visible in the path layout and policies (secret/linkly/... readable only by linkly's role); in SOPS in .sops.yaml creation rules. If a secret has no owner, nobody rotates it.

Test yourself

What makes a dynamic secret safer than a static one?

  1. It is longer
  2. It is created per consumer with a lease, so it expires on its own and a leak points to one consumer
  3. It is stored in Git
  4. It never needs authentication

What is the 'secret zero' problem?

  1. Secrets with zero length
  2. The first credential a workload needs to fetch the rest; ideally a platform-provided identity rather than a copied secret
  3. A Vault error code
  4. Rotating a secret to an empty value