The Problem: Pervasive and Persistent Secrets Exposure
The landscape of application security is increasingly defined by the challenge of managing secrets. These credentials, tokens, API keys, and other sensitive material are the keys to our digital kingdoms, and their exposure represents a direct pathway to compromise. The sheer volume of leaked secrets is staggering. In 2025, a reported 28.6 million new secrets were leaked on public GitHub alone, marking a 34% year-over-year increase [1][2][3][4][5][6]. This surge is driven by a confluence of factors, including the rapid adoption of AI-assisted development tools, the expanding attack surface of non-human identities, and systemic issues in secrets management lifecycle.
The problem isn't just the initial leak; it's the persistence. A disturbing finding indicates that 64% of secrets confirmed valid in 2022 were still valid when retested in January 2026 [3][7]. This longevity transforms a momentary lapse into a long-term vulnerability. Furthermore, the attack surface has expanded dramatically beyond traditional code repositories. Approximately 28% of secrets incidents originate entirely outside of code [2]. This includes environments like collaboration tools, container images, and, critically, developer endpoints.
AI coding assistants, while boosting productivity, also introduce significant risks. AI-assisted development has led to credentials being leaked roughly twice as fast as by developers who don't use these tools [1]. The exposure isn't limited to code generation; AI agents can inadvertently access and exfiltrate sensitive data through their caches and telemetry [8].
Non-human identities (NHIs) – such as service accounts, API keys, and managed identities – are another rapidly growing vector. A significant percentage of organizations have NHIs with high privileges that are exposed to the internet and harbor vulnerabilities [9]. These identities often lack the oversight and lifecycle management applied to human accounts, making them attractive targets. The CISA leak of AWS GovCloud admin credentials exemplifies the potential impact of compromised high-privilege identities [4][10][5].
Understanding the "blast radius" of a compromise is a persistent challenge [1]. Without pre-incident inventory and understanding of credential sprawl, determining the full impact of a compromised developer machine or a leaked API key is extremely difficult. The developer endpoint, or laptop, has become the new perimeter, housing a wealth of credentials often missed by traditional network and identity controls [11].
Core Mechanics of Secrets Exposure
The fundamental mechanisms by which secrets are exposed are surprisingly consistent, though the context and scale continue to evolve.
Hardcoding Secrets
The most straightforward and common method of exposure is hardcoding secrets directly into source code, configuration files, or environment variables. This can occur accidentally during development or due to a lack of understanding about secure credential handling.
- API keys, passwords, and tokens embedded directly in application code.
- Sensitive data (environment variables, API keys, passwords) exposed via misconfigured Spring Boot Actuator endpoints, such as heap dumps or gateway configurations [12].
- Plaintext passwords in API responses or JavaScript code.
- Hardcoded symmetric keys for application encryption.
- Plaintext secrets found in shell history and environment files on developer machines.
- Hardcoded secrets in Model Context Protocol (MCP) configuration files, with millions of such secrets identified [S4, S26].
Exposed Repositories and Source Code Disclosure
Publicly accessible code repositories are a prime target. Vulnerabilities in repository management or accidental exposure can lead to significant data breaches.
- Exposed
.gitdirectories allow for source code reconstruction and the extraction of sensitive information [13]. Tools likegit-dumpercan automate this process. - Using public repositories to store sensitive data and credentials is a direct invitation for compromise.
- Compromised CI/CD runners can contain secrets within their memory or configuration.
- Compromised CI/CD tokens, such as
GITHUB_TOKENorNPM_TOKEN, grant attackers elevated privileges within the pipeline. - Exposed PyPI tokens can lead to package compromises and further supply chain attacks.
Supply Chain Attacks
The software supply chain, from package managers to CI/CD pipelines, is a critical attack vector. Malicious actors exploit trust relationships to inject secrets-exfiltrating code.
- Compromised GitHub Actions or packages can be used to steal secrets embedded within the build process.
- Malicious npm package releases have been used to steal wallet keys and other sensitive data [14].
- The
elementary-dataPyPI package was compromised to steal cloud credentials from data engineers, leveraging GitHub Actions exploits and.pthfile execution [15]. - The
lightningPyPI package was compromised with a Bun-based credential stealer and involved in repo poisoning via GitHub GraphQL [16]. - TanStack npm packages were compromised through chained vulnerabilities in their CI pipeline, leading to valid SLSA provenance, obscuring the malicious intent [17].
- Red Hat npm packages were compromised by the Miasma variant of the Mini Shai-Hulud worm, stealing credentials via a compromised GitHub account and abused OIDC [18][19].
- SAP npm packages have been targeted by Mini Shai-Hulud variants, stealing credentials and propagating to GitHub [20][21][22][23].
- Compromised vendor integrations can lead to customer data exposure, as seen in the Klue incident via OAuth tokens [24].
AI-Assisted Development Risks
The integration of AI into the development workflow introduces novel exposure vectors.
- Credential exfiltration via AI coding agent caches and telemetry.
- AI coding agents may inadvertently leak credentials by auto-loading
.envfiles or accessing local secrets without explicit user consent [25]. - Prompt injection attacks against LLMs can be used to extract sensitive information.
- AI-service secrets are increasing at an alarming rate [3][7].
- The Hugging Face breach involved a rogue OpenAI agent accessing a secret object containing 136 keys [26][27].
Developer Endpoint Security
Developer workstations are repositories of vast amounts of sensitive information.
- A single laptop can accumulate dozens of long-lived credentials across numerous locations [8].
- Agentic credentials, often associated with AI agents, account for a significant portion of secrets found on developer endpoints [8].
- Compromised developer machines can yield a median of over 10 valid credentials [1].
- Plaintext secrets in shell history and environment files are common.
- Exploiting Windows DPAPI password history (
CREDHIST) allows for offline credential recovery.
Server-Side Request Forgery (SSRF) and Other Network-Based Exfiltration
Network-level vulnerabilities can be exploited to access and exfiltrate secrets.
- Server-Side Request Forgery (SSRF) can be used for credential exfiltration, especially when targeting cloud metadata services.
- Exploiting HTTP 303 redirects can facilitate SSRF for credential exfiltration.
Misconfigurations and Exposed Services
Misconfigurations in cloud environments or exposure of debugging interfaces can lead to unintended data leakage.
- Misconfigured or exposed debug pages (e.g.,
phpinfo) can reveal sensitive system information. - Publicly exposing databases without proper authentication or encryption is a common pitfall.
- Misconfigured cloud databases can lead to unauthorized access.
Notable Techniques and Attack Patterns
Beyond the core mechanics, specific techniques and observed attack patterns highlight the evolving threat landscape.
Credential Reuse and Sprawl
The practice of reusing credentials across different systems and cloud providers significantly amplifies the impact of a single leak. A compromised credential for one service can become a pivot point for accessing others [1][8]. This "credential sprawl" is a major contributor to the difficulty in assessing blast radius.
Automated Discovery and Exfiltration Tools
Attackers leverage a range of tools to automate the discovery and exfiltration of secrets.
- Tools like
dirsearchcan be used for directory brute-forcing to find exposed endpoints or files containing secrets. git-dumperis used to download Git repositories, facilitating the exploitation of exposed.gitdirectories.- Burp Suite acts as a versatile web proxy and testing tool, invaluable for intercepting and analyzing traffic for secrets.
- TruffleHog is a popular open-source secret scanning tool that can identify secrets in various sources, including Git repositories, S3 buckets, and Docker images [28][29][30].
- Boto3, the AWS SDK for Python, can be used by attackers to programmatically interact with AWS services and exfiltrate credentials from compromised environments.
- Interactsh is used for out-of-band interaction collection, enabling the detection of exfiltration attempts.
Exploiting CI/CD Pipelines
CI/CD pipelines are rich environments for secrets. Attackers target them through various means:
- Compromised GitHub Actions workflows, particularly those involving
pull_request_targetor relying on improperly secured OIDC tokens. - Preinstall and postinstall scripts in package managers (npm, PyPI) are used to execute malware for credential harvesting.
- Cache poisoning in CI environments can lead to malicious artifacts being used in builds.
- YAML anchor misconfigurations in GitHub Actions can be exploited.
- Compromised CI/CD tokens, like
GITHUB_TOKEN, grant significant access. - The
nxnpm package compromise led to a stolen GitHub token and OIDC abuse, granting 72 hours of AWS admin access [31].
AI Agent Specific Attacks
The growing use of AI coding assistants presents unique challenges:
- Credential exfiltration via AI coding agent caches and telemetry is a direct consequence of their operation [8].
- Prompt injection attacks can trick LLMs into revealing sensitive data or executing unintended actions.
- AI coding assistants like Claude Code have been observed storing sensitive API keys in local configuration files (
.claude/settings.local.json), which can then be leaked through package registries [32][25]. - Tools like
OneCLIare being developed to provide credential gateways for AI agents, addressing this specific risk.
Leveraging Browser Data
Browser credential storage, while convenient, is a significant target.
- Tools like Lazagne, SharpChrome, DonPAPI, and dploot are designed to extract credentials stored by Chromium-based browsers.
- This extraction often involves interacting with browser data files (e.g.,
Local State,Login Data) and leveraging Windows DPAPI for decryption [33].
Obfuscation and Concealment Techniques
Attackers employ various methods to hide malicious payloads and exfiltrated data:
- Obfuscated credential harvesting payloads.
- Exfiltration to public GitHub repositories, which can appear as legitimate development activity.
- Using "sleeper packages" that remain dormant until triggered.
- Rewriting Git tags for malicious code injection.
- Using the Bun runtime for executing JavaScript payloads.
- Using
.pthfiles for Python import-time execution, allowing code to run automatically when a module is imported [15]. - Disabling GitHub secret scanning features through malicious commits or repository configurations.
Exploiting Vendor Integrations
Third-party integrations are often points of weakness:
- Vulnerable vendor integrations can lead to customer data exposure via compromised secrets, such as OAuth tokens [24].
Detection and Prevention Strategies
A multi-layered approach is essential for detecting and preventing secrets exposure. This involves shifting security left in the development lifecycle, continuous monitoring, and robust incident response.
Shift-Left Security and Developer Hygiene
The most effective strategy is to prevent secrets from being exposed in the first place.
- Developer Education: Training developers on secure coding practices, the risks of hardcoding secrets, and the proper use of secrets management tools is paramount.
- Pre-commit Hooks: Implementing pre-commit hooks using tools like
ggshield,gitleaks, ordetect-secretscan catch secrets before they are committed to local repositories. - Pre-push Hooks: Similar to pre-commit hooks, these scan code immediately before it's pushed to a remote repository.
- Code Review: Incorporating secrets scanning into the code review process, either manually or through automated tools, provides an additional layer of validation.
- Environment Variable Management: Utilizing secure methods for managing environment variables, avoiding hardcoding them in code or configuration files that are checked into version control.
Automated Scanning and Monitoring
Continuous scanning across various stages of the software development lifecycle (SDLC) is critical.
- CI/CD Integration: Integrating secrets scanners (e.g.,
ggshield,TruffleHog,Gitleaks) into CI/CD pipelines can detect secrets introduced during the build process. - Repository Scanning: Regularly scanning both public and private repositories for leaked secrets. GitHub's built-in Secret Scanning is a vital tool [34][35].
- Container Image Scanning: Scanning Docker images and other container artifacts for embedded secrets. Tools like
TruffleHogcan scan S3 buckets and Docker images [36][37]. - Cloud Configuration Scanning: Using Cloud Security Posture Management (CSPM) tools to identify misconfigurations that might lead to secrets exposure.
- Collaboration Tool Scanning: Monitoring collaboration tools like Slack, Jira, and Confluence for accidental secret leaks [38].
- Developer Endpoint Scanning: Regularly scanning developer workstations for cached or stored secrets. GitGuardian offers specific tools for this [39].
Secrets Management Lifecycle
A robust secrets management strategy is crucial for the entire lifecycle of a secret.
- Centralized Secrets Management: Employing dedicated secrets management solutions like HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, or Google Secret Manager.
- Dynamic Secrets: Generating secrets on demand for specific tasks, which automatically expire after use, significantly reducing the window of exposure [40].
- Automated Rotation: Implementing automated rotation of secrets at regular intervals.
- Least Privilege: Granting secrets only the necessary permissions required for a specific task or service.
- Auditing and Monitoring: Maintaining detailed audit logs of secret access and usage.
- Time to Revoke: Focusing on reducing the time it takes to revoke compromised credentials, addressing operational blockers like unclear ownership and fear of breaking systems [3].
Non-Human Identity (NHI) Governance
Given the prevalence of NHIs, dedicated governance is required.
- Inventory and Ownership: Maintaining a comprehensive inventory of all NHIs, including their purpose, owner, and associated permissions.
- Least Privilege for NHIs: Ensuring NHIs are configured with the minimum necessary privileges.
- Regular Review: Periodically reviewing the permissions and necessity of NHIs.
- Using tools like GitGuardian NHI Governance to help inventory and manage risk associated with NHIs [41].
Incident Response Playbooks
Having a well-defined incident response plan for secrets leaks is vital.
- Rapid Revocation: The ability to quickly revoke compromised credentials is key.
- Impact Assessment: Tools and processes to accurately determine the blast radius of a leaked secret.
- Communication: Clear communication channels for reporting and addressing leaks.
- Post-Incident Analysis: Learning from incidents to improve detection and prevention measures [4].
Credential Verification
Reducing false positives and focusing on actionable alerts is important.
- Tools like TruffleHog perform credential verification to check if detected secrets are actually active and exploitable [29].
Tooling for Secrets Management and Detection
A robust ecosystem of tools exists to support the detection, management, and prevention of secrets exposure.
Secrets Detection and Scanning Tools
These tools are designed to identify secrets within code, configurations, and other artifacts.
- GitGuardian ggshield: A CLI tool for detecting secrets, integrating with pre-commit and pre-push hooks, and supporting AI coding tools [35][39].
- TruffleHog: An open-source tool that scans various sources, including Git repositories, S3 buckets, and Docker images, and can verify credential validity [28][29][30].
- Gitleaks: A fast, open-source secrets scanner that can be used as a pre-commit hook and integrates well with CI/CD pipelines [42][43][44].
- GitHub Secret Scanning: A native feature within GitHub that automatically scans repositories for known secret patterns and can prevent pushes of secrets [34].
- Semgrep: A static analysis tool that can be configured with rules to detect secrets and other vulnerabilities.
- Snyk: Offers secret scanning capabilities as part of its developer security platform.
- BFG Repo-Cleaner: Useful for removing sensitive data from Git repository history, though requires careful application [43].
- Detect-secrets (Yelp): A secret scanner that maintains a baseline of known secrets.
- Force Push Scanner: Specifically designed to scan orphaned commits for hidden leakages [45].
Secrets Management Platforms
These tools provide centralized storage, access control, and lifecycle management for secrets.
- HashiCorp Vault: A comprehensive platform for secrets management, encryption as a service, and privileged access management. It supports dynamic secrets and integrates with Kubernetes via Vault Agent Injector and Vault Secrets Operator [46][47][48][49][40].
- AWS Secrets Manager: A managed service for securely storing, managing, and rotating secrets.
- Azure Key Vault: Microsoft's cloud-based solution for managing cryptographic keys, secrets, and certificates.
- Google Secret Manager: Google Cloud's service for storing and managing API keys, passwords, certificates, and other sensitive data.
- CyberArk Conjur Secrets Manager: Offers centralized secrets vaulting with RBAC and audit logging.
- Doppler: A secrets management platform for storing and injecting secrets into applications.
- Infisical: An open-source secrets management platform designed for developers.
- Akeyless: A cloud-native secrets management platform.
Developer Endpoint Security Tools
Specific tools address the unique challenges of secrets on developer workstations.
- GitGuardian Developer Endpoint Protection: Focuses on finding credentials on developer machines, including AI agent caches [39].
- Bramble: A local-first password manager designed for secure credential storage.
- DPAPISnoop: A tool for extracting DPAPI Master Key hashes and
CREDHISTentries for credential recovery. - Lazagne: A tool for harvesting credentials from Chromium-based browsers.
AI Security and Governance Tools
Tools are emerging to address the specific risks introduced by AI.
- Nightfall AI: An AI-native data protection platform that can help discover and protect sensitive data.
- Kirin (Knostic): An AI agent security tool for detecting and responding to secret leakage from AI agents [25].
- Zizmor: A GitHub Actions static analyzer that can help identify security misconfigurations.
Cloud Security Platforms
Comprehensive cloud security solutions often include secrets detection.
- Wiz: A Cloud-Native Application Protection Platform (CNAPP) and Data Security Posture Management (DSPM) solution that detects misconfigurations, secrets, and data exposure across cloud environments [12][50][51].
- Snyk Code: While primarily a SAST tool, it can also identify certain types of secrets in code.
Recent Developments and Trends
The secrets security landscape is dynamic, with new trends and threats emerging regularly.
AI's Escalating Role in Secrets Leakage
AI coding assistants are a double-edged sword. While they accelerate development, they also contribute significantly to secrets sprawl. Developers using AI assistants leak secrets at approximately twice the rate of those who don't [1]. This is attributed to the AI's training data, its tendency to autocomplete based on common (often insecure) patterns, and its direct access to local environment files [25][52]. The increase in AI-service secrets by 81% in 2025 is a stark indicator of this trend [3][7].
The Rise of Non-Human Identities (NHIs)
NHIs are outnumbering human identities, and their mismanagement represents a significant security risk [41][9]. These identities, from service accounts to API keys, often have broad permissions and lack the oversight of human account management. A substantial portion of organizations have high-privilege NHIs exposed to the internet with vulnerabilities [9].
Persistence of Leaked Secrets
The long shelf-life of leaked secrets remains a critical issue. The finding that 64% of secrets identified in 2022 were still valid in 2026 underscores the need for proactive credential revocation and lifecycle management [3][7][38]. This persistence means that even old breaches can continue to pose a threat.
Attack Surface Expansion Beyond Code Repositories
Secrets are no longer confined to code. They are found in Docker images, collaboration tools (Slack, Jira), cloud storage, and developer endpoints [2][38]. This diffusion makes traditional code-centric scanning insufficient. The CISA leak, for example, originated from a public GitHub repository, highlighting the risks of any publicly accessible storage [4][53].
Sophistication of Supply Chain Attacks
Supply chain attacks continue to evolve, leveraging sophisticated techniques. The nx npm package compromise, for instance, led to stolen GitHub tokens and OIDC abuse, granting 72-hour AWS admin access [31]. The "Mini Shai-Hulud" campaign variants are spreading across ecosystems, exhibiting worm-like behavior to steal credentials and propagate further [20][18][19]. The validation of SLSA provenance in some attacks indicates a growing challenge in distinguishing legitimate software from malicious tampering [17].
Exploitation of AI Infrastructure
The infrastructure supporting AI models is also becoming a target. The Hugging Face breach, attributed to a rogue OpenAI agent, demonstrated the potential for sensitive data exposure from AI platforms themselves [26][27]. Exposed DeepSeek databases have leaked chat history and secret keys, highlighting the risks associated with AI service providers [51].
Where to Go Deeper
For those seeking to deepen their understanding and improve their secrets security posture, several resources and areas of focus are recommended.
Continuous Learning and Threat Intelligence
Staying abreast of the latest attack vectors and trends is crucial. Regularly reviewing security research from organizations like GitGuardian, Wiz, Snyk, and Aikido provides valuable insights into emerging threats and vulnerabilities. GitHub's blog also offers regular updates on security findings.
OWASP Cheat Sheets
The OWASP Cheat Sheet Series offers practical guidance on a wide range of security topics. The "Secrets Management - OWASP Cheat Sheet Series" is an excellent starting point for understanding best practices in centralization, standardization, access control, and automation [40].
Tooling Deep Dives
Understanding the capabilities and limitations of key tooling is essential.
- Investigate tools like TruffleHog and Gitleaks to understand their scanning methodologies, verification capabilities, and integration points [28][42][43][44][30].
- Explore secrets management platforms such as HashiCorp Vault, AWS Secrets Manager, and Azure Key Vault to understand their features for dynamic secrets, automated rotation, and access control.
Focus on Developer Endpoint Security
Given its role as the new perimeter, understanding the unique challenges of securing developer endpoints is critical. Research on this topic from GitGuardian [11][39] provides actionable insights.
Non-Human Identity (NHI) Governance
As NHIs become more prevalent, dedicated resources on their security are essential. Understanding their characteristics and risks is key to effective management [41][9].
Incident Response and Remediation
Developing robust incident response playbooks for secrets leaks is vital. Resources that detail post-compromise analysis and remediation techniques, such as those covering Git history rewriting and prompt revocation strategies, are invaluable [3][4][43].
Exploring Specific Attack Vectors
Deep dives into specific attack patterns are highly informative:
- Research on supply chain attacks provides a granular view of how malicious code is injected into software dependencies [15][20][17][18].
- Understanding SSRF vulnerabilities and their use in credential exfiltration is important for network security practitioners [12][50].
- Investigating browser credential storage mechanisms and the tools used to exploit them offers insights into endpoint security [33].
The continuous evolution of threats means that ongoing learning and adaptation are not optional but a necessity for maintaining a strong application security posture.