What Is Secrets Management? How to Protect Passwords, Keys and Tokens

A developer needs to test a connection to the production database, so they paste the password into a configuration file just for a moment. The file is committed. Months later, the repository is copied to a contractor's laptop, and the password, which has never been changed, now sits in places nobody is tracking.
This is how many breaches begin: not with a clever exploit, but with a credential left where it should not be. Secrets management exists to stop it.
Quick answer: Secrets management is the practice of securely storing, controlling, delivering, rotating and auditing the credentials that applications, systems and people use to access each other, such as passwords, API keys, tokens and certificates. Instead of hard-coding secrets in code, files or scripts, they are kept in a central vault, given out only to authorized users and services when needed, changed regularly, and logged. CMEx delivers secrets management as part of its Secure Infrastructure Automation practice.
What counts as a secret?
A secret is any piece of information that grants access to a system or data. Common examples include:
Passwords for databases, servers, admin consoles and service accounts.
API keys and tokens for cloud services, payment gateways, SaaS tools and AI services.
Certificates and private keys used for encryption and to prove identity.
SSH keys for server access.
Cloud access keys that can create, change or delete infrastructure.
Encryption keys that protect sensitive data.
Many of these are used by machines rather than people: applications, scripts, pipelines and containers all need credentials to talk to each other.
Why is secrets management a growing problem?
Secrets keep leaking. GitGuardian's State of Secrets Sprawl 2026 report found 28.65 million new hard-coded secrets added to public GitHub commits in 2025, a 34% increase on the year before.
Internal code is worse. The same research found that internal repositories hold far more secrets than public ones, so private code is not a safe place for credentials.
Machine identities are multiplying. Microservices, containers, automation and AI agents each need their own credentials, often far outnumbering human users.
Leaked secrets stay valid. Credentials that are never rotated can be used by attackers long after they leak.
Secrets are scattered. They end up in code, configuration files, pipeline settings, chat messages, tickets and wikis, so nobody has a full picture.
What are the core practices of secrets management?
The OWASP Secrets Management Cheat Sheet is a widely used reference. In practical terms, good secrets management means:
Centralize secrets: store them in a dedicated secrets manager or vault, not in code, files or spreadsheets.
Never hard-code secrets: applications and scripts fetch secrets from the vault at run time.
Apply least privilege: each user, application and pipeline can access only the specific secrets it needs.
Use short-lived and dynamic secrets: where possible, generate credentials on demand that expire automatically, instead of long-lived passwords.
Rotate regularly: change long-lived secrets on a schedule and immediately after any suspected exposure.
Encrypt everywhere: secrets are encrypted at rest and in transit.
Audit every access: log who or what accessed each secret, when and from where.
Detect leaks: scan code, pipelines, logs and collaboration tools for exposed secrets.
Plan for incidents: know how to find where a leaked secret is used and replace it quickly.
What are dynamic secrets?
Traditional secrets are static: the same password is used for months or years. Dynamic secrets are created on demand for a specific user or application, with limited permissions and a short lifetime, and then expire automatically.
For example, instead of every application sharing one database password, each application asks the vault for its own temporary credential when it starts. If that credential leaks, it is useful to an attacker only briefly and can be traced to one application.
How does secrets management fit into DevSecOps and infrastructure as code?
In code: applications read secrets from the vault at run time, so nothing sensitive is stored in source control.
In CI/CD pipelines: jobs receive only the secrets they need, only while they run, as covered in our guide to a secure CI/CD pipeline.
In infrastructure as code: templates reference secrets in the vault rather than containing them, as explained in our guide to infrastructure as code.
In containers and Kubernetes: secrets are injected securely at run time and access is limited to the right workloads.
In zero trust: each service gets its own identity and short-lived credentials, a key part of zero trust architecture.
How do you get started with secrets management?
Find your secrets. Scan code repositories, pipelines, configuration files and collaboration tools to see where credentials live today.
Rotate anything exposed. Change secrets that have been found in code or shared in unsafe places.
Set up a central vault. Choose a secrets management platform and define who can manage it.
Move high-risk secrets first. Start with production databases, cloud admin keys and payment or customer system credentials.
Change how applications get secrets. Update applications and pipelines to fetch secrets from the vault at run time.
Introduce dynamic secrets and rotation. Use short-lived credentials where possible and automate rotation for the rest.
Add leak detection. Scan new code and pipeline changes so secrets are caught before they are committed.
Monitor and review access. Audit who uses which secrets and remove access that is no longer needed.
What are the common challenges?
Legacy applications: older systems may expect passwords in configuration files, so they need adapters or gradual changes.
Fear of breaking things: teams avoid rotating secrets because they do not know what depends on them. Good inventory and automation fix this.
Multiple vaults: different teams and clouds using separate tools can recreate the sprawl problem. Standard practices across tools help.
Protecting the vault itself: the secrets manager becomes a high-value target, so it needs strong access control, backup and monitoring.
How CMEx delivers secrets management
CMEx's Secure Infrastructure Automation practice includes secrets and identity management as a core capability, alongside infrastructure as code and zero-trust networking.
In practice, that covers:
Secrets and identity management with a central vault, dynamic secrets and automated rotation.
Integration with CI/CD and infrastructure as code, so secrets are never stored in code or templates.
Zero-trust networking, giving users and services verified, least-privilege access.
Governed cloud provisioning and endpoint security, so environments and devices follow the same rules.
Partner technologies including HashiCorp Vault and Boundary, and Red Hat OpenShift and Ansible.
This connects with CMEx's DevSecOps work and its focus on regulated industries such as Banking & Financial Services and Telecom, where control of credentials and audit evidence are essential.
Frequently asked questions
What is the difference between secrets management and password management?
Password managers mainly help people store their own passwords. Secrets management focuses on credentials used by applications, systems and automation, such as API keys, database credentials and certificates, with features like dynamic secrets, rotation and machine access control.
Is it safe to keep secrets in environment variables?
It is better than hard-coding them, but environment variables can still be exposed through logs, crash reports or debugging tools. The safer approach is to fetch secrets from a vault at run time, with access limited to the application that needs them.
What should we do if a secret is leaked?
Revoke or rotate it immediately, find everywhere it is used and update those systems, check logs for any misuse, and remove it from the place it leaked, including code history. Then fix the process that allowed the leak.
How often should secrets be rotated?
It depends on the risk and type of secret. High-value credentials should be rotated often, ideally automatically, and immediately after any suspected exposure. Dynamic secrets that expire after minutes or hours reduce the need for manual rotation.
Do secrets in private repositories count as a risk?
Yes. Private repositories are copied, shared with contractors and sometimes made public by mistake, and attackers who get inside an organization often search them for credentials. Secrets should never be stored in any code repository.
Can secrets management work across multiple clouds?
Yes. A central secrets platform can serve applications across on-premises, private cloud and public cloud environments, giving consistent control and auditing wherever workloads run.
How does secrets management help with compliance?
It enforces least-privilege access to credentials, rotates them regularly and logs every access. That gives auditors clear evidence that sensitive systems are protected, which is important in banking, telecom and the public sector.
Conclusion
Secrets are the keys to your systems, and they leak more often than most organizations realize. Secrets management brings them under control: stored centrally, given out only when needed, changed regularly and logged every time. Start by finding and rotating exposed secrets, set up a central vault, move your highest-risk credentials first, and build secrets handling into your pipelines and infrastructure code.
Not sure where your secrets are today? A CMEx practice principal, not a sales rep, will review how credentials are stored and used in your environment and show where to start.


