Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Imagine the private key your identity provider uses to sign access tokens is suspected to be compromised. Treat this as a business continuity problem: what must already be in place, and what happens in the first hours?

A suspected signing key compromise is survivable only if the preparation already exists: a written procedure, the ability to publish a new key and remove the old one within minutes, and services that refetch the key set when they see an unknown kid. In the first hours we rotate, accept that every existing token becomes invalid, absorb the wave of re-logins by scaling the identity provider and telling users, and investigate what forged tokens may have done. The procedure must be rehearsed, because a first attempt during an incident tends to fail.

Why this question is asked

Most security incidents affect one service or one data set. A compromised token-signing key is different: whoever holds it can create a valid access token for any user, with any permissions, for every service that trusts the identity provider. Treating it as a business continuity problem means asking two questions at once: how do we stop the forged tokens, and how do we keep the business running while we do it? Interviewers ask this at principal and director level because the right answer is mostly decided months before the incident. In this answer, we will look at why the key is so critical, what must already be in place, what happens hour by hour once the alarm goes off, how to investigate the damage, and how rehearsal turns the plan into something that works.

1Why This Key Is the Most Dangerous Secret We Have

The identity provider signs access tokens with a private key, and every service verifies them with the matching public key, fetched from a JWKS (JSON Web Key Set) endpoint. Services trust any token whose signature checks out, whose issuer is right and which has not expired. They do not ask the identity provider whether it really issued that token.

So an attacker with the private key needs no passwords and leaves no failed logins. They can mint a token for the chief financial officer with an admin scope and a long expiry, and every service will accept it. The only fix is to stop trusting that key everywhere, which also invalidates every legitimate token signed with it. That is why the incident is a continuity problem: the cure logs out the whole company and its customers.

2What Must Already Be in Place

The first piece is a written procedure with named owners: who can declare the incident, who performs the rotation, who talks to customers, and who leads the investigation. In the middle of the night, nobody should be deciding whether they have authority to log out every user.

The second is the technical ability to rotate quickly. The identity provider must be able to generate a new key pair, publish its public key, start signing with it and remove the compromised key in minutes, ideally through a tested runbook or automation. If the private key lives in a hardware security module or a cloud key service, the procedure must cover creating a replacement there too.

The third is that every service refetches the JWKS when it sees an unknown kid (the key id in the token header) and caches keys for a bounded time. If one service pins the key in a configuration file or caches it for a day, it will keep accepting forged tokens or rejecting all new ones after rotation. Finding those services is part of preparation, not of the incident.

The fourth is logging that supports the investigation: the identity provider logs every issued token id (jti) with subject and client, and services log the token id and subject of each request. Without that, we cannot tell a forged token from a real one afterwards.

3The First Hours, Step by Step

Once the compromise is suspected strongly enough, waiting is the expensive option, because every minute lets forged tokens keep working. The sequence below assumes the preparation exists.

We publish a new key and sign all new tokens with it. Then we remove the compromised key from the JWKS. Unlike planned rotation, there is no overlap period: the old key must stop being trusted now, and we accept that every token signed with it, legitimate or not, becomes invalid. Refresh tokens issued alongside those access tokens should be revoked too if there is any chance they were affected, so users must sign in again. Services pick up the change on their next refresh or on the first token with the new kid; for services with longer caches, we restart them or force a refresh.

Step throughFirst hours after a suspected key compromise
  1. Declare the incidentNamed owner decides; procedure starts
  2. Generate and publish new keyNew tokens signed with it
  3. Remove compromised key from JWKSNo overlap: all old tokens fail
  4. Force refresh on slow servicesRestart those that cache too long
  5. Scale identity providerRe-login wave expected
  6. Tell users and supportWhy they were signed out
  7. Investigate forged token useLogs of jti, subject and source

7 steps in order. Play them, or step through them one at a time.

4Handling the Wave of Re-Logins

The moment the old key goes, every client gets 401 on its next call and tries to refresh or sign in again. If the identity provider normally handles 200 logins a minute and we have two million active sessions, a large share of them will arrive within the next 15 to 30 minutes. The provider must be scaled up before the switch, and clients should retry with backoff and jitter instead of hammering it.

Communication is part of continuity. Support teams need a short script before users start calling, the status page should say that sessions were reset for security, and large customers or partners with integrations may need a direct message, because their service accounts must fetch new tokens. A clear message reduces the support load and the reputational damage much more than silence does.

5Investigating the Scope

Rotation stops future misuse but says nothing about the past. The investigation asks how the key leaked, how long it was exposed and whether forged tokens were used. A useful signal is a token id that appears in service logs but was never issued by the identity provider, or a token whose claims (scopes, lifetime, client) do not match anything the provider produces. Requests from unusual locations or for unusual data during the exposure window follow.

The result feeds into legal and regulatory decisions, such as whether personal data was accessed and whether notification is required, so security, legal and the data protection officer join early. Fixing the root cause, for example moving the key into a hardware security module, comes before anyone calls the incident closed.

6Rehearsing Before It Is Real

A procedure that has never been run usually fails on small things: an expired credential for the key vault, a service that pins the key, a dashboard nobody can find. So we rehearse it. In staging, an emergency rotation every quarter shows which services break. In production, a planned rotation on a schedule exercises the same steps with an overlap period, so the mechanics stay familiar. A tabletop exercise with the people named in the procedure, including communications and legal, tests the decisions rather than the code.

The measure of readiness is time. If the drill shows that we can go from declaring the incident to the compromised key being untrusted everywhere in 30 minutes, that is a number leadership can plan around. If it takes two days because of one forgotten service, we have found that out at the right moment.

7Follow-up questions

Could we keep the old key for an hour to soften the impact?

Only if we accept that forged tokens also keep working for that hour. When compromise is likely, the safer choice is to remove it at once and manage the re-login wave. When it is only a weak suspicion, a short overlap while the investigation confirms can be a reasonable risk decision, but it must be made explicitly by the incident owner.

How do short token lifetimes help here?

They limit how long forged tokens with honest expiry times stay valid, and they make clients used to refreshing often, so the wave after rotation looks like heavy normal traffic. They do not protect against an attacker who mints tokens with a long expiry, because the attacker writes the exp claim. Only removing the key stops those.

What changes after the incident?

We fix how the key leaked, shorten the time to rotate where the drill was slow, bring any service that pinned keys onto the platform decoder, and update the procedure with what we learned. We also review whether the key belongs in a hardware security module so it cannot be copied at all.

8Conclusion

In this answer, we treated a compromised signing key as a continuity problem. The preparation decides the outcome: a written procedure with owners, rotation that takes minutes, services that refetch keys on an unknown kid, and logs of token ids. In the first hours we rotate without overlap, accept that all tokens become invalid, scale the identity provider and communicate, then investigate what forged tokens did. Regular rehearsal is what makes the plan work when it is needed.

What to say in the interviewAbout 100 seconds aloud

Open with

I would start by saying that whoever holds that key can mint a valid token for any user against every service, so the only real fix is to stop trusting the key everywhere, and that logs everybody out.

Then, if they want more

So the outcome depends on what we prepared. Before any incident I want a written procedure with named owners, rotation that we can do in minutes, every service refetching the JWKS when it sees an unknown kid with a bounded cache, and logs of token ids on both the identity provider and the services.

When it happens, the incident owner declares it, we publish a new key and sign with it, and we remove the compromised key with no overlap period. Every existing token becomes invalid, refresh tokens too if they may be affected. We force a refresh on any service with a long cache.

Then we deal with the consequences: scale the identity provider for the re-login wave, have clients back off, and tell support, users and partners clearly why they were signed out. In parallel we investigate: token ids seen by services that the provider never issued, unusual claims, unusual access during the exposure window, and we bring in legal for notification decisions.

And none of this works if it is tried for the first time in the incident, so I would rehearse it quarterly and measure how long it takes to make the old key untrusted everywhere.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
RFC 7519, JSON Web Token
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Imagine the private key your identity provider uses to sign access tokens is suspected...": https://scrivio-interview-library.netlify.app/spring-boot/jwt/1ef77f4d15/