Join our Newsletter — 33% off our NHI Course
Home› Guides› Secrets Management Cheat Sheet: Storage, Rotation and Detection…
Template Secrets Management

Secrets Management Cheat Sheet: Storage, Rotation and Detection Rules

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 11 min read
On this page

Most secret leaks are not clever attacks but ordinary rules that nobody wrote down: a key pasted into a repository, a token that never expires, a CI variable every maintainer can read. This cheat sheet condenses secrets management into rule tables you can adopt as an engineering standard: where secrets may live, when they must rotate, who and what may read them, where to detect leaks, and what to do in the first hour after one. It is for developers, platform engineers and the security teams who set their guardrails. The rules draw on the OWASP Secrets Management Cheat Sheet, the OWASP Non-Human Identities Top 10 for 2025 and NIST key management guidance. For the programme view (operating model, tooling choices, maturity), see the Secrets Management Guide.

Key takeaways

  • A secret has one home. Store it in a secrets manager or a platform identity, never in code, images, tickets or chat; everything else is a copy to find and remove.
  • Short-lived beats rotated, rotated beats static. Prefer workload identity federation and dynamic credentials; where a static secret is unavoidable, give it an owner, an expiry and automated rotation.
  • Rotation has triggers, not just a calendar. Exposure, a leaver with access, a vendor incident and a scope change all force rotation regardless of schedule.
  • Detect at four points. The developer machine (pre-commit), the platform (push protection), the pipeline (CI scanning) and runtime (secret use and audit logs) each catch leaks the others miss.
  • Revoke first, then clean up. Deleting a leaked secret from a file or history does nothing for the copy an attacker already holds; revocation and rotation come before history rewriting.

How to use this template

  • Adopt the rules as a standard: copy the rule tables into your engineering standards, replace [Organisation], [secrets manager] and [owner] placeholders, and mark each rule Must, Should or Could for your environment.
  • Classify secrets first: rotation and access rules depend on class. Use the classes in section 2 or your own, and record the class as metadata on every secret.
  • Turn rules into controls: each rule has a detection or enforcement point in section 4. A rule without a check will drift.
  • Scope: machine secrets (API keys, tokens, database credentials, private keys, certificates, webhook URLs). User passwords follow different rules: OWASP notes that user credentials are excluded from regular rotation and should be rotated on suspicion or evidence of compromise, in line with NIST.

1. Storage rules

#RuleWhyCheck
S1Store every machine secret in [secrets manager] or replace it with a platform identity (managed identity, IAM role, Kubernetes service account with federation).One audited home; OWASP recommends centralising and standardisingInventory of secrets outside the manager trends to zero
S2No secrets in source code, configuration files committed to version control, scripts, infrastructure as code variables or container images.OWASP NHI2:2025 lists hard-coding and plain text configuration as primary leak pathsPre-commit and CI scanning (section 4)
S3Do not pass runtime application secrets through CI/CD; deploy with a platform identity and let the service fetch its own secrets at runtime.OWASP calls this the recommended approach; it decouples build systems from production secretsPipeline variable review
S4If a secret must live in CI/CD tooling, keep it low-value and narrowly scoped, document it, and confirm forks and copied jobs cannot read it.CI variables are exposed to jobs and maintainersQuarterly CI secret review; see How to Audit CI/CD Secrets Scope
S5Prefer files or in-memory injection over environment variables for sensitive secrets, and never print secrets to logs.Environment variables leak through crash dumps, debug output and child processesLog scanning; see Environment Variables vs Secrets Manager
S6Encrypt secrets at rest with keys held in a KMS or HSM, and use TLS for every retrieval.Protects the store and the path to itConfiguration baseline
S7GitOps: commit only secrets encrypted to an environment-specific key (for example a Sealed Secrets resource), never plain Kubernetes Secret manifests.Only the target environment's controller can decryptRepository policy check
S8Record metadata for every secret: owner, consuming systems, class, created date, expiry, rotation method and dependencies.OWASP: prepare to move the secret; without metadata, rotation breaks thingsMetadata completeness metric
S9Plan for availability: back up the secrets manager, test restore and keep a documented break-glass path.A secrets outage is a production outageRestore test record

Bootstrapping the first credential that unlocks the store is its own problem; see the Secrets Zero Problem Guide.

2. Rotation rules

OWASP's guidance is that secrets should be rotated regularly so a stolen credential works only for a short time, and that lifetimes range from minutes to years depending on function. NIST SP 800-57 Part 1 Rev. 5 frames this as the cryptoperiod: the time span a key is authorised for use. OWASP NHI7:2025 Long-Lived Secrets warns against credentials with distant or no expiry dates. The periods below are a starting template to set by policy, not values from those sources.

Rotation by secret class

ClassExamplesPreferred modelMaximum lifetime (set by [Organisation])
Cloud and CI accessCloud access keys, deployment credentialsFederation (OIDC) with short-lived tokens; no static keys[Hours for issued tokens]
Database credentialsApplication database usersDynamic credentials with lease TTLs[Lease TTL; static fallback in days]
Third-party API keysSaaS and AI model provider keysAutomated rotation through provider API where offered[Days]
Signing and encryption keysToken signing keys, data keysKMS-managed rotation with versioning[Per cryptoperiod policy]
CertificatesTLS and client certificatesACME or internal CA automation[Days]
Hard-to-rotate tokensLegacy integration tokens, webhook URLsScoped down, monitored, scheduled for replacement[Documented exception with expiry]

Rotation triggers (rotate now, regardless of schedule)

TriggerAction
Secret found in code, logs, tickets, chat or an imageRevoke and rotate immediately (section 5)
A person with read access leaves or changes roleRotate every secret they could read in plain text
Vendor, CI platform or dependency security incidentRotate secrets held by or exposed to that party
Scope or privilege change for the consuming workloadIssue a new secret with the new scope; retire the old one
Secret past its expiry or cryptoperiodRotate automatically; alert if automation fails
Decommissioned service or integrationRevoke, not just delete; see Deleted but Not Revoked

Rotation without downtime: create the new version, deploy consumers that accept both, switch, verify, then revoke the old version. Rotation that needs a manual change window will be skipped. See Credential Rotation at Scale.

3. Access rules

#RuleCheck
A1One secret per workload per environment; no sharing a secret between services, environments or people (OWASP NHI9:2025 NHI Reuse, NHI8:2025 Environment Isolation).Duplicate value detection in the store
A2Grant read access per secret path to the consuming workload identity only; humans get write or rotate rights, not read, wherever possible.Policy review; human read events
A3Separate the right to exchange an OIDC token or assume an identity from the right to read specific secrets.Federation trust review
A4Preserve caller attribution: secret requests from pipelines must trace to the job, trigger or commit.Audit log sampling
A5Minimum privilege on the secret itself: the key or token should carry only the scopes the workload needs.Scope review against usage
A6No human use of machine credentials (OWASP NHI10:2025 Human Use of NHI).Interactive use of service credentials alerts
A7Administrative access to the secrets manager is privileged access: MFA, just-in-time elevation, logged sessions.PAM coverage of store admins

To remove static cloud keys from pipelines entirely, see Workload Identity Federation vs Static Cloud Keys.

4. Detection rules

Detection points

PointWhat it catchesMechanismNotes
IDE and pre-commitSecrets before they enter historyPre-commit hook running an open-source scanner (for example Gitleaks or detect-secrets)Developers can skip hooks, so treat as a convenience layer; see the Git Hooks and Pre-commit Security Guide
Push protection on the code platformSecrets in pushes, web edits, uploads and API commitsPlatform feature such as GitHub push protectionBypasses create alerts and audit entries; restrict who can bypass with delegated bypass
CI scanningSecrets in branches, pull requests, build logs and artefactsScanner step on every pull request plus full-history scans on a scheduleFail the build on verified secrets; see How to find secrets in CI logs and build artefacts
Images and artefactsSecrets baked into containers and packagesImage layer scanning in the registrySee How to find hard-coded secrets in container images
Collaboration toolsSecrets in chat, tickets and wikisScanning connectors and DLP rulesOWASP NHI2:2025 names public chat and file shares as leak paths
Runtime and auditMisuse of a valid secretSecrets manager audit logs, cloud and SaaS logsThe only point that sees a secret already stolen

Runtime audit events to alert on

The OWASP cheat sheet lists what to audit at a minimum. Turn these into alerts:

  • Use of an expired or revoked secret: a strong compromise signal; log every attempt.
  • Retrieval by an unexpected identity or location: a workload reading a secret it has never read, or a human reading a machine secret.
  • Authentication and authorisation errors: bursts against the store or against the service the secret unlocks, which may indicate attackers validating leaked secrets; see Leaked Secret Validation Detection.
  • Bulk retrieval or listing: enumeration of many paths in a short window.
  • Administrative changes: policy edits, audit log changes, new auth methods on the store.
  • Clock problems: OWASP notes audit trails depend on correct timestamps, so monitor time sync on the store's infrastructure.

5. Leak response

The OWASP cheat sheet orders containment as revocation, rotation, deletion and logging. In practice:

  1. Revoke: de-authorise the exposed secret at the issuer immediately. Treat any secret that reached a public repository as compromised, even if it was removed minutes later.
  2. Rotate: issue a replacement through automation, with least privilege, and deploy it to consumers.
  3. Investigate use: pull the issuer's logs for the exposure window: who used the secret, from where, and what it touched.
  4. Remove copies: delete the secret from code, logs, tickets and images. Rewriting Git history is optional and has side effects (it breaks commit links); do it only after revocation. See How to Remove Secrets From Git History.
  5. Fix the cause: move the secret to [secrets manager] or replace it with federation, and add the missing detection point.
  6. Record: owner, exposure path, time to revoke, time to rotate and evidence of use, for metrics and lessons learned.

For full playbooks, see the API Key Leak Response Playbook and the Cloud Access Key Leak Playbook.

6. Metrics and framework mapping

MetricTarget direction
Secrets stored outside the approved managerDown to zero
Share of secrets with automated rotation or replaced by federationUp
Secrets past maximum lifetimeDown; see How to measure secret age and rotation coverage
Median time from detection to revocationDown (hours, not days)
Push protection bypasses per month and share reviewedBypasses down, review at 100%
Secrets with complete metadata (owner, expiry, consumers)Up
FrameworkReference
NIST SP 800-53 Rev 5IA-5 Authenticator Management; IA-5(7) No Embedded Unencrypted Static Authenticators; SC-12 Cryptographic Key Establishment and Management; SC-28 Protection of Information at Rest; AC-6 Least Privilege; AU-6 Audit Record Review, Analysis, and Reporting
NIST CSF 2.0PR.AA-01 identities and credentials managed; PR.DS-01 data at rest protected; DE.CM-09 runtime environments monitored
OWASP NHI Top 10 2025NHI2 Secret Leakage; NHI7 Long-Lived Secrets; NHI8 Environment Isolation; NHI9 NHI Reuse; NHI10 Human Use of NHI
MITRE ATT&CK v20T1552.001 Credentials In Files; T1552.004 Private Keys; T1528 Steal Application Access Token; T1078.004 Cloud Accounts

Practitioner checklist

  • Publish the storage, rotation and access rules as an engineering standard with an owner.
  • Inventory secrets and record owner, class, expiry, consumers and rotation method for each.
  • Replace static cloud and CI keys with workload identity federation.
  • Automate rotation for every class that supports it and document exceptions with an expiry date.
  • Enable pre-commit scanning, platform push protection with restricted bypass, and CI scanning on every pull request.
  • Alert on use of revoked or expired secrets, unexpected retrieval and bulk listing in the secrets manager.
  • Rehearse the leak response: revoke, rotate, investigate use, remove copies, fix the cause.
  • Report the six metrics monthly and review exceptions quarterly.

Standards and references

Related NHI Mgmt Group resources: Secrets Management Guide · Dynamic Secrets and Ephemeral Credentials Guide · OWASP NHI Top 10 NHI2 Secret Leakage Guide · OWASP NHI Top 10 NHI7 Long-Lived Secrets Guide · Workload Identity Federation Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.