Cloud & app security

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

Secrets management keeps the credentials your software uses — API keys, database passwords and tokens — in one protected place, instead of scattered through code and files.

Cysoro Security TeamPublished · 9 min read
VAULTAPI keys · tokens · certssk-••••••••••••••••••CLOUD & APP SECURITYSecretsmanagementOne vault. No keys in code.
Quick answer

Secrets management is the practice of storing, controlling, rotating and auditing the credentials software uses — API keys, database passwords, SSH keys, tokens and certificates — in a central, encrypted store, and giving each application and person only the access they need, for only as long as they need it.

Key takeaways

  • A secret is any credential software uses to act on your behalf, and it should never live in source code, chat or shared files.
  • Centralize secrets in one encrypted store, apply least privilege, audit every access and rotate on a schedule and after any leak.
  • Short-lived and dynamic secrets beat long-lived keys: a stolen credential should stop working within minutes or hours, not years.

Every application you run holds keys to your business: the payment API key, the database password, the token that lets your website send email. If those keys are scattered through code, chat messages and shared spreadsheets, one leak can hand an attacker the same access your software has.

What is secrets management?

Secrets management is the practice of storing, controlling, rotating and auditing the credentials software uses, in a central encrypted store, so each application and person gets only the access they need. It replaces scattered copies with one governed place.

A secret is any value that lets its holder authenticate, sign, decrypt or call an API as someone or something else. OWASP lists API keys, database credentials, IAM permissions, SSH keys and certificates as typical examples, and notes that many organizations still have them hard-coded in source code in plaintext.

The problem is scale. A small business may have dozens of secrets; a larger one has thousands. OWASP warns that services often share the same secret, which makes identifying the source of a leak challenging. Centralizing storage, provisioning, auditing and rotation is how you regain control.

Secrets management is not a single product. It is a discipline plus tooling: a vault or cloud secrets manager, rules about where secrets may live, automation for rotation, and logs that show who read what and when.

What counts as a secret?

Any credential that lets software act on your behalf counts as a secret, whether a human ever types it or not. If losing it would let an attacker read data, move money or take over a system, treat it as one.

  • API keys — keys for payment, email, maps, AI and other third-party services.
  • Database passwords — credentials applications use to read and write your data.
  • Tokens — OAuth tokens, session tokens and personal access tokens for GitHub, cloud and SaaS tools.
  • SSH keys and private keys — keys that log into servers or sign certificates and code.
  • Certificates — TLS certificates and the private keys behind them.
  • Cloud access keys — credentials that control your cloud account, storage and infrastructure.

Human passwords are a different category. A password generator helps people create strong logins, but secrets management is about machine credentials that applications and pipelines use at runtime.

Why does secrets management matter?

Leaked secrets are one of the fastest routes into a system, because the attacker does not need to break anything — they simply log in with a valid credential. A leaked API key can be used from anywhere in the world, within minutes of appearing online.

Automated scanners constantly crawl public code repositories, container images and configuration files looking for keys. OWASP notes that secrets are often hard-coded in source code and littered through configuration files, which is exactly where scanners look first.

CISA and NIST have also flagged secrets management as a weak point in cloud identity security, noting that scaling centralized secrets management risks misconfiguration and inconsistent policies, and that proper rotation matters. Their joint guidance, IR 8587 on protecting tokens and assertions, covers token and secrets controls for cloud systems.

The cost of getting it wrong is not just the leak. If every service shares one key, you cannot tell which service was compromised, you cannot revoke access for one service without breaking the others, and you cannot prove what the attacker did.

How does secrets management work?

A secrets manager stores secrets encrypted, controls who can read each one, delivers them to applications at runtime, and records every access. Applications ask for a secret when they need it, instead of carrying a copy in their code.

How a secrets manager worksCentral vaultencrypted at restone place, notscattered filesaccess controlaudit logApp requestsat runtime, byidentity, not a fileShort-lived secretdynamic, expiresin minutes or hoursRotationautomatic, onschedule or leakold secret revokedNo secret is baked into code or a container image.
The secrets manager pattern: one encrypted vault, runtime delivery, short-lived credentials and automatic rotation. Illustration by Cysoro.

The flow has four parts. First, the secret is created with strong random generation and the minimum privileges it needs. Second, it is stored encrypted, with fine-grained access control on each item. Third, the application retrieves it at runtime through an API, authenticated by its own identity. Fourth, access is logged, and the secret is rotated or revoked on schedule.

OWASP recommends automating as much of this as possible. Manual handling increases the risk of leakage and human error, and a secrets pipeline or dynamic secrets can remove people from touching the actual values at all.

Dynamic secrets are the strongest version of this pattern. When an application starts, it requests database credentials that are generated for that session and expire shortly after. If one leaks, it is already useless.

What is the secret lifecycle?

Every secret follows the same lifecycle: creation, rotation, revocation and expiration. Managing that lifecycle deliberately is most of what secrets management means in practice.

StageWhat happensWhat to get right
CreationA new secret is generated and storedStrong random generation, minimum privileges, record owner and purpose
RotationThe old value is replaced with a new oneAutomate it; rotate on departure, suspected leak and schedule
RevocationA secret is disabled before its expiryRevoke in the issuing system first, then remove copies
ExpirationA secret stops working at a set timeSet an expiry wherever the platform allows it

OWASP stresses that new secrets must be securely generated and cryptographically robust enough for their purpose, with the minimum privileges assigned. It also recommends recording metadata — creation, rotation and deletion times, owner, purpose and type — so you can find and move a secret later.

Rotation deserves special care. Rotating encryption keys can trigger partial data re-encryption, so OWASP describes strategies such as writing with new keys while keeping old keys for reading. For database credentials, cloud secret managers often rotate in steps: create the new secret, set it, test it, then finish.

What are the most common secrets management mistakes?

Most secret leaks are not sophisticated attacks. They are ordinary mistakes, repeated across teams, and each one has a straightforward fix.

  • Hard-coding secrets in source code. This is the top mistake OWASP names. Use a vault and inject secrets at runtime instead.
  • Committing .env files to git. Once a secret is in version history, removing the file does not remove the secret. Rotate it and clean the history.
  • Sharing one key across services. When it leaks, you cannot tell which service was the source, and revoking it breaks everything at once.
  • Long-lived keys that never rotate. A key valid for years gives an attacker years to use it quietly.
  • Printing secrets in logs or CI output. Logs are copied, stored and searched — treat them as public.
  • Giving everyone access to everything. Anyone who can read a secret can leak it, so apply least privilege to people as well as services.
  • Deleting a leaked secret without revoking it. OWASP is blunt here: removing it from history does not protect you, because bots may already have scraped it.

A related mistake is baking secrets into container images. An image is easy to share, copy and inspect, so a secret baked into one is effectively published. Deliver secrets at runtime instead.

What are secrets management best practices?

OWASP's cheat sheet groups the work into a few principles that cover most of the risk. Start with the first two, then work down the list.

  1. Centralize and standardize. Put secrets in one managed place, with the same rules for every team. Standardization should cover lifecycle management, authentication, authorization and accounting.
  2. Apply least privilege. Engineers should not have access to all secrets. Each secret should be readable only by the people and services that need it.
  3. Automate rotation. Use a secrets pipeline, dynamic secrets or automated rotation of static secrets, so no human handles the value by hand.
  4. Audit everything. Log who requested a secret, whether the request was approved, when it was used, when it expired, and any failed attempts. Protect those logs from tampering.
  5. Keep secrets out of code, images and logs. Scan repositories and pipelines for leaked secrets, and block them before they enter history where you can.
  6. Plan for secret zero. Use platform identity — a cloud IAM role, a Kubernetes service account or workload identity — to authenticate to the vault, rather than a stored master token.

For CI/CD pipelines, the strongest pattern is workload identity: the CI platform issues a short-lived token that the cloud provider validates, granting a scoped role, with no long-lived cloud credential stored anywhere.

Never trust "deleted"Deleting a leaked key from a file or a repository does not revoke it. Revoke and rotate in the issuing system first, then clean up copies.

Secrets manager vs password manager vs vault: what is the difference?

These tools overlap in name but solve different problems, and most teams need more than one of them.

ToolWho it is forWhat it storesKey feature
Secrets managerApplications and servicesAPI keys, tokens, database passwordsRuntime delivery, rotation, audit logs
Password managerPeopleWebsite and app loginsAutofill, sharing, breach alerts
VaultPlatform and security teamsMachine credentials, certificates, keysDynamic secrets, fine-grained policy
Cloud secret storeCloud workloadsCloud service credentialsNative rotation, IAM integration

In practice, a "vault" and a "secrets manager" are often the same kind of product under different names — HashiCorp Vault and AWS Secrets Manager are both secrets managers. The useful distinction is the audience: human passwords belong in a password manager, machine credentials belong in a secrets manager, and neither should live in code.

Cloud teams often use the secret store built into their cloud provider, while private-cloud teams use a third-party vault. OWASP notes that centralizing to one solution still leaves the primary secret of that solution to be secured somewhere else, so plan for that bootstrap credential from the start.

How do you start secrets management in a small team?

You do not need an enterprise platform to start. A small team can get most of the benefit in a few weeks with a simple, ordered plan.

  1. Inventory your secrets. List every secret, what system it unlocks, who owns it and when it was last changed. One page is enough to start.
  2. Move the riskiest ones first. Payment, customer database and email credentials come before low-risk keys.
  3. Give each service its own key. Stop sharing keys between services, environments and people. Never share a production credential with a test environment.
  4. Put them in one vault. Choose one secrets manager and make it the only approved home for machine credentials.
  5. Set a rotation calendar. Rotate on a schedule, on departure and on any suspected leak. Automate the first rotation you can.
  6. Scan for leaks. Add a pre-commit check that blocks secrets from entering git, and scan existing repositories for keys already committed.
  7. Write the leak plan down. Who revokes, who checks logs, who tells customers — decided in advance, not during an incident.

Check your own public surface as you go. Our security headers checker covers related risks.

Our spear phishing guide covers the social-engineering side of credential theft.

Our small business cybersecurity checklist puts secrets alongside backups, updates and device security, following the practices in the OWASP Secrets Management Cheat Sheet.

Small-team starter checklist1. Inventory every secret — owner, system, last changed2. Move payment, database and email keys into one vault3. One key per service, per environment — never shared4. Rotate on a schedule, on departure, and on any leak5. Scan code and CI output; block secrets before commitDone in weeks, not months — and it covers most of the risk.
Five steps that give a small team most of the benefit of secrets management. Illustration by Cysoro.

The bottom line

Secrets management is not about buying a vault. It is about knowing what credentials you have, keeping them in one protected place, giving each one the narrowest access that works, and making sure a stolen one stops working quickly.

Start with the inventory, move the riskiest secrets into a vault this week, and write down what you will do the day one leaks. You can check the security of your own site in the meantime with the free security headers checker.

Frequently asked questions

What is secrets management in simple terms?

It is keeping every credential your software uses in one protected, encrypted place, handing each one only to the systems and people that need it, and changing it regularly. Think of it as a locked safe for API keys and passwords, with a log of who opened it.

What counts as a secret?

Any value that lets its holder act as someone or something else: API keys, database passwords, SSH keys, OAuth tokens, certificates and private keys, and cloud access keys. If losing it would let an attacker read data, move money or take over a system, it is a secret.

Is a password manager the same as secrets management?

No. A password manager stores human passwords for websites. Secrets management stores machine credentials for applications, services and pipelines, and delivers them at runtime with access controls, rotation and audit logs. A small team may use both, for different jobs.

How often should secrets be rotated?

Rotate on a defined schedule and immediately after any suspected leak, staff departure or change of access. OWASP prefers short-lived dynamic secrets that expire automatically over long-lived keys rotated on a fixed calendar. CISA guidance commonly cites at least every 90 days for API keys.

What should I do if a secret leaks?

Revoke and rotate it first, in the system that issued it, before doing anything else. Removing it from code or history does not help, because automated scanners may already have copied it. Then check audit logs for use of the leaked credential and look for other exposed secrets.

What is secret zero?

Secret zero is the bootstrap problem: the credential your application uses to authenticate to the secrets manager itself. If that credential sits in a config file, you have only moved the problem. The fix is platform identity, such as a cloud IAM role or workload identity, so no stored master secret is needed.

Do small businesses need secrets management?

Yes, in a small form. Even a team of three has API keys for payments, email and cloud services. A shared vault, one key per service, and a rotation habit cover most of the risk without an enterprise platform.

Sources

  1. OWASP — Secrets Management Cheat Sheet
  2. CISA — CISA and NIST Release Guidelines to Protect Federal Cloud Identity Systems
  3. OWASP — Secrets Management, DevSecOps Guideline
  4. CISA — Securing Core Cloud Identity Infrastructure
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the OWASP Secrets Management Cheat Sheet, OWASP DevSecOps Guideline and CISA/NIST guidance on token and secrets management.

How we write and fact-check →

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free