Secrets management

Hand-drawn broad stepped terracotta channels with angular slivers running diagonally through interlocking masonry blocks hatched in cream, sand, umber and moss.

Secrets management is the practice of keeping the credentials software uses to authenticate (API keys, tokens, passwords, private keys) out of reach, and of limiting damage when one leaks. Secrets leak at scale: a peer-reviewed measurement found them in over 100,000 public GitHub repositories, with thousands of new ones each day (Meli et al., 2019). In honeypot tests, attackers used planted cloud keys within seconds to minutes (Toulas, 2026). The disputes are about how many detected strings are real secrets, how long leaked secrets stay usable, and whether scanning tools prevent leaks. On the last two, most figures come from security vendors.

Where secrets leak

Secrets leak wherever code and its build products are published: source repositories, container images, packages, apps and build logs (Meli et al., 2019; Dahlmanns et al., 2023; Kadkoda et al., 2022).

Code repositories

Public code hosting is the best-measured leak path. The 2019 GitHub study counted leaks in over 100,000 repositories, and most stayed online: just over 12% were gone after one day, and only 19% after 16 days (Meli et al., 2019). A vendor, GitGuardian, counted 12.8 million new secrets leaked on public GitHub in 2023, up 28% from the year before (Segura, 2024).

Leaks are common in developers’ own experience too. In a survey of 109 developers, 30.3% reported first-hand experience of a secret leaking in their projects (Krause et al., 2022).

Container images, packages and apps Strong evidence: many studies agree on this

Later peer-reviewed measurements found secrets in other published artefacts at rates from 8.5% to 35%. In 2023, 8.5% of 337,171 Docker Hub images and images from private registries held secrets, including 52,107 private keys (Dahlmanns et al., 2023). Across GitHub, PyPI (the Python package index) and WeChat, up to 30% of projects were at risk of leaking secrets (Zhou et al., 2025c). In 50,000 Android apps from 2025, detection found secrets in 35%, and 1,802 of 18,908 detected secrets were still active (Alecci et al., 2026).

Leaked keys from images were in real use. The same container study found 275,269 servers using leaked private keys for TLS and SSH authentication (Dahlmanns et al., 2023).

Build logs Weak evidence: few or small studies support this

Build logs from continuous integration (CI), the services that build and test code on each change, have leaked secrets, but the measurements come from security vendors, not peer-reviewed studies. In 2022, Aqua Security found about 73,000 tokens, secrets and credentials in a sample of roughly 8 million public Travis CI log requests (Kadkoda et al., 2022). Travis CI masked a GitHub token in many cases but missed about 20 variations of it, and told the researchers that old logs were exposed by design (Kadkoda et al., 2022).

Provider changes then cut live leaks sharply. Travis CI began expiring logs older than 365 days in 2022 and started censoring secrets in logs with scanning tools in January 2023 (Rahal, 2023). A re-scan of about 4.7 million logs in 2023 found 80 unique live secrets, most likely from users who had switched off the default masking (Rahal, 2023).

Masking in logs has gaps on other platforms too. GitHub’s documentation warns that secrets printed in logs are not redacted when its workaround for large secrets is used (GitHub, n.d.e). In 2025, a compromised third-party GitHub Action (a reusable build step), tj-actions, disclosed secrets including valid access keys (CISA, 2025). Such attacks through shared build components are covered under software supply chain security.

How many detected secrets are real

The share of detected strings that are real secrets depends on how strictly they are filtered. In SecretBench, a dataset hand-labelled by two raters, only 15,084 of 97,479 candidate secrets from 818 public GitHub repositories were true secrets, about 15.5% (Basak et al., 2023b). The 2019 GitHub study used strict filters, and its manual review of 240 random hits estimated that 89.10% were sensitive rather than test or dummy keys (Meli et al., 2019).

The strict figure covers a narrow slice of secrets. That study looked only at private key files and 11 platforms whose API keys have distinctive formats (Meli et al., 2019). Its filters also passed some keys that were valid but harmless, such as an RSA key in a unit test of a cryptographic library (Meli et al., 2019).

Detection tools disagree widely on what they report. In one comparison on public repositories, GitHub’s secret scanner had the best precision, the share of its warnings that were real secrets, at 75% (Basak et al., 2023a). Gitleaks had the best recall, the share of real secrets it found, at 86% and 88% in two test cases (Basak et al., 2023a).

How fast leaked secrets are abused Weak evidence: few or small studies support this

Attackers can find and use exposed cloud keys within minutes, but the figures rest on a few honeypot experiments, where researchers plant a working key and watch for its use. A GitHub honeypot with a dummy Amazon Web Services (AWS) key was found and abused within about one minute (Bischoff, 2020). In a study of Docker Hub images, the fastest use of a planted AWS key came 7.86 seconds after publication. All 100 planted keys were used within 15 minutes (Toulas, 2026).

How long leaked secrets stay valid Weak evidence: few or small studies support this

According to vendor measurements, most leaked secrets remain usable for weeks or years. Truffle Security tracked 10,000 leaked secrets and found 74% still valid 31 days after the leak (Leon, 2024). GitGuardian reports that over 90% of exposed secrets were still active five days after the leak (Segura, 2024). In a later snapshot of public code, Truffle found 543,699 unique credentials still valid, with a median exposure of 784 days (Truffle Security Research, 2026).

Deleting a leaked secret does not end the risk; revoking it does. In more than half of the cases where exposed keys were taken down from GitHub, the keys stayed valid (Leon, 2024). Where providers revoke their own leaked tokens, almost none survive: 1 of 101,886 committed npm tokens and 260 of 73,048 GitHub tokens were still live (Truffle Security Research, 2026). Truffle advises rotating a secret first and cleaning up the code history afterwards (Truffle Security Research, 2026).

Developers who leak a secret mostly replace it. In a survey of 109 developers, 54.1% of those who had leaked one renewed or revoked it, and 17.4% cleaned the version-control history (Krause et al., 2023).

Keeping secrets out of code

The usual advice is to keep secrets outside the code and add scanning as a second line of defence. The authors of a developer study recommend environment variables, vaults or secret managers, blocking secret files from repositories, and scanners, especially before each commit (Krause et al., 2023). In their survey, about half of developers kept secrets outside the code, and 29.4% blocked them from the repository, for example with a .gitignore file (Krause et al., 2023).

Secret managers, services that store secrets and hand them to applications at run time, are not easy to adopt. In a lab study, all 21 new users stored and read a secret with one within 30 minutes. Only 18 of 21 managed to inject it into an application (Neil et al., 2025).

Platform-level limits did not stop large-scale exposure in 2019. The GitHub study found that automatic leak detectors, requiring several secret values, and rate limits on GitHub search all failed to limit it (Meli et al., 2019).

Secret scanning and push protection Weak evidence: few or small studies support this

Whether scanning reduces leaks is unsettled: the before-and-after figures come from vendors, and an independent study found developers often bypass warnings. Push protection blocks a commit that contains a recognised secret before it reaches the repository. GitHub reports that it stops about 30% of newly detected secrets before they enter repository history, counting additional secret types (Havens, 2026). After GitHub turned it on by default, Truffle Security found exposure of covered credential types fell 53%, against 7% for uncovered ones. It could not tie the drop to the rollout date (Truffle Security Research, 2026).

Reported bypass rates differ widely. GitHub reports that developers overrode 3.93% of push blocks in mid-2026, down from 6.63% two years earlier (Havens, 2026). In a peer-reviewed case study of one company’s blocking tool, developers bypassed warnings in 44.2% of cases once and in 7.2% permanently (Rahman et al., 2022).

False alarms explain only part of the bypassing. Those developers judged 50% of the warnings false positives, but also bypassed under time pressure, for projects that would not ship, and because they saw commits as low risk (Rahman et al., 2022). The authors recommend a second check to catch wrong bypasses (Rahman et al., 2022).

Few developers scan for secrets at all. In a survey, only 14.7% reported regular scanning, against 55.0% who kept secrets outside the code (Krause et al., 2022). The authors link the low uptake to false positives and manual review work, and interviewees said tools that change their workflow a lot slow them down and get bypassed (Krause et al., 2022).

Encryption at rest and key management

Encryption at rest mainly protects data on stolen disks and backups, not data in a running system; this rests on guidance and vendor documentation rather than measured outcomes. Microsoft describes the threat its database encryption (Transparent Data Encryption, TDE) addresses as theft of drives or backup tapes (Microsoft, 2025d). TDE decrypts data as it is read into memory and does not encrypt network traffic (Microsoft, 2025d). OWASP, a web security community, says the right layer of encryption depends on the threat: encrypting the disk protects against theft of the server, not against remote compromise (OWASP Cheat Sheet Series, n.d.a).

Encryption is only as strong as the separation of keys from data. OWASP advises storing keys apart from the encrypted data, so that an attacker who reaches one cannot reach both (OWASP Cheat Sheet Series, n.d.a). Envelope encryption puts this into practice. The application encrypts data with a data key it generates, a key management service encrypts (“wraps”) that key with a key that never leaves the service, and the wrapped key is stored beside the data (Google Cloud, 2026b).

Keys also bring a risk of their own. A TDE-protected backup can be restored only with the certificate that protects its key, so losing the certificate loses the data (Microsoft, 2025d). OWASP states that the best protection for sensitive information is not to store it (OWASP Cheat Sheet Series, n.d.a).

Encryption also changes legal duties after a breach. Under the EU’s General Data Protection Regulation (GDPR), a controller need not tell people about a breach if encryption or similar measures made the data unintelligible to outsiders (European Union, 2016a). What causes breaches in the first place is covered under data breaches; misuse of cryptographic libraries in code is covered under secure software development.

Further reading

Known gaps

What this article cannot tell you yet.

  1. The effect of GitHub push protection on leaks was measured only by vendors (GitHub and Truffle Security); no independent before-and-after study of secret scanning was found.
  2. No peer-reviewed measurement of secrets in CI build logs was found, and how often GitHub Actions logs expose secrets was not measured.
  3. No critique of whether honeypot abuse speeds represent real leaks was found; the speed figures rest on a few single experiments.
  4. No empirical study of how server applications manage encryption keys, or of breaches where encryption at rest made a difference, was found.
  5. The effect of short-lived credentials on leaks and abuse was not researched.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 24 references