Scrivio Interview library
LeadershipAdvanced6 min read · updated 12 November 2026

Write a key and credential rotation policy for your organisation, covering signing keys, encryption keys, database passwords and API keys. What makes such a policy work in practice?

A good rotation policy sets rotation periods by key type and risk, for example signing keys yearly, data encryption master keys yearly with automatic KMS rotation, database passwords every 30 to 90 days or replaced by dynamic credentials, API keys every 90 days, plus immediate rotation on any suspected compromise. What makes it work in practice is not the table of periods but automation, systems designed for overlapping validity so rotation causes no downtime, an inventory of keys with owners and last rotation dates that alerts on overdue ones, and regular practice so rotation is routine rather than an emergency.

Why this question is asked

Many organisations have a rotation policy that says "all secrets are rotated every 90 days" and an estate where half the secrets have never been rotated. The policy failed not because the period was wrong, but because nothing made it happen. Interviewers ask this leadership question to see whether we can write a policy that people can follow, and whether we know the engineering conditions that make it real. In this answer, we will set the policy's scope and periods by key type, cover compromise rotation, and then go through what makes it work: automation, overlapping validity, an inventory with alerts, and practice.

1Scope and Principles of the Policy

The policy covers four families, because each behaves differently when rotated. Signing keys create signatures others verify, such as JWT signing keys or artifact signing keys. Encryption keys protect stored data, usually as master keys in a KMS that wrap data keys. Database passwords and other service credentials let one system log in to another. API keys are credentials issued to or by third parties.

The principles fit in a few sentences. Every key has an owner. Rotation is automated unless an exception is approved. Systems must accept an old and a new credential at the same time during rotation. Any suspected compromise triggers immediate rotation regardless of schedule. The periods below are defaults by risk; teams can rotate more often, never less, without an approved exception.

2Rotation Periods by Key Type

The periods follow from how a key is used and what rotation costs. Credentials that are cheap to rotate and used by machines should rotate often, or better, be replaced by dynamic credentials with lifetimes of hours. Keys that others must trust, such as signing keys published in a JWKS document, rotate less often because verifiers need time to pick up the new key. Root keys used to sign other keys, such as a CA, rotate rarely and are protected in HSMs instead.

Default rotation periods (example policy)
Key typeDefault periodNotes
JWT and token signing keysEvery 6 to 12 monthsPublish new key in JWKS before using it
Root CA and code-signing rootsYears, held in HSMPlanned ceremony, long overlap
KMS master keys (wrap data keys)Yearly, automatic KMS rotationOld versions kept for decryption
Data encryption keysPer volume or periodRetire after about 2^32 GCM messages
Database passwords30 to 90 days, or dynamicPrefer Vault dynamic credentials
Third-party API keys90 daysTwo active keys during switch
Any key, suspected compromiseImmediatelyIncident process, revoke old at once

3Immediate Rotation on Suspected Compromise

The schedule protects against leaks we do not know about; compromise rotation handles the ones we do. The policy defines triggers: the secret appeared in a repository, log or ticket; a person with access left on bad terms; a system holding it was breached; a vendor reported an incident. When a trigger fires, the owner rotates within a fixed time, for example 24 hours for production and 4 hours for high-privilege keys, and the old value is revoked immediately rather than after the usual overlap, accepting some disruption if needed.

Notice the trade-off. Normal rotation uses overlap to avoid downtime; compromise rotation shortens the overlap because the old key is in hostile hands. A system that has rehearsed scheduled rotation can do the compressed version safely.

4What Makes the Policy Work: Automation

Manual rotation does not happen reliably. It depends on someone remembering, finding the runbook, and having time during a busy quarter, and each of those fails sometimes. So the policy requires automation as the default: KMS automatic key rotation, Vault dynamic database credentials or scheduled rotation, a rotation job for API keys using the provider's API, and JWKS publishing driven by the signing service.

Where automation is not yet possible, the exception is recorded with an owner and a date by which it will be automated, and the manual procedure is scripted and tested, not written as prose in a wiki.

5Overlapping Validity So Rotation Causes No Downtime

Rotation that breaks production is rotation that gets postponed. Every system must therefore support two valid credentials during a transition: verifiers accept tokens signed with the old and new keys, identified by a kid header, until old tokens expire; data stores record a key id with each ciphertext so old and new keys decrypt side by side; services switch to a new database password or API key while the old one still works, and only then is the old one revoked.

This is a design requirement the policy places on engineering, and the architecture review checks it: a new service that can only hold one secret value at a time is not ready for production.

Step throughSigning key rotation with overlap
Token issuerJWKS endpointAPI services
publish new key k2 next to k1
refresh keys (cache 1h)
k1, k2
after 24h: sign new tokens with k2
accept k1 and k2 by kid
after old tokens expire: remove k1

6 messages in order. Play them, or step through them one at a time.

Verifiers learn the new key before any token uses it, so no request fails.

6Inventory, Alerts and Practice

We cannot enforce periods for keys we do not know about. The inventory lists every key and credential with its type, owner, system, last rotation date and next due date, fed automatically from the KMS, Vault and the secret store where possible. Overdue keys raise alerts to the owner and, after a grace period, appear in the engineering manager's quality report. The count of overdue keys is a metric reviewed monthly.

Finally, practice. Rotation is exercised regularly in lower environments, and production rotation of each key family is run on its schedule as a normal change, not a special event. A team that rotates its database credentials every 30 days without anyone noticing is a team that will handle a leaked key calmly.

7Follow-up questions

Should every secret rotate every 90 days?

A single period for everything is simple to state but ignores risk and cost. Signing keys rotated too often create work for every verifier; database passwords rotated rarely stay valuable to attackers for too long. Periods by type and risk, plus immediate rotation on compromise, protect better.

How do you handle a vendor whose API keys cannot be rotated without downtime?

Record it as an exception with an owner, contain the key (one consumer, stored centrally, network restrictions where possible), ask the vendor for a second-key feature, and schedule a short planned window for rotation until they provide one.

8Conclusion

In this answer, we wrote a rotation policy covering signing keys, encryption keys, database passwords and API keys, with periods set by key type and risk and immediate rotation on suspected compromise. We saw that what makes it work is automation, systems designed for overlapping validity so rotation causes no downtime, an inventory of keys with owners and last rotation dates that alerts on overdue ones, and regular practice so rotation is routine.

What to say in the interviewAbout 100 seconds aloud

Open with

I would write the policy around key types, because they rotate differently. Signing keys, like JWT keys, rotate every six to twelve months with the new key published in the JWKS before it is used, and root keys live in an HSM and rotate rarely in a planned ceremony.

Then, if they want more

KMS master keys rotate yearly using automatic rotation, with old versions kept for decryption. Database passwords rotate every 30 to 90 days, or better are replaced by Vault dynamic credentials, and third-party API keys every 90 days with two active keys during the switch.

On top of that, any suspected compromise means immediate rotation, with a fixed deadline such as four hours for high-privilege keys and the old value revoked straight away. But the table is the easy part. What makes it work is, first, automation, because manual rotation simply does not happen reliably; exceptions need an owner and a date.

Second, every system must accept old and new credentials at the same time, with key ids on tokens and ciphertexts, so rotation never causes downtime and nobody has a reason to postpone it.

Third, an inventory of every key with owner, last rotation date and next due date, with alerts on overdue keys and a monthly metric in the managers' quality report. And fourth, practice: rotation runs regularly in lower environments and on schedule in production, so that when a key actually leaks, rotating it is routine and not a crisis.

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
Spring Security reference
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 "Write a key and credential rotation policy for your organisation, covering signing keys...": https://scrivio-interview-library.netlify.app/spring-boot/secrets-and-crypto/77133bf5b0/