Why I am (still) finding secrets in your code

Luke Marshall

BSides Canberra VIII (2025) · Day 2 · Off-Main Track

Overview

In this compelling talk at BSides Canberra, security researcher Luke Marshall delves into the persistent and alarming issue of secrets — such as API credentials, usernames, passwords, and database credentials — being inadvertently exposed in public code repositories and package registries. Despite advancements in security tooling and a general awareness of the risks, Marshall demonstrates that this problem is far from solved, presenting a comprehensive overview of its scale, impact, and underlying causes. His research, specifically targeting the npm and PyPI ecosystems, uncovered a staggering number of verified secrets, leading to significant bug bounty payouts and critical disclosures to affected organizations.

Watch on YouTube

Visual summary for Why I am (still) finding secrets in your code by Luke Marshall
Visual summary for Why I am (still) finding secrets in your code by Luke Marshall

Key moments

  1. 0:40 23 million exposed credentials in GitHub repos
  2. 3:00 10,000 verified secrets found, $25k in bounties
  3. 4:40 Maintainer access to security tool via GitHub PAT
  4. 6:00 Why secrets are still being exposed: usability, visibility
  5. 8:50 GitHub's native push protection for secret scanning
  6. 12:00 Supply chain compromise via GitHub PAT in deployment workflow
  7. 15:00 Implementing a continuous monitoring system for registries
  8. 22:30 Non-invasive verification methods for leaked credentials

Why I am (still) finding secrets in your code

Speakers: Luke Marshall

Conference: BSides Canberra

YouTube: https://www.youtube.com/watch?v=FVoQ3MkRFBI

Overview

In this compelling talk at BSides Canberra, security researcher Luke Marshall delves into the persistent and alarming issue of secrets — such as API credentials, usernames, passwords, and database credentials — being inadvertently exposed in public code repositories and package registries. Despite advancements in security tooling and a general awareness of the risks, Marshall demonstrates that this problem is far from solved, presenting a comprehensive overview of its scale, impact, and underlying causes. His research, specifically targeting the npm and PyPI ecosystems, uncovered a staggering number of verified secrets, leading to significant bug bounty payouts and critical disclosures to affected organizations.

Marshall's presentation highlights that the exposure of secrets isn't just a theoretical vulnerability; it's a tangible threat responsible for an estimated 31% of data breaches. What makes this issue particularly insidious is the long remediation time—around 292 days to identify and fix—and the fact that a significant portion of previously exposed credentials remain active years later. The talk serves as a stark reminder for developers and security professionals alike that current defensive strategies often fall short, advocating for a more robust, multi-layered approach that includes continuous monitoring of the final published artifacts.

Background

▶ Watch: 23 million exposed credentials in GitHub repos (0:40)

The problem of secrets in code is not new, yet it continues to plague the software development landscape. Luke Marshall emphasizes that in 2025, despite widespread awareness and the availability of secret scanning tools, developers and organizations are still routinely leaking sensitive credentials. This persistence is underscored by data from GitGuardian, which in 2024 reported over 23 million exposed credentials across GitHub repositories, with 4.6% of public repositories containing such leaks. The impact is severe, as stolen credentials are a leading cause of data breaches, and once exposed, these secrets often remain active and exploitable for extended periods.

Marshall attributes this enduring problem to a "perfect storm" of factors: usability, visibility, and the transition from private to public codebases. Modern package managers like npm and PyPI offer incredibly easy command-line interfaces for publishing code, which can inadvertently bypass an organization's established CI/CD pipelines designed for secret scanning. Compounding this is the lack of visibility within these registries; it's difficult for organizations to ascertain their full code footprint or search for packages published by their developers using domain names. Furthermore, the act of moving code from local development environments or private repositories to public registries often involves a step where secret scanning is overlooked or circumvented, leading to the injection of sensitive data into the final published artifact. While platforms like GitHub and Hugging Face have introduced reactive measures like push protection and email notifications, and npm scans for its own tokens, these mechanisms often don't cover the full spectrum of secrets or prevent their injection during complex deployment workflows.

Key Findings

▶ Watch: Maintainer access to security tool via GitHub PAT (4:40)

Luke Marshall's extensive research yielded significant and concerning findings regarding the prevalence and impact of exposed secrets. He initially scanned all 4.2 million packages across the npm (3.5 million) and PyPI (700,000) registries, focusing on the latest versions. Following this initial discovery phase, he expanded his efforts to scan 20 million versions for organizations participating in bug bounty programs or self-hosted security programs.

His primary discoveries include:

  • Scale of Exposure: Marshall successfully identified and verified approximately 10,000 secrets across the scanned packages. This work resulted in over 50 submissions to various bug bounty programs and Vulnerability Disclosure Programs (VDPs), earning him over $25,000 in bounties.
  • High-Impact Secrets: While many exposed secrets were low-impact (e.g., Infura, Alchemy, Twitter consumer keys, Etherscan keys), a significant portion were high-impact credentials. These included MongoDB credentials, GitHub Personal Access Tokens (PATs), and AWS credentials. Marshall specifically noted the danger of exposing root AWS keys or GitHub PATs with broad, legitimate access, which can lead to severe compromise.
  • File Type Prevalence: The majority of secrets were found in common development file types. JSON, JavaScript, and Python files accounted for roughly 80% of all secret findings, aligning with the primary languages used in the npm and PyPI ecosystems. Other file types included PHP, YAML, Java, and TypeScript properties.
  • Critical Supply Chain Vulnerability: A particularly impactful finding involved a GitHub PAT discovered in a .npmrc file. This token provided maintainer-level access to a widely recognized security tool's public repositories. Such access would have allowed Marshall to push malicious code, approve it with the token, and effectively poison the supply chain for all organizations relying on that tool, highlighting the severe consequences of even a single, powerful secret exposure.
  • Organizational Blind Spots: A recurring theme in his interactions with affected organizations was a lack of awareness. Many did not know about the existence of certain packages published by their developers or the presence of secrets within them, especially those not scoped to official organizational namespaces. This lack of visibility makes larger organizations particularly susceptible to this issue.

Technical Deep Dive

▶ Watch: GitHub's native push protection for secret scanning (8:50)

Marshall's research provides a deep dive into the technical mechanisms behind secret exposure and the limitations of traditional defenses. He defines "secrets" broadly to include API credentials, database credentials, usernames, and passwords, emphasizing that not all secrets carry the same risk, with AWS keys, database credentials, and GitHub PATs being among the most critical.

The "perfect storm" he describes for undiscovered exposed credentials involves three core elements:

  1. Usability: Package managers like npm and PyPI are designed for ease of use, often with a single CLI command (npm publish) allowing developers to push code. This simplicity can bypass CI/CD pipelines that incorporate secret scanning, as developers might publish directly.
  2. Visibility: Organizations struggle to map their entire footprint within these public registries. Unlike private repositories, there's no easy way to search for packages by domain or link them directly to an organization, making it challenging to track what individual developers might be publishing.
  3. Transition from Private to Public: Secrets often leak when code moves from local instances or private repositories to public registries (npm, PyPI, GitHub, Docker, AWS ECR). This transition point is where CI/CD scanning might be skipped entirely or where secrets are inadvertently introduced.

Traditional deployment workflows, even those with secret scanning, often fall short. A typical GitHub workflow might include PR checks for secrets, linting, and tests before merging to main, followed by a build, deploy, and publish step. While this seems robust, Marshall notes that secrets can still be injected during the build or deployment phase, meaning the GitHub repository itself might appear clean, but the final published artifact contains the secret. Even pre-commit hooks, which trufflehog offers to prevent secrets from entering the Git stream, require additional developer setup and can be inconsistent.

Platforms have attempted to address this:

  • GitHub Push Protection: Natively scans pushes for secrets and blocks them, requiring user acknowledgment. It covers major services like AWS and GitHub PATs, but is reactive (the secret is already being pushed).
  • Hugging Face: Implemented a similar system, emailing users when secrets are pushed to their repositories. This is also reactive, meaning the secret is exposed, however briefly.
  • npm: Scans for and immediately revokes npm tokens if they are published. This is a proactive and effective measure for its own specific tokens.

However, Marshall illustrated a critical bypass: a GitHub PAT can be used to deploy code to npm. He cited a real-world example involving Malaysia's largest restaurant management software. He consistently observed their GitHub PAT appearing in new versions of their npm packages, often hidden in large JavaScript files. This PAT provided full access to their entire GitHub and npm registries, posing a significant supply chain risk to their 36 packages and 10,000 customers. Through responsible disclosure, he learned that their GitHub repository was clean due to PR secret scanning. The leak occurred because secrets were being injected during the deployment workflow to the npm registry, bypassing the GitHub-level checks. This underscores the necessity of scanning the final artifact that is actually published to a public registry.

Demo / Proof of Concept

▶ Watch: Supply chain compromise via GitHub PAT in deployment workflow (12:00)

While Luke Marshall's talk did not feature a live, real-time demonstration of finding a new secret, he effectively "demonstrated" his methodology and the tools he developed and utilized for his extensive research. He provided a conceptual walkthrough of his continuous monitoring system and his approach to registry replication, both of which serve as powerful proof-of-concept solutions for organizations.

For continuous monitoring, Marshall leveraged the RSS feeds provided by npm and PyPI. His system works as follows:

  1. Feed Polling: Every minute, the system pulls the RSS feeds, which contain information about newly created or updated package names.
  2. Maintainer Resolution: It then resolves the maintainers and authors associated with these packages.
  3. Queueing: The package names are sent to an AWS Simple Queue Service (SQS). This provides a durable, decoupled queue, preventing bottlenecks and ensuring that no package is missed, even during high volume.
  4. Package Scanning: A separate container, acting as the package scanner, pulls names from the SQS queue. It then downloads and scans the specified package version for secrets using tools like TruffleHog.
  5. Logging Results: All findings are logged, allowing for subsequent analysis and action.

This system proved highly effective for Marshall, enabling him to catch secrets in older package versions even if a developer subsequently published a new, "clean" version. He highlighted the cost-effectiveness of this setup, running on approximately $1.50 per month for AWS services and $12 per month for a Virtual Private Server (VPS) to host the containers. The code for this system is publicly available on his GitHub repository.

Additionally, Marshall described his method for replicating the npm registry into a local database. He initially used a custom script and later found that npm's CouchDB instance could also facilitate this, albeit with some bugs. The purpose of this replication is to create a more queryable registry. This allows organizations to:

  • Map their footprint: Identify all packages published by their developers, even those not under an official organizational namespace. He used the example of PayPal, showing numerous packages not directly associated with their official scope.
  • Identify unknown packages: Discover packages that developers might have published without the organization's knowledge.
  • Scan comprehensively: Once the full organizational footprint is mapped, every package can be scanned for secrets.

This registry replication tool is also available on his GitHub, encouraging others to adapt and utilize it. For the actual secret scanning and non-invasive verification, Marshall primarily used TruffleHog, noting its ability to validate keys by hitting arbitrary, non-destructive API endpoints (e.g., get caller identity for AWS keys) without malicious intent. He also mentioned GitLeaks as another potential tool, suggesting that running both might yield more comprehensive results due to differing upstream detection capabilities.

Defensive Implications

▶ Watch: Non-invasive verification methods for leaked credentials (22:30)

The findings from Luke Marshall's research underscore the critical need for a paradigm shift in how organizations approach secret management and detection. Traditional defensive strategies, while valuable, are often insufficient on their own. He outlines three common approaches and their limitations:

  1. Endpoint Focus (Pre-commit hooks): Tools like TruffleHog and GitLeaks can be implemented as pre-commit hooks to scan code before it enters the Git stream.
  • Limitation: Requires individual developer setup, can be bypassed, and doesn't account for secrets introduced later in the pipeline.
  1. CI/CD Pipelines: Integrating secret scanners into CI/CD workflows (e.g., GitHub Actions, GitLab CI) to scan code during pull requests or merges.
  • Limitation: Effective for code in the repository, but can be bypassed if developers publish directly or if secrets are injected during the build/deployment phase, as demonstrated by the Malaysian company example. The source code might be clean, but the published artifact is not.
  1. Platform Reliance: Relying on built-in platform features like GitHub Push Protection, Hugging Face's email alerts, or npm's token revocation.
  • Limitation: Often reactive (secrets are detected after being pushed), limited in scope (e.g., npm only scans for its own tokens), and doesn't cover all possible secret types or deployment scenarios.

Marshall strongly advocates for a multi-layered approach with a significant emphasis on monitoring the final published artifact in the public registry itself. His key recommendations for defenders include:

  • Scan the "End Product": Do not solely rely on scanning source code in Git repositories. Implement scanning on the actual packages or artifacts before they are published to public registries, or, even better, continuously monitor the registries post-publication.
  • Implement Continuous Monitoring: Utilize a system similar to his open-source project that polls RSS feeds of package registries (npm, PyPI) for new or updated packages. This allows for immediate scanning of every new version for secrets, catching issues that might be missed by earlier pipeline stages or subsequently "fixed" in newer versions but still present in older, vulnerable ones.
  • Map Your Organization's Footprint: Replicate package registries into a queryable database (like his open-source tool) to identify all packages published by your developers, including those not under official namespaces. This helps discover shadow IT or unknown assets that could be leaking secrets.
  • Proactive Remediation: Upon discovery of a secret, immediately revoke it. This proactive step is crucial, given the long dwell times of exposed credentials.
  • Educate Developers: Foster a culture of security awareness regarding secret management, secure coding practices, and the risks associated with public package publication.
  • Secure Deployment Workflows: Scrutinize and secure deployment pipelines to ensure that secrets are not inadvertently injected into artifacts during the build or packaging process, even if the source repository is clean.

By adopting these comprehensive strategies, organizations can move beyond reactive detection and build a more resilient defense against the pervasive threat of exposed secrets in their code.

Key Takeaways

  • Secrets Remain a Widespread and Critical Threat: Despite advances in security, millions of credentials are still exposed in public repositories (e.g., 23 million in GitHub in 2024, affecting 4.6% of public repos), leading to a significant portion of data breaches.
  • High-Impact Secrets are Common: Critical credentials such as root AWS keys, database credentials, and GitHub PATs with broad access are frequently found, posing severe supply chain compromise risks.
  • Traditional Defenses Are Insufficient on Their Own: Pre-commit hooks, CI/CD pipeline scanning, and platform-native protections (GitHub Push Protection, npm token scanning) are valuable but can be bypassed or are reactive, often missing secrets injected during deployment or published directly.
  • Continuous Monitoring of Registries is Essential: Proactively scanning public package registries (like npm and PyPI) using tools like Luke Marshall's RSS-feed-based system is crucial for detecting secrets in the final published artifacts, catching issues missed by earlier checks.
  • Organizations Must Understand Their Full Footprint: Replicating package registries into a queryable database allows organizations to identify all packages published by their developers, even those outside official namespaces, revealing hidden assets that may be leaking secrets.
  • Adopt a Multi-Layered, Proactive Approach: A robust defense requires combining endpoint scanning, CI/CD integration, platform features, and, most importantly, continuous, post-publication monitoring of the actual artifacts in public registries to effectively combat secret exposure.

About the Speaker(s)

Luke Marshall is a dedicated security researcher and accomplished bug bounty hunter specializing in identifying and addressing vulnerabilities related to exposed secrets in open-source ecosystems. His work, as detailed in this talk, primarily focuses on public package registries such as npm and PyPI. Marshall has a proven track record of discovering critical secrets, responsibly disclosing them to affected organizations, and contributing to the security community, evidenced by his earning of over $25,000 in bug bounties. He actively develops and shares open-source tools for continuous monitoring and registry analysis, empowering other organizations to enhance their secret detection capabilities.

Reviews

→ Top-rated talks at BSides Canberra VIII (2025)

All talks from BSides Canberra VIII (2025)