Secrets management

On this page 7

Secrets management is the discipline of securely storing, distributing, rotating and auditing the credentials that software uses to authenticate itself, such as API keys, database passwords, tokens, private keys and certificates. In application security, it replaces hardcoded credentials in source code and configuration files with a controlled system that issues secrets only to verified workloads.

A mature approach treats every secret as a short-lived, scoped and logged asset. It answers four questions at any moment: where each secret lives, who or what can read it, when it was last rotated, and how quickly it can be revoked after a leak.

How secrets management works

A secrets management system centralizes credentials in an encrypted secret store, usually called a vault, and exposes them through an authenticated API. Applications do not carry a password in their code; they prove their identity to the vault, receive only the secrets their access policy allows, and use them for a limited time.

The vault encrypts data at rest with a master key that is itself protected, often by a hardware security module (HSM) or a cloud key management service. This pattern, known as envelope encryption, means that a stolen copy of the storage backend is useless without the separately guarded key.

The table below lists the building blocks found in most implementations.

ComponentRoleTypical implementation
Secret storeHolds encrypted credentialsVault server or cloud secret service
Identity brokerAuthenticates workloadsCloud IAM roles, Kubernetes service accounts
Access policiesDefine who reads which pathPath-based or attribute-based rules
Rotation engineReplaces credentials on scheduleBuilt-in rotation or scheduled jobs
Audit logRecords every read and changeAppend-only log sent to a SIEM
Core components of a secrets management system

Types of secrets and how they differ

Secrets differ in lifetime, blast radius and rotation difficulty, so a single policy rarely fits all of them. A cloud root credential deserves stricter handling than a test API key, and a signing key used for releases needs different controls than a session token.

Secret typeTypical lifetimeMain risk if leaked
Database passwordsDays to monthsFull data read or modification
Cloud access keysMinutes to monthsInfrastructure takeover and cost abuse
API tokensHours to a yearAbuse of third-party accounts
TLS private keysUp to the certificate validityImpersonation of a service
Signing keysYearsMalicious releases trusted by users
Encryption keysMonths to yearsDisclosure of protected data
Common secret types and their handling

The strongest pattern is dynamic secrets: the vault creates a unique credential on request, for example a database user valid for one hour, and deletes it automatically. Dynamic secrets make every credential traceable to one workload and shrink the window in which a leaked value is useful.

Secrets management overlaps with several neighboring practices, and confusing them leads to gaps. Key management concentrates on cryptographic keys and their lifecycle, often inside an HSM, while secrets management covers every credential an application consumes. Environment variables and configuration files are delivery mechanisms, not management systems, because they lack rotation, access control and auditing.

PracticePrimary focusRelation to secrets management
Key managementCryptographic key lifecycleProtects the vault master key
Identity and access managementHuman and workload identitiesSupplies identities the vault trusts
Secret scanningFinding leaked credentialsDetects failures of the process
Configuration managementApplication settingsShould reference secrets, not contain them
Software composition analysisThird-party dependenciesSeparate supply chain control
How secrets management relates to neighboring practices

In the OWASP guidance on application security, cryptographic failures and security misconfiguration frequently trace back to exposed credentials, which is why secrets management is considered a baseline control rather than an advanced option.

Implementing secrets management in practice

Implementation begins with an inventory of existing secrets across repositories, CI/CD pipelines, container images and infrastructure templates, followed by migration into one controlled store. Teams then remove plaintext copies and rewrite Git history where credentials were committed, because deleting a file in a later commit does not remove it from earlier revisions.

The decision table below summarizes common situations and recommended approaches.

SituationRecommended approachReason
Workloads in one cloudNative cloud secret serviceIntegrates with IAM roles
Hybrid or multicloud estateCentral vault platformOne policy and audit model
Kubernetes workloadsExternal secrets operator or CSI driverAvoids plain base64 secret objects
CI/CD pipelinesOIDC federation to cloud rolesRemoves long-lived pipeline keys
Developer laptopsCLI access with single sign-onNo shared credential files
Choosing a secrets delivery approach
  • Least privilege: grant each workload read access only to its own secret paths.
  • Automated rotation: rotate high-value credentials on a schedule and after every staff departure.
  • Pre-commit scanning: block commits that contain patterns matching keys or tokens.
  • Break-glass procedure: document emergency access that is logged and reviewed afterward.

Common failures and risks in secrets management

Most credential incidents do not involve broken cryptography; they involve secrets in the wrong place. Public repositories, container image layers, build logs and crash reports are the most common leak paths, and automated scanners operated by attackers can find an exposed cloud key within minutes of publication.

Centralization also creates a high-value target. The vault itself needs strong authentication, network isolation, high availability and a tested unseal and recovery process, because an outage of the secret store can stop every dependent application. Another subtle risk is secret zero: the initial credential an application uses to reach the vault must come from a trusted platform identity, not from yet another hardcoded token.

Finally, rotation that has never been exercised often fails when it is needed most. Teams should test rotation regularly and confirm that applications reload new credentials without downtime.

In everyday language

Software needs passwords too. An online shop’s code needs a password to reach its database and a key to talk to the payment provider. Writing those passwords directly into the code is like taping the house key to the front door: anyone who sees the code gets in.

Secrets management is a locked key cabinet with a guard. Programs ask the guard for a key, show who they are, receive only the key they are allowed to use, and often have to return it after a short time. The key idea: every password has one safe home, a clear owner and a record of who used it.

Seen in the real world

A mid-sized online retailer runs forty microservices on Kubernetes. During a routine audit, its security team finds a production database password in a configuration file committed to Git three years earlier, readable by more than sixty developers. The password had never changed because nobody knew which services depended on it.

The team deploys a central vault, connects it to Kubernetes service account identities and switches the order service to dynamic database credentials that expire after one hour. Pipeline keys are replaced with OIDC federation, and a pre-commit scanner blocks new credentials in code. Six months later, a contractor accidentally pastes a token into a public issue tracker; because the token was valid for only 30 minutes and scoped to one read-only path, the incident ends with a log review instead of a breach.