Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Credentials for workloads

The printer's old shared secret has turned up in places nobody meant to put it. This lesson compares the credentials a workload can hold, shows why a short lifetime limits what a leaked copy is worth without anyone noticing the leak, and follows how a credential that changes every hour reaches the running software.

Where the key ended up

A week after the overnight burst of print jobs, the printer's code scanner raises two alerts. The shared print lab secret appears in an old layer of the render service's container image, and again in a debug log that printed the service's configuration when it started. Removing the line from today's image does not help, because a container image keeps every layer it was built from. Every earlier version still contains the secret, and anyone who ever downloaded one of them has a copy. The team rotates the secret, then asks which credentials a workload should hold at all, and how they should reach running software.

Static secrets spread because using them means copying them. An environment variable is visible to anything that can inspect the process, and it often appears in crash reports. A configuration file gets committed to a repository. A startup log prints the settings it loaded. A pipeline log echoes the variables a job used. A developer copies the file to a laptop to run the service locally.

Every copy is as powerful as the original, and lasts as long. Secret scanning finds some of those copies, and finding them is worthwhile, but the more durable fix is a credential that is not worth much once someone has copied it.

Kinds of workload credentials

Workload credentials fall into three broad families, which build on the comparison in Secrets and key pairs.

Bearer secrets are API keys, client secrets and long-lived static tokens. Presenting the value is the proof, so the workload sends it with its requests, and anyone who sees it can use it.

Key pairs let the workload prove possession of a private key by signing something, such as a client assertion or a TLS handshake, without sending the key itself, as Secrets and signed assertions showed for a token request. A captured request does not reveal the key. A captured client assertion that has not been used yet could still be presented once during its short validity, and replay tracking refuses only the later uses, so it cannot tell whether the first presenter was the real workload. The key file itself can still be copied if it is stored carelessly, the risk Storing and using keys addressed.

Issued short-lived credentials come from the workload's identity system after attestation and are renewed automatically. Two forms are common. The first is a certificate whose subject alternative name holds the workload's identity, used for mutual TLS, where each side of a connection presents a certificate. SPIFFE calls this an X.509-SVID, for SPIFFE Verifiable Identity Document. Its private key is generated on the workload's own machine and never leaves it. The certificate itself is public, so holding a copy proves nothing: the workload proves it is the holder by signing a fresh random value with that private key, its holder key, and anyone can check the signature against the public key the certificate names. The second is a signed JWT carrying the same identity, which SPIFFE calls a JWT-SVID, for presenting to an API. Decoded, the render service's token for the storage service looks like this:

{
  "sub": "spiffe://printer.example/prod/render",
  "aud": ["https://storage.printer.example"],
  "iat": 1790000600,
  "exp": 1790000900
}

All domains, credentials, and tokens in these examples are fictional. The token is signed with a key that belongs to the printer.example trust domain. Its subject is the workload's identity, it is meant only for the storage service, and it expires five minutes after it was issued. It is still a bearer token: anyone holding a copy could present it to the storage service until it expires, which is why the audience and the lifetime are kept so tight.

The table compares the four credentials a workload is most likely to hold. Read the last column as the question the code scanner's alerts raised: if a copy of this credential leaks today, what does it give whoever finds it?

Workload credentials compared
CredentialTypical lifetimeWhat travels with a requestWhat a leaked copy gives an attacker
API key or client secretMonths or years, until someone rotates itThe secret itselfFull use until someone notices and replaces it
Private key for signed assertionsMonths or yearsA short-lived signed assertionAn unused captured assertion can authenticate once before it expires; a used one should be refused. A copied key can make fresh assertions until its registration is removed
Short-lived certificateMinutes to hours, renewed automaticallyThe certificate and a signature in the TLS handshakeA copied private key works only until the certificate expires
Short-lived signed tokenMinutes, renewed automaticallyThe tokenUse at the token's one audience until it expires

Short-lived by default

A lifetime is a control that works without anyone noticing a problem. If the render service's certificate lasts one hour, a snapshot of that certificate and its key stops authenticating within the hour. The old shared secret would have kept working for years.

That limit holds for a copy taken once. It assumes whoever took the copy cannot also renew it or obtain the next credential, so renewal must use fresh key material that stays protected. Someone who keeps control of the running workload, or of the local API that hands it credentials, can collect each new credential as it arrives, and that is a different incident to contain.

Short lifetimes also change what rotation means. Replacing a static key is a project: find every place it is used, update them in the right order, and hope nothing was missed. A credential issued automatically is replaced dozens of times a day, so renewal is exercised constantly and a broken renewal shows up at once rather than on the day a key must be replaced in a hurry.

Renewal should start well before expiry, often around halfway through the lifetime. If the identity server is briefly unavailable, workloads keep using credentials that are still valid, and the outage does not spread to every service. Verifiers should also allow a little clock difference between machines when they check issue and expiry times.

Revocation matters less as well. Rather than maintaining lists of revoked certificates, the printer can usually wait for a credential to expire. In an emergency it removes the registration entry, so no new credential is issued, and the last one runs out shortly afterwards.

Delivering credentials to a running workload

A credential that changes every hour has to reach the workload without anyone copying it by hand. There are a few common routes.

A local workload API, like the node agent in Attesting a workload, gives the workload its credential on request and pushes a replacement before each one expires. The orchestrator can also mount the credential as a file and replace it in place, provided the workload reads the file again when it changes.

Cloud platforms offer a metadata endpoint at a special address that only the machine itself can reach. A workload asks it for short-lived credentials for the role assigned to its machine, and the platform answers. This is convenient, and it has one well-known weakness: an endpoint that is not protected well enough answers any request made from that machine, including one a vulnerable workload was tricked into making. If a web service on the machine has a server-side request forgery bug, which lets an attacker make the service fetch a URL of the attacker's choosing, the attacker can make it fetch the machine's credentials and then use the service's identity from anywhere.

Platforms defend against this by requiring a session token first, obtained with a kind of request a simple forgery cannot make, and by limiting how many network hops the credential response may travel, which makes it harder to relay. These controls narrow the risk without removing it, because their effect depends on which requests the vulnerable service can be made to construct. Each platform documents its own metadata settings and their defaults differ, so check what the platform actually enforces. Applications should also refuse to fetch internal addresses, and the link-local range the metadata endpoint usually sits in, on a user's behalf.

Secret managers fit into this picture once the first-secret problem is solved. The render service authenticates to the secret manager with its workload identity, and some secret managers then issue dynamic secrets, such as a database password created for one service on request and deleted when its lease ends.

When a static secret remains

Not every service can accept a short-lived credential. The shipping company the printer uses for international orders accepts only an API key. That key will exist for months, so the printer limits what it can do and who can reach it.

The key lives in the secret manager, not in configuration or an image, and only the batch job's identity may read it. The batch job loads it into memory when it needs it and never writes it to a log. The team rotates it on a schedule and immediately whenever it might have been exposed, following Rotating client credentials. Its use is monitored, so a request from anywhere other than the batch job is noticed. And the team keeps asking the shipping company for a better option, because every one of those controls depends on someone noticing, which a lifetime never does.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

A snapshot of the render service's one-hour certificate and its key leaks. Later renewals use fresh keys, and whoever took the snapshot cannot renew or reach the workload. What limits this copy? 1 of 3

Choose one answer.

The render service's certificate lasts one hour. Why does its node agent renew it after about thirty minutes rather than just before it expires? 2 of 3

Choose one answer.

A web service can be made to fetch URLs and can reach a metadata endpoint that releases its role credentials to such requests. Why is that serious? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity