Most rotation outages and most incomplete incident clean-ups have the same cause: nobody wrote down which systems use the secret, how the new value reaches them, or how to get back to the old one when the cutover fails. This template is a ready-to-adopt secrets rotation runbook for API keys, passwords, cloud and service account keys, client secrets, private keys and encryption keys. It covers the secret record, triggers, single or dual key rotation, dependency checks, the planned procedure, verification, rollback, emergency key rotation and manual key rotation, with AWS Secrets Manager, Azure Key Vault and Google Cloud Secret Manager examples. It is for platform, DevOps and security engineers who own production secrets. For the wider programme see the Secrets Management Guide.
How to use this template
- Replace text in square brackets, such as [Organisation], [Secret owner] and [24 hours], with your own teams, tools and targets.
- Complete sections 3 and 6 once per secret (or per class of identical secrets). Sections 7 to 11 are the procedures engineers follow; keep them as a key rotation checklist in your ticketing or change tool.
- "Must" is mandatory; "should" may be skipped with a recorded reason.
- Why rotation is hard for machine identities is covered in the Guide to NHI Rotation Challenges; this runbook covers how to do it safely.
1. Purpose and scope
This runbook defines how [Organisation] rotates secrets and cryptographic keys on a schedule and in response to suspected compromise, so that rotation does not cause outages, every consumer is moved to the new value, the old value is revoked, and each step is recorded. It implements [Secrets Management Standard] clause [X].
- In scope: API keys and tokens; database and service account passwords; cloud and service account keys; OAuth client secrets; SSH, TLS, signing and encryption keys; webhook secrets and connection strings used by applications, pipelines, AI agents and integrations in [environments].
- Out of scope: human user passwords, which OWASP says "should only be rotated if there is suspicion or evidence that they have been compromised"; these follow [Password Policy].
2. Roles and responsibilities
| Role | Responsibilities | Named person or team |
|---|---|---|
| Secret owner | Accountable for the secret record, the rotation schedule and approving rotation; on call during the change | [ ] |
| Rotation operator | Runs sections 6 to 9; may be an automated rotation function with a named human owner | [ ] |
| Consumer owners | Confirm their service picked up the new value; report errors | [per consumer] |
| Issuer administrator | Holds rights to create and revoke credentials at the issuing system (database, cloud, SaaS) | [ ] |
| Security operations | Monitors use of the old value after revocation; leads section 10 | [ ] |
| Change manager | Approves planned rotations of [Tier 1] secrets; emergency changes are approved retrospectively | [ ] |
3. Secret record
Every secret in scope must have a record before it can be rotated safely. OWASP lists the metadata a secrets solution should hold, including when a secret was "created/consumed/archived/rotated/deleted", "Who to contact" and "When you need to rotate it, if done manually".
| Field | Example |
|---|---|
| Secret ID and location | [prod/payments/db-app] in [secrets manager, vault, region] |
| Type and issuer | [Database password] issued by [database cluster] |
| Owner and deputy | [ ] |
| Consumers | Every service, job, pipeline, agent and partner that uses it, and how each retrieves it (runtime API, sidecar, environment variable, file) |
| Privilege tier | [Tier 1: production data or admin rights / Tier 2 / Tier 3] |
| Rotation pattern | [Single credential / dual credential / versioned key / dynamic] (section 5) |
| Interval and last rotated | [90 days], [date] |
| Rollback method | [Restore previous version label / re-enable previous version / revert configuration] |
| Revocation method | [Delete user / disable key / regenerate key at issuer] |
4. Rotation triggers and intervals
A cryptoperiod is "the time span during which a specific key is authorized for use" (NIST SP 800-57 Part 1 Rev. 5), and NIST lists the cost of key revocation and replacement among the factors that shape it. Set intervals by tier and by how the secret is used, not one number for everything. OWASP's reason to rotate is "so that any stolen credentials will only work for a short time."
| Trigger | Type | Deadline |
|---|---|---|
| Scheduled interval reached | Planned (sections 6 to 9) | Tier 1 [30 to 90 days]; Tier 2 [90 to 180 days]; encryption keys [at least every two years, which Microsoft advises for Key Vault keys] |
| Expiry or near-expiry alert | Planned | Before [expiry minus 7 days] |
| Person with access leaves or changes role | Planned, accelerated | [5 business days] |
| Secret found in code, logs, tickets, chat or an image | Emergency (section 10) | Revoke within [4 hours]; Tier 1 within [1 hour] |
| Vendor, CI/CD or upstream breach notice | Emergency | [24 hours] for every secret shared with that party |
| Algorithm, key length or provider change | Planned project | [Per migration plan] |
5. Choose the rotation pattern
The pattern decides whether rotation can be done without downtime and how rollback works. Record it in section 3.
| Pattern | How it works | Platform examples | Use when |
|---|---|---|---|
| Single credential | One credential is changed in place; consumers pick up the new value | AWS Secrets Manager single user strategy, "appropriate for most use cases"; AWS notes a short window in which "there is a low risk of the database denying calls", mitigated by retries | The issuer allows one credential only; consumers retry on authentication failure |
| Dual credential (dual key rotation) | Two valid credentials exist; the inactive one is regenerated and promoted, then the other becomes inactive | AWS alternating users ("both user and user_clone credentials are valid"); Azure storage key1 and key2 alternated as Key Vault secret versions, giving "the application a full rotation cycle to pick up the newly regenerated key" | High availability; many consumers; slow propagation |
| Versioned key | A new key version is created; old versions stay enabled for decryption or verification | Azure Key Vault key rotation policy; consumers use a versionless key URI | Encryption and signing keys |
| Dynamic or keyless | A short-lived credential is issued per use, or workload identity replaces the secret | Managed identities, attached service accounts, IAM roles | Wherever the platform supports it; this removes the rotation burden |
Safe key rotation for anything with more than one consumer should use the dual credential or versioned pattern. Alternating users on AWS needs a separate superuser secret to clone the user, because "most users don't have permission to clone themselves"; protect that secret as Tier 1. Before investing in rotation, ask whether the secret can be removed: Microsoft's own tutorial advises preferring managed identity and, where compliance allows, disabling Shared Key authorisation to "remove the need for key rotation entirely".
6. Pre-rotation dependency checks
Complete this secret rotation checklist before any planned rotation. Do not start if any item fails.
- Confirm the consumer list in section 3 against evidence: secrets manager access logs for the last [30 days], issuer authentication logs, and a code and configuration search for the secret ID.
- Confirm how each consumer loads the value: on every request, on a cache timeout, on start-up or only on redeploy. Consumers that load only at start-up need a restart or redeploy step.
- Check that the operator or rotation function can create and revoke credentials at the issuer, and that the issuer allows a second credential if the pattern is dual.
- Check the platform state: on AWS, no version stuck with
AWSPENDINGfrom a failed rotation, since a later rotation then "assumes that a previous rotation request is still in progress and returns an error". - Identify dependent artefacts that break silently: rotating an Azure storage account key "revokes any account-level shared access signature (SAS) generated from that key"; signed URLs, cached sessions and derived tokens may do the same.
- Confirm the rollback method in section 9 works for this secret, and that the previous value or version will be retained.
- Schedule a window outside [peak periods], with consumer owners on call, and raise the change record.
7. Planned rotation procedure
This key rotation procedure follows the create, set, test, finish sequence used by AWS rotation functions and recommended by OWASP: "Test the pending credential before promoting its version to AWSCURRENT."
- Create: generate the new value with the issuer or the secrets manager's generator, never by hand. Store it as a new pending version (AWS
AWSPENDING; a new secret version in Azure Key Vault or Google Cloud Secret Manager). Do not overwrite the current version. - Set: register the new value at the issuer. For dual credential, regenerate the inactive credential only; the active one keeps serving traffic.
- Test: authenticate with the pending value from a test client with the same network path and permissions as a consumer, and perform a read-only operation.
- Promote: make the new version current (AWS moves
AWSCURRENTand labels the old versionAWSPREVIOUS, "so that you retain the last known good version"). On Google Cloud, where workloads should bind to a specific version rather thanlatest, update the pinned version in deployment configuration. - Propagate: roll the new value to consumers in stages: [one canary instance], then [10%], then all. Google warns that resolving
latestcontinuously "risks immediate, service-wide outage"; staged adoption limits the blast radius of a bad value. - Verify: run section 8 before touching the old credential.
- Retire the old credential: after [one full cache or session lifetime, minimum 24 hours], disable the old version or credential, watch for errors for [24 hours], then revoke it at the issuer and destroy the old version. Google's sequence is to disable, "wait a reasonable amount of time to allow a human to intervene", and only then destroy.
- Record: update the section 3 record and close the change with evidence.
For encryption keys, retirement is different: old versions must stay enabled for decryption. Microsoft states that "Both old and new key versions must remain enabled until re-wrapping is complete", and that Azure services can take "one hour to 24 hours or more" to adopt a new customer-managed key version.
8. Verification
- Consumers: every consumer in section 3 shows successful authentications using the new credential or version (issuer logs, application health checks, error rates against the baseline).
- Old value unused: zero successful authentications with the old credential for [24 hours] before revocation. Any remaining use is either a missed consumer or misuse; investigate before revoking.
- After revocation: a test call with the old value must fail. A "rotation" that leaves the old credential valid is not complete.
9. Rotation rollback plan
| Failure point | Rollback action | Owner |
|---|---|---|
| Test step fails | Stop. Leave the current version untouched; discard or disable the pending version. On AWS, let the rotation function clear AWSPENDING rather than removing it manually, which AWS warns against | Rotation operator |
| Canary fails after promotion | Restore the previous version as current (AWS: move AWSCURRENT back to the AWSPREVIOUS version; Google: redeploy the prior pinned version; Azure: point consumers at the previous secret version) | Rotation operator |
| Consumers fail after old credential disabled | Re-enable the old credential or version, which is why it is disabled before it is destroyed; then find the missed consumer | Secret owner |
| Issuer rejects both credentials | Use the [break-glass credential] held under [dual control], restore service, raise an incident | Issuer administrator |
Rollback is not available once the old credential has been revoked at the issuer and destroyed, so those steps come last. In an emergency rotation (section 10), never roll back to a compromised value: fix forward.
10. Emergency key rotation
Use this procedure when a secret is exposed or suspected compromised. OWASP: "Keys that were exposed should undergo immediate revocation", and "Restarting the application does not itself revoke stolen credentials." The order matters: if the attacker still has the access path that exposed the secret, they will collect the new one.
- Declare and assign: open an incident under [Incident Response Plan], assign an owner, and start a UTC log.
- Close the exposure path: remove the secret from the repository, image, log or ticket, and remove the attacker's access where the exposure came from a compromised system. OWASP requires that rotated secrets "be removed from the exposed system immediately".
- Revoke or rotate: if the service can tolerate an outage, revoke first and then issue the new value. If not, run section 7 at speed with the canary step shortened, and revoke the old value as soon as consumers have moved, within [the deadline in section 4].
- Scope the blast radius: list every secret the exposed one could read or that sat in the same location, and rotate those too. Rotating one credential and leaving its neighbours is the most common gap.
- Investigate use: answer OWASP's questions from logs: "Who had access?", "When did they use it?", "When was it previously rotated?" Search issuer logs for use of the old value from unfamiliar addresses during the exposure window.
- Confirm and close: old value fails; no further use; record lessons and change the rotation pattern if the incident exposed a weakness.
The Cloudflare breach of 2023 shows why step 4 matters: four credentials left unrotated after the Okta support breach let a nation-state attacker in. The Sumo Logic breach shows how one compromised cloud credential can lead to a customer-wide rotation. For first-hour actions after a leak, use the Leaked Credential Response Playbook.
11. Manual key rotation
Where the issuer has no API or automation is not yet built, manual key rotation must follow the same section 7 sequence, plus these controls. OWASP warns that rotation "implemented manually ... can lead to mistakes".
- Two people: one performs, one checks each step against this runbook. Neither pastes the value into chat, tickets or email.
- The new value is generated by the secrets manager or issuer and entered directly into it; nobody types or records it elsewhere.
- Use a near-expiry alert as the trigger: Azure Key Vault can publish a near-expiry event to Event Grid "as a reminder for manual rotation", and Google Cloud Secret Manager sends a
SECRET_ROTATEPub/Sub message atnext_rotation_time(the rotation period cannot be less than one hour). - Every manual rotation creates a ticket to automate the secret, with a target date.
12. Automation standards
- Schedules: AWS rotation uses
rate()orcron()expressions in UTC, "as often as every four hours within a rotation window as small as one hour". Azure key rotation policies have a minimum rotation time of seven days. Google rotation schedules only notify; [Organisation] must run a subscriber that performs the rotation. - Reentrancy: rotation code must survive being stopped part way and restarted. Google advises that the process "must be able to restart"; AWS relies on
AWSPENDINGfor idempotency. - Alerting and privilege: failed or skipped rotations page the owner (Google skips a scheduled rotation "if there is an in-flight rotation"), and the rotation function's identity can change only the credentials it rotates.
13. Records, metrics and review
- Keep, per rotation: secret ID, trigger, operator, start and end times, versions, verification evidence, rollback taken, and revocation time.
- Report monthly: percentage of secrets rotated within interval; percentage rotated automatically; failed rotations and rollbacks; median time from exposure to revocation; secrets with an incomplete section 3 record.
- Review this runbook after any failed rotation, any emergency rotation and at least [annually]. Rehearse section 10 on one Tier 1 secret in [each half year], alongside the break-glass credentials that OWASP says should be "tested routinely".
Implementation guidance
- Inventory first: fill section 3 for Tier 1 secrets before scheduling any rotation. A runbook without a consumer list is the root cause of most rotation outages.
- Pilot: run section 7 end to end in non-production, then on one Tier 3 production secret, timing each step.
- Move multi-consumer secrets to dual credential and automate by risk: Tier 1 database and cloud credentials first, using native rotation where it exists.
- Remove where you can: each secret replaced by workload identity no longer needs this runbook. See the Cloud Workload Identity Guide.
Small and large organisations: a small team can run this runbook with one owner per secret and native cloud rotation, keeping section 3 in the secrets manager's tags (Azure's dual rotation tutorial stores CredentialId, ProviderAddress and ValidityPeriodDays as tags). A large organisation should hold section 3 in an NHI inventory, enforce section 6 checks in the pipeline and report section 13 metrics per business unit.
Common failure patterns: rotating at the store but not revoking at the issuer; missing a consumer that only reads the secret at start-up; deleting the old version before the canary has finished, which removes rollback; restarting services and assuming that revoked a leaked credential; and rotating the exposed secret while leaving others from the same location, as in the Internet Archive breach, where unrotated keys allowed a second breach within a month.
| Runbook area | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 | ISO/IEC 27001:2022 |
|---|---|---|---|
| Secret record and ownership (3) | IA-5, CM-8 | ID.AM | A.5.9, A.5.17 |
| Intervals and cryptoperiods (4, 5) | SC-12, IA-5(1) | PR.AA-01 | A.8.24 |
| Planned rotation and rollback (6 to 9) | CM-3 | PR.PS-01 | A.8.32 |
| Emergency rotation (10) | IR-4 | RS.MI-01, RS.MI-02 | A.5.26 |
Standards and references
- NIST: SP 800-57 Part 1 Rev. 5 Recommendation for Key Management: Part 1, General
- OWASP: Secrets Management Cheat Sheet
- AWS: Rotation strategies in AWS Secrets Manager
- AWS: Lambda rotation functions
- Microsoft Learn: Automate rotation for resources with two sets of credentials
- Microsoft Learn: Configure cryptographic key auto-rotation in Azure Key Vault
- Google Cloud: Secret Manager rotation schedules
- Google Cloud: Secret Manager rotation recommendations
This template is provided for guidance and must be adapted to your organisation. Related NHI Mgmt Group resources: Secrets Management Guide · Guide to NHI Rotation Challenges · Leaked Credential Response Playbook · Cryptographic Key Management Guide · API Key Management Guide