Credential rotation: move safely to a new key and retire the old one
Credential rotation replaces an existing key, password, or certificate with a new value and makes the replaced value unusable. First find the affected services and consumers, then check which replacement strategy the provider supports. Scheduled rotation limits exposure time; suspected compromise is incident response and may require immediate blocking with no overlap.
Credential rotation replaces an existing key, password, or certificate with a new value and makes the replaced value unusable. First find the affected services and consumers, then check which replacement strategy the provider supports. Scheduled rotation limits exposure time; suspected compromise is incident response and may require immediate blocking with no overlap.
Before replacing a credential
Inventory its type and purpose: who issues and uses it, which services and deployments reference it, where it is stored, how it expires or can be revoked, and whom to contact if the change fails. If multiple applications share one secret, changing it for one consumer can break the others, so map the impact first.
Prefer dynamic, short-lived credentials and automated rotation when the secrets system supports them. Set lifetime according to what the key protects, how it is used, and the issuer’s capabilities; there is no universal rotation interval. Scheduled changes to human passwords are a different policy from machine-account keys. For human passwords, follow current NIST guidance and organizational policy, including changes when exposure is suspected or confirmed.
Planned rotation sequence
**Find consumers and dependencies.** Locate references in repositories, deployment configuration, runtime secret-delivery paths, and audit records. Track identifiers, owners, and reference locations without printing secret values.
**Issue a replacement.** Use adequate cryptographic strength and only the required permissions. Store the new value through an approved secret-management path and confirm consumers can retrieve it.
**Migrate consumers using a supported strategy.** If the provider allows two keys to be valid at once, distribute the replacement first and verify each consumer authenticates with it. Services without overlap may need a short maintenance window or a separate dual-account pattern. Never assume overlap without checking the provider’s contract.
**Disable the old value and observe.** After confirming all consumers work with the new value, disable the old credential. Watch authentication failures, delayed jobs, deployments, and calls to find any remaining users.
**Revoke and record.** After a safe observation period, delete or revoke the old key or certificate. Record issue, deployment, disablement, and deletion times, owner, affected systems, and outcome as non-secret audit metadata.
Google Cloud’s service-account key guidance describes creating a new key, replacing the old key across applications, disabling it and monitoring, then deleting it. Some AWS Secrets Manager rotation functions instead create a pending secret version, change the target credential, test the new version, and promote it as current. These are provider-specific examples, not universal procedures for every key or platform.
Rotation failures and suspected exposure
If planned rotation fails, identify the completed stage and whether the replacement can be rolled back safely. When a target value and its stored copy may have diverged, restore the issuer’s state first; do not delete mismatched values or repeatedly deploy them blindly.
If a problem appears only after disabling the old key, consider a short recovery only when the provider permits it and there is no indication of exposure. Do not reactivate a key that may have leaked merely for convenience.
If compromise is suspected or confirmed, do not wait for the normal schedule: block access and revoke the affected key, certificate, or token immediately. Issue a replacement, migrate consumers, remove exposed copies, review usage records, and investigate actors and timestamps. Revoking a parent key may not invalidate short-lived tokens already issued from it; check the separate revocation or expiry behavior.
Encryption-key rotation can differ from credential replacement. Switching new writes to a new key may leave existing data encrypted under the old key, so design decryption compatibility, re-encryption, and key-version retention separately.
Operational checklist
Does each credential have a documented owner, purpose, consumers, storage location, and issue/expiry/revocation method?
Are overlap rules and provider-specific rotation stages known?
Are there metrics and an owner to verify successful authentication and find consumers still using the old value?
Can the old value be disabled and revoked, with the result audited without storing the secret?
For exposure incidents, are immediate blocking, token invalidation, consumer migration, cleanup, and investigation assigned?
Rotation is not complete when a new value is merely issued. Verify every consumer’s migration, disable the old value, then revoke it. Keep planned rotation separate from compromise response, and follow the selected provider’s actual procedure.
References
[OWASP Secrets Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)
[Google Cloud: Service account key rotation](https://docs.cloud.google.com/iam/docs/key-rotation)
[AWS Secrets Manager: Lambda rotation functions](https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_lambda-functions.html)