← Back to section · Open Source Projects
Open-Source Secrets Management: Getting Passwords, Tokens and Private Keys Out of the Code
Secrets scattered across config files and repositories are a common root of supply-chain incidents. Vault, SOPS and age answer the problem from three directions — centralised custody, file-level encryption and minimalist tooling.
Why Secrets Always Escape Control
Almost every team passes through a stage of secret sprawl: a database password sits in a config file, the config file enters the code repository, repository permissions keep widening, and departed members’ local copies are tracked by no one. Credential leakage perennially ranks among the top causes of breaches in incident statistics, and much of it is not theft by sophisticated means but secrets simply stored too carelessly. What secrets management tooling must solve is not “is the encryption strong enough” — modern algorithms are more than sufficient — but turning the creation, distribution, use, rotation and revocation of secrets into an orderly process, so that “who used which key, and when” becomes an answerable question.
The Centralised Route: A Server Issues Everything
Centralised designs, represented by HashiCorp Vault, place secrets in a dedicated server: applications no longer hold long-term passwords but exchange their own identity for short-lived dynamic credentials — a database account valid for hours, expiring automatically, compressing the leak window to a minimum. The server also carries access control and auditing: which identity read which secret, and when, is all recorded. The costs are equally plain: the server itself becomes a high-value target and an availability single point, demanding clusters, unseal procedures and dedicated operators; and how the master key that unlocks the entire store is kept leads straight back to the old root-of-trust question. The fitting scenario is larger scale, many services, and explicit compliance audit requirements.
The File-Based Route: Ciphertext in the Repository
The other route assumes no always-on service and instead stores encrypted secret files directly in version control. SOPS, started by Mozilla, is the representative: it encrypts the values inside structured config files such as YAML and JSON while leaving keys readable, delegating the decryption keys to cloud key services or existing systems like PGP and age. Age, created by Filippo Valsorda, is more minimalist still: a small, focused file-encryption tool whose interface is deliberately narrow — “no configurability, no way to misconfigure” — often used as the encryption primitive beneath this route. The strengths of such designs are a natural fit with existing code review and version control workflows, where secret changes pass the same approval as code changes; the weaknesses are coarser rotation and revocation granularity, and access auditing only indirectly available through repository logs. For individuals and small-to-medium teams, starting here is entirely reasonable.
The Shared Root: Master Keys and People
Both routes converge on the same question: where does the key that unlocks everything live? Established engineering practice is layering and separation: the master key never sits on any server’s disk, recovery material is split among several holders, and unsealing requires multiple people present or hardware devices participating. Open hardware keys and smart cards are common in such procedures precisely because they turn “knowing” into “holding”. Conversely, if the master key lies in a text file on some machine, however exquisite the tooling above it, the attacker merely faces one extra door that pushes open. When evaluating any secrets management scheme, ask where the root of trust lands before asking about features.
Two Commonly Underestimated Things
The first is how automated rotation really is. Many teams adopt a tool yet never rotate, and secrets management degenerates into secrets storage. Half the tool’s value is rotation: short-lived credentials make rotation routine rather than an incident-response action. The second is the application side’s willingness to change. Centralised designs require applications to fetch secrets dynamically and handle credential expiry and renewal — work operations alone cannot deliver; underestimating it is the most common cause of abandoned rollouts. The pragmatic path is staged: bring the most sensitive, least-changing production credentials under management first, then extend coverage step by step, rather than aiming for totality at project kickoff.
After a Leak: The Response Playbook Beyond the Tools
No management regime reduces leak probability to zero, so half of a secrets programme’s quality shows in response speed after an incident. A mature playbook usually has four moves. First, scope the impact: use audit records to answer who used this key and on which systems; a system that cannot answer is left with the blunt instrument of rotating everything. Second, fix the order of revocation and rotation: whether old credentials die before new ones are distributed, or the reverse, depends on whether the business can tolerate brief authentication failures, and should be graded in advance by system criticality rather than improvised mid-incident. Third, close the leak channel before assigning blame: if the secret escaped through a logging pipeline or a debug interface, rotating keys without closing the channel just leaks the new ones too. Fourth, review and deposit: the leak path should become a detection rule or a process prohibition on the next round’s defence list.
Open-source tools each carry a segment of this playbook: centralised services provide audit queries and one-action revocation, file-based schemes rely on version history to trace how a secret was introduced and how far it spread, and scanning tools continuously hunt for plaintext secrets accidentally committed to code and artifacts. Only the three together form the complete chain from prevention through detection to response. Buying one segment and neglecting the others is the deeper reason many teams keep having incidents after adopting tooling.
Conclusion
Secrets management has no silver bullet, only order matched to scale: a small team keeping ciphertext in version control with a file-based scheme already beats plaintext sprawl, while a large organisation trades a centralised service for short-lived credentials and audit capability at the price of taking root trust and operations seriously. Either way, the test is always the same: when any single key leaks, can you quickly answer what it opens, and how fast all of it can be replaced?
Tags: Secrets ManagementVaultSOPSage