Shared .env files work for a team of two. At ten engineers and three environments they become a security risk. Here is a practical path to managed secrets.
Almost every project starts with a .env file. It is simple, it works locally and it keeps credentials out of the code. The trouble begins when the file is shared over chat, copied between laptops and pasted into CI settings — and nobody is sure which copy is current, or who has seen it.
Signs you have outgrown .env files
- Secrets are shared over messaging apps or email.
- Nobody can say who has access to production credentials.
- Rotating a key means updating several places by hand.
- Former team members may still hold working credentials.
Move secrets into a managed store
Cloud providers offer managed secret stores, and dedicated tools such as HashiCorp Vault exist for more complex needs. What they have in common matters more than which you choose: encrypted storage, fine-grained access control, audit logs and support for rotation.
Give workloads identities, not passwords
Where possible, let applications authenticate with the identity of the environment they run in — a cloud role or a workload identity — rather than a long-lived key. There is no secret to leak if there is no secret at all.
If a secret leaks
Rotate it first and investigate second. Removing a key from Git history doesn’t make it safe — assume anything that was committed has already been copied.
Stop leaks before they happen
- Run secret scanning in pre-commit hooks and in CI.
- Keep
.envin.gitignore, and commit a.env.examplewith placeholder values instead. - Use short-lived credentials for CI pipelines.
- Rotate keys on a schedule — and immediately when someone with access leaves.
Secrets management isn’t glamorous, but it is one of the highest-value security improvements a growing team can make — and it gets harder to retrofit the longer you wait.
Written by
Devant Quality Engineering
Test automation and security
Quality and security engineers who build the automation and practices that keep releases calm.




