top of page

Copyright © 2026. All rights reserved.

Services

Attack Surface Review

Attack Simulation

Compliance Gap Review

Security Baseline

Security Architecture

Security Operations Oversight

Virtual CISO

Security Risk & Decision Management

Security Certification Program

Resources

Insights

Blog / news

Events

Resources

We bring clarity to cybersecurity, helping organizations navigate complexity, make confident decisions and innovate with confidence.

header

Blog

Get to know all our latest news and learn from our knowledge

How Leaked API Keys and Passwords Put Your Attack Surface at Risk

Apr 8, 2025
5 min read

A single API key in a public repository can do the same damage as an unlocked admin panel. It may give an attacker access to cloud storage, source code, payment systems, email platforms, monitoring tools, or production data. The risk grows when teams assume the secret is old, unused, or already rotated.


That assumption is often wrong.


Secrets sprawl happens when API keys, tokens, passwords, certificates, and other credentials spread beyond controlled systems. They appear in Git commits, public repositories, support tickets, chat logs, build files, and copied configuration snippets. Once exposed, they are hard to track, hard to revoke, and easy for attackers to test at scale.


Wide-angle view of a cracked safe with glowing key cards scattered on concrete.
Leaked credentials often sit in plain sight long before anyone notices them.

Public code is still leaking private access


The GitGuardian State of Secrets Sprawl 2025 report shows that secrets continued to leak into public GitHub repositories throughout 2024. GitHub is not the only place this happens, but it is one of the most visible. Public code can be cloned, indexed, searched, and monitored by anyone, including attackers who run automated scans for credentials.


This is not limited to junior mistakes or forgotten test projects. Common leaks include:


  • Cloud access keys committed in `.env` files

  • Database passwords copied into configuration examples

  • Personal access tokens used to automate deployments

  • Messaging and email service tokens used in test scripts

  • Private keys added to repositories to “fix” a temporary issue

  • Secrets pasted into tickets during incident response


The pattern is usually mundane. A developer needs to debug a failing service. A support engineer asks for logs. A build pipeline needs a token quickly. A temporary shortcut becomes part of the record.


The danger is that Git remembers. Ticketing systems remember. Search engines, mirrors, forks, and local clones may remember too.


Why leaked secrets can stay valid for years


Many organisations have password rotation rules for humans, yet far weaker controls for machine credentials. That gap matters because attackers do not care whether access came from a person or a script. If the key works, it works.


Leaked secrets often remain valid for years because of four practical failures.


Nobody owns the credential


A token may belong to a former employee, a shared service account, or a deployment process no one wants to touch. If no team clearly owns it, no team rotates it.


This is common in older software-as-a-service products where integrations grew over time. A payment key, error tracking token, or build secret may have existed before the current team joined.


Rotation might break production


Teams hesitate to rotate secrets when they do not know where those secrets are used. One API key may be hardcoded in several services, stored in a build tool, copied into a ticket, and included in a local script.


Rotating it without a map can cause outages. So the work gets delayed.


Alerts focus on new leaks, not old ones


GitHub secret scanning and similar tools can catch many new leaks, especially for known token formats. But older exposures can be harder to manage. A secret leaked two years ago may still be live, even if the original repository has since been made private or deleted.


Security teams need historical checks, not just real-time alerts.


Some systems have no expiry by default


Many access keys and tokens do not expire automatically. Unless an organisation sets expiry dates, scopes access, or runs regular reviews, a leaked credential can remain useful long after the project that created it has changed.


That is why old exposed secrets are not harmless history. They are often active access paths.


Close-up of an old brass key tagged with a cloud symbol lying beside a torn code printout.
Old secrets can keep opening systems long after the original project has moved on.

Attackers treat exposed credentials as doors, not clues


Attackers do not need to exploit a complex software flaw if a leaked key gives them a direct route in. That is the core risk of exposed secrets.


A public token can let an attacker:


  • Read private data from a storage bucket

  • Send messages through a trusted email provider

  • Pull images from a private container registry

  • Access source code or internal packages

  • Modify cloud resources

  • Create new credentials for persistence

  • Move from a test environment into production


The first step is often automated. Attackers scan public repositories for patterns that look like keys. They test them against the relevant service. If a key is valid and has broad permissions, the incident can escalate quickly.


This is why scope matters. A read-only token limited to one development service is still bad if leaked, but it is very different from a long-lived cloud key with permission to create servers, read storage, and manage identity settings.


The strongest defence is not just finding leaks faster. It is making sure any leaked credential has limited power, a clear owner, and a short life.


Tickets and logs are part of the same problem


Repositories get attention because public GitHub is easy to scan. But secrets also leak into less obvious places.


Support tickets often contain screenshots, pasted configuration, stack traces, or full environment dumps. Incident channels may include “temporary” passwords during an outage. Build logs can print variables by mistake. Error tracking tools may capture request headers that include tokens.


These systems are not always public, but they still expand the attack surface. More people can access them. More third-party tools may process them. Retention periods may be long. Search features can make old secrets easy to find.


For CTOs, engineering leads, and DevOps teams, the lesson is clear: secrets management cannot stop at the repository boundary. It must include the full software delivery path.


What a practical response looks like


A useful secrets programme does not rely on one tool or one policy document. It combines detection, ownership, and safer defaults.


Start with these controls:


  1. Scan public and private code


    Use repository scanning to detect committed secrets before and after code is pushed. Include historical scans, because older commits may still contain valid keys.


  2. Scan tickets, logs, and collaboration tools


    Repositories are only one source. Extend checks to systems where engineers paste debugging data.


  3. Rotate confirmed leaks quickly


    Treat a valid leaked secret as an incident. Deleting the commit or ticket is not enough. Revoke or rotate the credential.


  4. Reduce permissions


    Give tokens only the access they need. Avoid broad service accounts where a narrow key would do.


  5. Set expiry dates


    Permanent credentials create permanent risk. Short-lived credentials limit the damage window.


  6. Track ownership


    Every production secret should have an owner, a purpose, and a rotation path. If no one owns it, it will not be maintained.


  7. Block secrets before commit


    Pre-commit checks and protected pipelines catch mistakes early, when the fix is cheap.


The 2025 takeaway is persistence


Secrets sprawl is not a one-time hygiene issue. It is a persistence problem. Credentials leak during normal software work, and many remain valid because rotating them feels risky, ownership is unclear, or old systems have been forgotten.


The GitGuardian State of Secrets Sprawl 2025 report is a reminder that public GitHub leaks in 2024 were not rare edge cases. They were part of a continuing pattern across modern software delivery.


Review your attack surface now. Look beyond the newest alerts, check historical leaks, include tickets and logs, and verify whether old credentials still work. The most dangerous secret is often the one everyone assumes has already been dealt with.


Curious whether any of your keys or credentials are already out in the open? It’s one of the things we hunt for in an Attack Surface Review.

 
 
footer
Banner mobile

Let’s protect what matters most

Tell us about your challenges and we’ll guide you through the solution

bottom of page