OOmnistu

Blog / Security

Security

Secrets management basics: API keys, passwords and rotation, from OWASP's cheat sheet

Plan controlled storage, access, rotation and revocation for application credentials while keeping secrets out of code and logs.

OOmnistu
Reviewed 2026-11-16 · 5 min read
Centralise and standardise
Use a managed way to store, provision, audit and rotate secrets; it should be clear what a secret is for and where to find it.
Automate, least privilege
Manual handling raises leak and error risk, and engineers should not have access to all secrets - anyone who can read a secret can leak it.
Rotate so theft expires fast
Regular rotation means a stolen credential works only briefly; per NIST, user credentials rotate when compromise is suspected, not on a schedule.

All wording checked against the OWASP Secrets Management Cheat Sheet linked in Sources.

Secrets include API keys, database credentials and private SSH or signing keys. IAM permissions describe access policy, not a secret value; certificates may be public while their private keys must be protected. OWASP's Secrets Management Cheat Sheet, read on 15 November 2026, describes how to handle them. We read it except the cloud-provider detail (section 4.1 onwards) and the encryption section (7). This is one source's checklist and does not certify any setup. The sheet notes many organisations hard-code secrets in plain text in source code and configuration, and that services often share the same secret, which makes the source of a leak hard to find.

Core practices

Lifecycle

  1. Creation: generate securely and strongly enough for the purpose, with minimum privileges; do not send the password with the username when provisioning accounts.
  2. Rotation: rotate regularly so a stolen credential works only briefly. Lifetimes range from minutes to years depending on function. The sheet excludes user credentials from regular rotation, per NIST: rotate those when compromise is suspected. Rotating encryption keys may need data re-encryption, with strategies such as writing with new keys while keeping old keys for reading.
  3. Revocation: revoke when no longer needed or possibly compromised.
  4. Expiration: set an expiry where possible so rotation is triggered.

Rotation patterns described: a Kubernetes sidecar that fetches secrets into an in-memory shared volume, and a cloud secrets manager invoking a rotation function in steps (create, set, test, finish).

Creation

Generate securely and strongly enough for the purpose, with minimum privileges.

Rotation

Rotate regularly so a stolen credential works only briefly; lifetimes range from minutes to years depending on function.

Revocation

Revoke when no longer needed or possibly compromised.

Expiration

Set an expiry where possible so rotation is triggered.

Secrets in memory

The sheet says to start with a threat model; protecting memory is often overkill, but may be worth it in sensitive settings. Measures it lists: avoid immutable strings in .NET and Java (use byte or char arrays you can overwrite), zero memory after use, and memory encryption where available.

Identity providers

OpenID Connect delegates user login but does not require passwordless authentication and does not remove phishing or weak passwords at the identity provider. Choose one that enforces strong controls, such as WebAuthn. Tokens and client credentials still need protecting, and OIDC does not replace database credentials or API keys.

CI/CD

Containers

Build-time secrets are not recommended. Three ways to get secrets into a container: mounted volumes (mounted by the orchestrator, never built in), fetching from a secret store through a sidecar (in memory), and environment variables overwritten by the orchestrator. Never hard-code secrets with Docker ENV or ARG, since they leak with the container definition. Expose secrets only to intended containers. A deliberately restricted in-memory volume shared with a secrets sidecar is different from an unrestricted shared volume; keep that access narrow, and encrypt the orchestrator's secret storage.

Dynamic or static

Dynamic secrets suit short-lived credentials for connecting services, session-length keys and deployment-time credentials. The sheet notes they often need long-term static secrets to create them, and some uses stay static (storage encryption keys, TLS PKI keys, services that cannot issue temporary credentials). Limit who and what can read secrets; if a tool cannot restrict access, consider separate secrets managers for production and development. Monitor who accesses a secret and from where; the sheet says to alert and assume compromise if CI/CD credentials are used from an unexpected IP. Define alerts for anomalous retrieval and attempts to write secrets to logs.

Detection

Approaches listed: shared test secrets to cut false positives, detection in the IDE or a pre-commit hook, treating secrets as part of the threat model, more than one detection tool with de-duplicated results, and a balance between easy-to-detect formats and not missing human-created passwords. Types to detect include tokens that are hard to rotate, configuration files, connection strings, API keys, passwords, 2FA keys, private keys, session tokens and platform-specific secrets. Secrets must never be logged. Document who has access, how it rotates, dependencies that rotation could break, and the incident contact.

For a small team, as questions

Limits

We did not read the sheet's cloud provider selection, envelope encryption and IAM detail (section 4) or its encryption section (7), and we recommend no specific product. We quote no breach statistics.

By Omnistu.

Sources

Previous
Do you need obfuscation and anti-tampering in your mobile app? What OWASP MASVS-RESILIENCE says