A static secret stays valid until someone changes it, so a database password or API key copied into a repository, a log or a laptop image keeps working for as long as nobody notices. Dynamic secrets are created on request, unique to the consumer and revoked when their lease ends, which shrinks both the time a leak is useful and the number of systems one leak exposes. They also add a broker, a renewal path and new failure modes, so they are not the right answer for every credential. This guide compares static and dynamic secrets on lifetime, blast radius, attribution, operations and cost, shows where managed rotation and workload identity federation fit between the two, and gives a decision table and a phased plan. It is for platform, security and database teams deciding how to handle non-human credentials. For the mechanics of leases and secrets engines see the Dynamic Secrets and Ephemeral Credentials Guide; this page is about the choice.
Key takeaways
- The difference is lifetime and uniqueness. A static secret is one long-lived value shared by every consumer; a dynamic secret is generated per request with a lease, so each consumer holds its own short-lived credential.
- Rotation shortens exposure; dynamic issuance bounds it. A rotated static secret is still valid until the next rotation and is still shared. A dynamic secret expires on its own and a leak exposes one consumer for one lease.
- Static secrets remain correct for some material. OWASP lists storage encryption keys, TLS PKI keys and credentials for services that cannot create temporary accounts as static use cases.
- Dynamic issuance still rests on a static root. The broker needs a long-lived privileged credential to create accounts. Rotate it so no human knows it, scope it to account creation, and monitor it closely.
- Federation is often better than both. Where a platform can exchange a workload identity for temporary credentials, there is no stored secret and no broker in the middle.
What each approach is
A static secret is a credential value created once and used until it is changed or deleted: a database password in a connection string, a cloud access key, an API key, a client secret. Storing it in a secrets manager protects it at rest and controls who can read it, but does not change its nature. Every consumer that reads it holds the same value, and every copy stays valid until the next rotation.
A dynamic secret is generated by a broker at the moment a consumer asks for it. The broker creates a new database user, cloud key or certificate, returns it with a lease (an ID, a time to live and whether it can be renewed), and deletes or invalidates it when the lease expires or is revoked. HashiCorp Vault's documentation, for example, states that every dynamic secret has a lease, that revoking a lease invalidates the secret immediately, and that revoking a token revokes every lease created with it.
Two patterns sit between them and are often confused with dynamic secrets:
- Managed rotation of a static secret: a service owns an existing account and changes its password on a schedule. AWS Secrets Manager rotation functions and HashiCorp Vault database static roles both work this way. The credential is still shared, but its age is controlled.
- Federated temporary credentials: the platform exchanges a signed workload identity token for short-lived cloud credentials, with nothing stored. See the Workload Identity Federation Guide.
Side-by-side comparison
| Property | Static secret, manual rotation | Static secret, managed rotation | Dynamic secret |
|---|---|---|---|
| Lifetime of a leaked value | Until someone rotates it, often months or never | Until the next scheduled rotation | Until the lease expires or is revoked |
| Shared across consumers | Yes | Yes | No, one per request or instance |
| Blast radius of one leak | Every system the account can reach, for every consumer | Same reach, shorter window | One consumer's grant, for one lease |
| Attribution in target logs | One account name for all consumers | One account name for all consumers | Unique account per consumer, traceable to the requester |
| Revocation of one consumer | Rotate for everyone | Rotate for everyone | Revoke that lease only |
| Emergency revoke-all | Change the password and redeploy | Trigger rotation | Revoke by prefix or by token |
| Application change needed | None | Read the secret at runtime and tolerate a change | Fetch at start, renew leases, reconnect on expiry |
| Dependency added | None at runtime | Secrets manager at read time | Broker on the critical path for every new credential |
| Load on the target system | None | One password change per period | Account creation and deletion per lease |
| Main residual risk | Long exposure window | Shared credential, rotation outages | Broker root credential, broker availability |
OWASP's Non-Human Identities Top 10 lists long-lived secrets as NHI7:2025 and recommends automated rotation, short-lived credentials that expire automatically, re-authentication for sensitive actions and least privilege. Managed rotation answers the first recommendation; dynamic secrets and federation answer the second.
Blast radius: what one leak actually exposes
Lifetime is only one dimension. A leaked static password used by forty application instances gives an attacker the access of all forty, indistinguishable in database logs from normal traffic. A leaked dynamic credential gives one instance's access for the rest of its lease, under a username that identifies which consumer requested it, so responders can see what it touched and revoke only that lease. Two public incidents show the static case:
- Exposure with no expiry: in the Toyota T-Connect key exposure, a server access key sat in source code on public GitHub for about five years before it was found and changed. A credential with a lease of hours would have expired long before.
- Rotation that skipped "unused" credentials: in the Cloudflare Thanksgiving breach, one service token and three service account credentials were not rotated after an upstream breach because they were believed to be unused, and the attacker used them to get in.
Dynamic secrets do not make credentials safe to leak. While a lease is valid it carries the role's full grant, so least privilege on the role definition matters as much as the TTL. OWASP's cheat sheet also notes that restarting an application does not revoke credentials it held: they stay usable until the backing service expires or revokes them.
When to use each
| Credential or workload | Recommended approach | Why |
|---|---|---|
| Workload on a cloud platform calling that cloud's APIs | Federation or platform identity | No stored secret and no broker; see the Cloud Workload Identity Guide |
| Application connecting to a relational database it does not own | Dynamic secret | Per-instance users, short leases, clear attribution |
| CI/CD job needing cloud or database access for minutes | Federation first, otherwise dynamic | Job lifetime matches a short lease |
| Engineer needing temporary production database access | Dynamic secret through an approval flow | Access disappears without a clean-up task; see the JIT Access Guide |
| Legacy application that cannot change usernames or reconnect | Managed rotation (static role) | Bounds age without changing the application |
| Database role that owns schema objects | Managed rotation | Objects created by short-lived users complicate ownership |
| Third-party SaaS API key with no issuance API | Static, stored in a manager, rotated on a schedule | The provider offers no way to mint per-request keys |
| Storage encryption key or TLS private key | Static key material under a KMS or HSM, rotated by policy | Must outlive any one deployment; see the Cryptographic Key Management Guide |
| Break-glass credential | Static, sealed and monitored | Must work when the broker is down |
When dynamic is worth the effort
- Many consumers share one high-value credential: per-consumer credentials remove the shared blast radius and the "who did this" problem.
- The target supports account creation cleanly: mainstream relational and NoSQL databases, cloud IAM and PKI do; many SaaS APIs do not.
- Consumers are short-lived: containers, functions and jobs fit leases naturally; long-running monoliths need renewal logic.
- You can run the broker as tier-zero infrastructure: highly available, backed up, monitored and owned. If not, managed rotation is the safer step.
Small teams usually get most of the value from federation for cloud access plus managed rotation for databases, adding dynamic secrets for the one or two databases with the most consumers. Large platforms with many services and strict attribution requirements benefit from dynamic database and cloud credentials as the default, with static secrets as documented exceptions.
Operational trade-offs
- Broker on the critical path: if the broker is unavailable, new instances cannot start and expiring leases cannot renew. Size TTLs so running workloads survive a broker outage of a known length.
- TTL tuning: too short and renewals and reconnections create load and errors; too long and the benefit fades. HashiCorp Vault's database engine documents defaults of a 1 hour TTL and 24 hour maximum TTL for dynamic roles; set your own deliberately rather than inheriting them.
- Target system load: every lease creates and drops an account. Check connection limits, user limits and audit volume on the database before rollout.
- Revocation lag: brokers revoke expired credentials within a reasonable time rather than instantly, and existing sessions may survive user deletion on some databases. Test what happens to open connections.
- Rotation outages for static secrets: AWS Secrets Manager documents that single-user rotation has a short window where calls with the old password can be denied, and that alternating-user rotation (two users, one secret) reduces this at the cost of keeping permissions in step on both users.
- The root credential: the broker's privileged account is the static secret that issues all the dynamic ones. Rotate it immediately after configuration so only the broker knows it, and treat its use outside the broker as an incident.
Moving from static to dynamic: a phased approach
- Inventory and rank. List static secrets with their age, number of consumers, privilege and target. Rank by consumers multiplied by privilege. Measure age first; see How to measure secret age and rotation coverage.
- Remove what federation can replace. Move cloud API access to workload identity before building broker roles for it.
- Bring the rest under managed rotation. Every remaining static secret should rotate automatically, even if it later becomes dynamic. See How to rotate database credentials without downtime.
- Pilot dynamic secrets on one service. Choose a stateless service with several instances against one database. Define a least privilege role, set TTLs, and confirm the application renews leases and reconnects cleanly.
- Run both in parallel. Keep the static credential valid but unused during the pilot window, and watch the database for logins with it. Rollback is pointing the service back at the static secret.
- Revoke the static credential. When it shows no logins, disable then drop the shared account.
- Rehearse emergency revocation. Practise revoking all leases for a path and confirm applications recover.
Threat model, failure modes and a worked scenario for each option
Static secrets
Threat model. A static secret is valid until someone changes it, so its exposure window is the time between leak and rotation, which is often months. Failure modes. Rotation that is scheduled but never run, the same password shared by several applications so nobody dares rotate it, and copies left in images and backups after rotation. Controls. One secret per consumer, automated rotation, and detection of use from unexpected sources. Decision criteria. Static secrets remain reasonable where the target system cannot create credentials on demand.
Dynamic secrets
Threat model. The attacker now targets the broker that issues credentials and the token used to request them. Failure modes. Lease durations set so long that dynamic secrets behave like static ones, and applications that ignore renewal responses. Vault's lease documentation warns that a requested renewal increment is advisory and the backend may limit it, so code must read the returned lease rather than assume. Controls. Short lease TTLs, renewal handling, and protection of the broker. Decision criteria. Prefer dynamic secrets for databases and cloud credentials where the target supports on-demand issuance.
Worked scenario. An intrusion is detected in an analytics cluster that reads from several databases. With static passwords, each must be rotated by hand and every consumer redeployed. With dynamic secrets, revoking the cluster's broker token revokes every lease created with it, and because Vault lease IDs are prefixed with the path the secret came from, an operator can revoke every credential issued by one backend in a single prefix revocation, which invalidates them immediately.
Detection and measurement
For static secrets, log reads from the secrets manager, rotation success and failure, and logins with the account from unexpected hosts. For dynamic secrets, log every issuance, renewal and revocation in the broker's audit device, and alert on use of the broker's root credential outside the broker, on mass issuance from one identity, and on logins with a dynamic username after its lease was revoked. OWASP recommends alerting when credentials are used from unexpected IP addresses or user agents. Leaked or stolen secrets used against cloud services map to ATT&CK T1552.001 Credentials In Files and T1078.004 Cloud Accounts; reads from cloud secret stores map to T1555.006 Cloud Secrets Management Stores.
- Median and maximum age of static secrets: falling, with a ceiling set by policy.
- Rotation coverage: percentage of static secrets under automated rotation.
- Dynamic coverage of shared credentials: percentage of credentials with more than one consumer that are now dynamic or federated.
- Median lease TTL by engine: stable and within policy.
- Rotation and renewal failure rate: low and investigated.
- Time to revoke all credentials for one engine: measured in drills.
Common failure patterns
- Dynamic secrets with static-length TTLs. Leases of 30 days or more give the complexity of dynamic issuance with little of the benefit.
- Over-broad role definitions. Every dynamic user is created with full database privileges, so a leaked lease is as damaging as the old shared password.
- The old static account never dropped. The service moves to dynamic credentials but the shared account still exists with its last password, often still in old configuration files.
- Broker root credential known to humans. The administrator's password used to configure the connection is never rotated, so the broker's power sits with a person.
- Rotation that skips "unused" secrets. Credentials assumed dead are left valid; check last-used data before skipping any.
- Applications that cache credentials forever. A service reads the secret once at boot and never re-reads it, so rotation breaks it and teams disable rotation.
Framework mapping
| Framework | Reference | How it applies |
|---|---|---|
| NIST CSF 2.0 | PR.AA-01, PR.AA-05 | Manage credentials for services; least privilege on what each secret can do |
| NIST SP 800-53 Rev. 5 | IA-5 | Authenticator management: changing and refreshing authenticators, protecting them in storage |
| NIST SP 800-53 Rev. 5 | IA-9, AC-2, AC-6 | Service authentication; account management including temporary accounts; least privilege for roles |
| CIS Controls v8.1 | Safeguard 5.5, Control 6 | Service account inventory; access control management |
| ISO/IEC 27001:2022 Annex A | A.5.17, A.8.2, A.8.5 | Authentication information, privileged access rights, secure authentication |
| OWASP NHI Top 10 2025 | NHI7:2025 Long-Lived Secrets, NHI2:2025 Secret Leakage | Short-lived credentials and rotation reduce both risks |
| MITRE ATT&CK | T1552.001, T1078.004, T1555.006 | Secrets in files, valid cloud accounts, cloud secret store access |
Practitioner checklist
- Inventory static secrets with age, consumers, privilege and owner.
- Replace cloud API keys with federation or platform identity first.
- Put every remaining static secret under automated rotation, including ones believed unused.
- Make dynamic secrets the default for databases with many consumers.
- Define least privilege broker roles and set TTL and maximum TTL deliberately.
- Rotate the broker's root credential immediately after configuration and alert on its use.
- Drop shared static accounts once dynamic credentials are live and logins stop.
- Keep documented static exceptions: encryption keys, TLS keys, break-glass, SaaS keys without issuance APIs.
- Drill emergency revocation by path and measure recovery time.
Standards and references
- OWASP: Secrets Management Cheat Sheet
- OWASP: NHI7:2025 Long-Lived Secrets
- NIST: SP 800-53 Rev. 5
- AWS: Secrets Manager rotation strategies
- HashiCorp: Vault lease, renew and revoke
- HashiCorp: Vault database secrets engine
- NIST: Cybersecurity Framework 2.0
Related NHI Mgmt Group resources: Dynamic Secrets and Ephemeral Credentials Guide, Secrets Management Guide, Credential Rotation at Scale, Cloud Secrets Managers Guide, Secrets Zero Problem Guide.