Forged tokens and stolen signing keys
A stolen sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier. starts from a real sign-in; a forged token starts from none. This lesson looks at the two ways to get a token nobody issued, stealing the key that signs and finding a validator that does not insist on it, and then at keeping signing keys out of reach, noticing a token without a sign-in, and what Cedar does when a signing key is exposed.
A token nobody issued
Cedar's admin console lets IT staff look up and change employees' accounts, and it accepts access tokens from Cedar's identity providerA service that authenticates users and tells other applications about the sign-in, so those applications never handle the users' passwords. In OpenID Connect it is called an OpenID Provider.. Before it acts on a token, it checks that a trusted issuer signed it, that it was issued for the console, that it is the right type of token and still within its lifetime, and then that the person it names may do what the request asks. A valid signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. proves only that someone holding the issuer's key signed those bytes. It says nothing about whether anyone actually signed in.
A forged token breaks that assumption. It passes the console's checks, but no sign-in produced it. An attacker can get one in two ways: by obtaining the private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. the sign-in service signs with, or by finding a validator that accepts tokens without real proof of that key. Either way, every protection that runs at sign-in is skipped. Passwords, passkeys, multi-factor authenticationSigning in with more than one type of factor, such as a password plus a code from an enrolled authenticator app. Two passwords are still one factor type, however many screens they appear on., and rules about devices and networks all apply to a sign-in, and a forger never goes through one.
Stolen sessions and replayed tokens, the subject of How sessions and tokens are stolen, start from a real sign-in by the victim, as the relay's copy of Riley's session did. A forgery has no such starting point. That makes it powerful, and it also leaves a gap in the records that defenders can look for.
Stealing the key that signs
With the private key, an attacker can sign any token they like, for any user, audience, role or lifetime. A verifier still applies its own rules, so a token whose audience or lifetime it does not accept fails anyway, but nothing that happens at sign-in applies. SAML has the same weakness. Whoever steals the certificateA signed statement that a public key belongs to a name, such as a website's hostname, for stated purposes and a limited period. A certificate authority signs it, so software that trusts the authority can connect the key to the name. and private key Cedar's identity provider signs SAML assertions with can sign an assertion for any Cedar employee, and the training service, the expense service and every other service that trusts Cedar's provider will accept it. The technique is known as Golden SAML. MITRE ATT&CK, a public catalog that gives each known attack technique a name and an ID, lists it as T1606.002. It was used in the widely reported 2020 supply-chain intrusion that began with compromised SolarWinds software to reach cloud services as any user the attackers chose.
Signing keys rarely leak through weaknesses in the cryptography. They leak from the places they are kept and used: a key file on a server, a backup or disk image that includes it, a source repository or build log, a crash dump or debugging snapshot taken while the key was in memory, or a test environment that was given a copy of the production key. An attacker with administrative access to the systems behind the sign-in service may simply read the key.
The damage grows with how widely the key is trusted. A key that signs tokens for one APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. exposes that API. A key that signs ID tokens and access tokens for every application Cedar's staff use, or that a provider hosting many organizations uses for all of them, exposes every one of them at once.
Validation that lets forgeries through
Some forgeries need no key at all, only a validator that does not insist on the right one. Decoding a token and reading its claims is not validating it, as Protecting credentials and messages pointed out, and Digital signatures set out the rule for validation itself: the verifier decides for itself which issuers, keys, and algorithms it accepts, and treats the token's header as a hint. Each common validation mistake breaks that rule in its own way.
- An unsigned token declares its algorithm as
noneand carries no signature. A validator that honors the declaration accepts claims anyone can write. - Algorithm confusion happens when the token chooses how it is checked. If the service signs with a private key, but a validator can be told that the token uses a shared-secret algorithm instead, it may check the token using the public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. as the shared secret. The public key is public, so anyone can produce a matching value.
- A key supplied by the token, in a header field that embeds a public key or points to an address to fetch one from, lets the attacker sign with their own key and tell the validator to use it. The signature verifies, and proves only that whoever wrote the token signed it.
- A key ID used as a lookup in the wrong way. The
kidheader names the key to verify with. A validator that uses it as a file path or inserts it into a database query, instead of looking it up in a fixed set of keys, can be steered to a file whose contents the attacker can predict, or into running a query the attacker wrote. - A token of the wrong type. An ID tokenIn OpenID Connect, a signed JWT from the provider, addressed to one client, saying which account authenticated, when, and in answer to which request. It reports a sign-in and is not used to call APIs., a logout tokenA signed JWT that an OpenID Provider sends directly to a relying party's server to say that a person's session at the provider has ended, naming them by sub, sid, or both. The relying party validates it like an ID token and ends its own matching session. and an access tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. from the same issuer are all signed JWTs, and each verifies with the same keys. A validator that does not check which kind it was given can accept an ID token where an access token is required. Explicit types, such as
at+jwtfor access tokens in thetypheader, and validation rules that no other kind of token can pass, prevent that confusion. - Missing issuer and audience checks let a genuine token from somewhere else through: one issued for a different application, or by another issuer whose keys the validator happens to hold.
- Accepting another tenant's issuer is the multi-tenant form of the same mistake. Providers that host sign-in for many organizations often sign every tenant's tokens with the same keys, so a token from a tenant the attacker created for themselves verifies perfectly. Only the issuer, which names the tenant, shows that it does not come from the organization the application serves.
RFC 8725, the JSON Web Token best current practices, describes each of these. The fix for all of them is the same. Configure the validator with the issuer it expects, the audience that identifies this application, the algorithms it allows, and where to fetch the issuer's keys, and reject anything outside that configuration. Maintained libraries do this when they are given explicit settings rather than left to their defaults. Validating an ID token and Issuer, audience, and authorized party apply these checks to ID tokens.
Each token below has one flaw. Choose the check that rejects it.
Which check catches it?
Simulation. These decoded tokens are made up, and answering sends nothing. Suppose Cedar signs in through a hosted identity provider that serves many organizations, where Cedar is tenant t-4821. Each token is sent to the expense service's business API, which expects the issuer https://idp.example.test/t-4821/, the audience https://api.expenses.example, and an ES256 signature from a key in that provider's published key set. Each token arrives at 10:20 UTC on 2 October 2026, and its exp of 1790937000 is 10:30 UTC that day.
Keeping signing keys out of reach
The strongest protection is a key nobody can copy. When the sign-in service's key is generated as non-exportable inside a hardware security module, a device built to hold keys and sign with them without ever releasing them, or a cloud key management service, as Storing and using keys described, an attacker who takes over the sign-in server can request signatures while they have that access but cannot take the key away. Removing their access ends their ability to sign anything new. Tokens they signed in the meantime remain a problem until they expire or the key is replaced, but the incident has an end.
Separate keys for separate purposes limit what one leak exposes: different keys for ID tokens, access tokens, and SAML assertions, for each environment, and, at a provider serving many organizations, for each organization where that is practical. A development key should never be trusted in production.
Access to signing configuration deserves the same care as the keys. Few people and services need permission to manage, export, or replace a key, and every use of that permission should be recorded. Changes to the published key set, to the list of trusted issuers, or to the keys an application accepts are rare, so an alert on each one costs little. An attacker who cannot steal a key may try to add one of their own instead, which Abusing federation and account linking examines.
Noticing a token without a sign-in
Every genuine token has a history at the issuer: a sign-in, a refresh or a client's own grant that produced it. A forged token has none. Comparing the tokens that applications accepted with the tokens the issuer recorded issuing can show that gap, as long as both sides keep the right records.
Finding that gap depends on the applications and APIs recording which tokens they accepted, by identifier rather than by value, and on someone comparing those records with the issuer's. The comparison can surface tokens with:
- an identifier the issuer has no record of issuing;
- a user who had no sign-in or refresh around the time the token says it was issued;
- a lifetime longer than the issuer ever grants, or an issue time in the future;
- a combination of audience, scopes, or roles the issuer never produces;
- more tokens carrying a key's identifier than the key service recorded signatures for.
Each of these is a lead, not a verdict. Records expire before anyone looks, not every token carries an identifier such as jti, refreshes and client grants leave different traces from sign-ins, and clocks drift. A forger can also copy a genuine identifier into a token. So each innocent explanation is ruled out before anyone concludes that a token was forged. What remains is a useful distinction: a stolen token always traces back to a genuine issuance somewhere, and a forged one never does.
When a signing key is exposed
A planned key rotation overlaps the old and new keys so that nothing breaks, as Storing and using keys described. An exposed key cannot wait for that overlap. Cedar generates a new key, publishes it, starts signing with it, and removes the exposed key from its published key set at once.
Removing the key ends trust in everything it ever signed, genuine and forged alike, because a signature cannot tell them apart. Staff holding tokens signed with it are signed out or have to refresh. Applications that cached the old key set keep accepting forgeries until they fetch the new one, so they need to be told to refresh. The training and expense services, which installed Cedar's SAML signing certificate by hand, have to install the new one before Cedar's staff can sign in to them again. An organization that already rotates keys routinely, and knows every verifier and partner that holds its public key, gets through this far faster than one doing it for the first time.
Replacing the key stops future forgeries. It does not undo what earlier ones did. The investigation uses the issuance records to find what the forged tokens were used for, then revokes the sessions and grants they created, reverses the changes they made, and finds out how the key escaped so that the new one does not follow it. Rotating credentials and keys after exposure follows that process in more depth.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Refuse foreign and wrong-type tokens, then withdraw an exposed key at oncePresent a real Lab Mail token to Lab Photos, refuse a token of the wrong type, then withdraw an exposed signing key at once, without the usual overlap.