Home Solutions Industries Portfolio Pricing Blog Affiliate Contact
Quote
← Back to all posts
Secrets Management: Keeping API Keys, Passwords and Tokens Out of Harm's Way
DevOps & Infrastructure

Secrets Management: Keeping API Keys, Passwords and Tokens Out of Harm's Way

BL
BlackCode Admin November 10, 2026 · 2 min read

API keys, database passwords, M-Pesa credentials and signing keys are the keys to your business. They leak more often than most teams realise: committed to Git, pasted in chat, printed in logs or left in old servers.

Where secrets leak

  • Committed to code repositories, including in old commits.
  • Shared in chat messages and emails.
  • Printed in logs and error messages.
  • Baked into Docker images.
  • Stored in plain-text files on servers and laptops.

Better storage

OptionGood for
Environment variables injected at runtimeSimple deployments
Cloud secrets managersCloud-hosted apps, rotation, audit logs
Vault-style toolsMultiple environments, dynamic secrets
Password managersHuman access to shared credentials

Tired of risky deployments and surprise downtime?

We set up CI/CD, monitoring and infrastructure that lets your team ship calmly.

WhatsApp us+254 731 209 601Book a free demo20 minutes, no costCall us+254 731 209 601

Practices

  1. Never commit secrets; add secret scanning to your repository and CI.
  2. Use different secrets for each environment.
  3. Grant each service only the secrets it needs.
  4. Rotate secrets regularly and immediately after staff changes or suspected leaks.
  5. Prefer short-lived credentials and roles over long-lived keys.
  6. Log access to secrets.

If a secret leaks

  1. Revoke or rotate it immediately; deleting the commit is not enough.
  2. Check logs for misuse.
  3. Find how it leaked and fix the process.
  4. Notify affected parties if data may have been accessed.

Key takeaways

  • Secrets leak through code, chat, logs and images.
  • Store them in a secrets manager or inject at runtime.
  • Scan repositories automatically.
  • Rotate immediately after any suspected leak.

Frequently asked questions

Is a .env file safe?

On a protected server, outside the repository and with tight permissions, it is acceptable for small setups.

How often should we rotate secrets?

Regularly, such as every 90 days, and always after staff changes or incidents.

Can you audit our secrets handling?

Yes. We scan repositories, review storage and set up rotation.

Tired of risky deployments and surprise downtime?

We set up CI/CD, monitoring and infrastructure that lets your team ship calmly.

WhatsApp us+254 731 209 601Book a free demo20 minutes, no costCall us+254 731 209 601

0 comments 0 likes

Comments (0)

Be the first to comment on this post.