Credential rotation, also called secret rotation, is the controlled process of replacing an existing credential with a new one and revoking the old value, so that any copy an attacker may hold becomes useless. In cybersecurity, and particularly in identity & access management, rotation applies to service account passwords, API keys, database credentials, SSH keys, signing keys and TLS certificates.
Rotation limits the window of exposure of a secret. It does not prevent theft, but it shortens how long a stolen credential remains valid and forces the organization to know where every secret is used. Done well, it is automated and invisible; done poorly, it causes outages and is quietly abandoned.
How credential rotation works
A safe rotation follows a multi-phase sequence that keeps services running while the secret changes. The key principle is that old and new credentials overlap briefly, so consumers can switch without a gap in access.
- Generate a new credential with sufficient entropy in a secrets manager or key management system.
- Register the new value with the target system, such as a database user or cloud identity, while the old one remains valid.
- Distribute the new value to every consumer, ideally by having applications fetch it at runtime.
- Verify that consumers authenticate successfully with the new credential.
- Revoke the old credential and record the change in an audit log.
Many platforms implement this as a dual-credential scheme: two keys or two database users alternate, so one is always active while the other is being replaced. Secrets managers can run the sequence on a schedule and roll back automatically when verification fails.
Credential types and typical rotation intervals
Rotation frequency depends on credential type, privilege level and exposure, not on a single universal number. The table below gives common practice ranges and the factors that shape them; individual policies and compliance frameworks may set stricter values.
| Credential type | Typical rotation interval | Main consideration |
|---|---|---|
| Database service passwords | 30 to 90 days, or on demand | Many consumers must be updated together |
| Cloud API access keys | 90 days or less | Prefer short-lived role credentials instead |
| Short-lived tokens | Minutes to hours | Expiry replaces manual rotation |
| TLS certificates | Up to about 398 days, trending shorter | Automated issuance through ACME |
| SSH host and user keys | Annually or on staff change | Stale keys accumulate on servers |
| Encryption and signing keys | Yearly or per cryptoperiod | Old versions kept for decryption or verification |
| Human user passwords | Only on suspected compromise | Forced periodic change weakens choices |
The last row reflects current guidance such as NIST SP 800-63B, which advises against mandatory periodic password changes for people because users respond with predictable patterns. For machine credentials, by contrast, regular rotation remains a sound practice.
Rotation compared with related access controls
Credential rotation is one of several ways to limit the lifetime of trust, and it is often confused with neighboring mechanisms such as token expiration and revocation. The comparison clarifies where each one fits.
| Mechanism | What changes | Who triggers it |
|---|---|---|
| Credential rotation | A long-lived secret is replaced | Schedule or security event |
| Token expiration | A short-lived token simply stops working | Built-in lifetime |
| Revocation | A credential is invalidated immediately | Incident or offboarding |
| Key versioning | A new key version becomes primary | Key management system |
| Ephemeral credentials | A fresh secret is issued per session | Identity provider or broker |
The strongest designs reduce the need for rotation altogether. Workload identity federation, OpenID Connect tokens for pipelines and dynamically issued database credentials replace stored secrets with credentials that expire on their own, leaving rotation for the few long-lived secrets that cannot be eliminated.
Implementing rotation without outages
Most rotation failures are operational rather than cryptographic: an unknown consumer still uses the old secret and breaks when it is revoked. Reliable rotation therefore starts with a complete inventory of secrets and their consumers.
- Centralize secrets in a vault or cloud secrets manager instead of configuration files and environment variables.
- Fetch secrets at runtime and cache them briefly, so applications pick up new values without redeployment.
- Use grace periods in which both values work, sized to the longest cache or connection lifetime.
- Monitor authentication failures after each rotation and alert on use of revoked credentials.
- Rotate immediately after a suspected leak, a departing administrator or a secret found in a code repository.
The following table connects common symptoms to their usual cause and a durable fix.
| Symptom | Likely cause | Fix |
|---|---|---|
| Outage right after revocation | Undocumented consumer | Inventory and usage logging before revoking |
| Rotation postponed for years | Manual, risky procedure | Automate with a secrets manager |
| Old key still found in source code | Hardcoded secret | Secret scanning and runtime retrieval |
| Intermittent failures for minutes | Cached old value | Overlap window longer than cache lifetime |
Limitations and common misconceptions
Rotation is a risk reduction measure, not a breach response by itself. If an attacker already holds a credential, scheduled rotation in 60 days leaves a long window; a confirmed leak requires immediate revocation and investigation of what the credential accessed.
Another misconception is that frequent rotation compensates for broad privileges. A powerful credential rotated monthly is still powerful for a month. Least-privilege scoping, network restrictions and monitoring matter as much as the interval. Finally, rotating a secret while storing the new value in the same insecure place simply recreates the original exposure.
Encryption keys need special care. Rotating a data encryption key does not re-encrypt existing data automatically, so older key versions must remain available for decryption until the data is re-encrypted or expires. Destroying an old version too early can make stored data permanently unreadable.
In plain words
Credential rotation is like changing the locks on a building at regular intervals. Even if someone secretly copied a key, it stops working once the lock is changed.
Computers use many hidden passwords and keys to talk to each other. Rotation replaces them on a schedule, and the clever part is doing it without locking out the legitimate users: the new key is handed out first, and only then is the old one thrown away.
A real-world example
An online retailer runs about 40 microservices that connect to a shared PostgreSQL database. Historically, one database password lived in configuration files and had not changed for three years, because every manual attempt caused checkout errors.
The platform team moves the password into a secrets manager and configures automatic rotation every 30 days with two alternating database users. Services read the credential at startup and refresh it every 10 minutes, and the old user stays valid for 24 hours after each switch. When a contractor accidentally pushes a configuration file to a public repository months later, the team rotates on demand within minutes, and monitoring confirms that no service fails. The exposed password was already obsolete, so the leak gave no usable access.