appsec.fyi

Secrets — A Practical Guide

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

Secrets: A Practical Guide

Curated and synthesized by . Last updated 2026-09-01. Synthesized from 232 of 232 curated resources. Browse all 232 Secrets resources →

Problem Framing

Secrets, defined as sensitive information like API keys, passwords, tokens, and certificates, are the keys to the kingdom for application security. Their pervasive nature within development workflows and cloud infrastructure makes them a perennial target for attackers. The landscape of secret management is rapidly evolving, driven by the increasing complexity of cloud-native architectures, the widespread adoption of CI/CD pipelines, and, most recently, the explosive growth of AI and machine learning within development processes.

Traditional security approaches, often focused on perimeter defense and static code analysis, are increasingly insufficient. Secrets sprawl across code repositories, developer workstations, collaboration tools, CI/CD pipelines, and cloud services, creating a vast attack surface. A significant percentage of incidents now originate entirely outside traditional code repositories, in platforms like Slack, Jira, and Confluence [1]. Furthermore, compromised secrets remain valid for extended periods, with a staggering 64% of secrets leaked in 2022 still unrevoked in 2026 [1][2][3][4][5][6][7]. This persistence, combined with the speed at which attackers can discover and abuse credentials, creates a critical window of vulnerability.

The rise of AI coding assistants and AI agents introduces a new dimension of risk. These tools, while boosting developer productivity, often ingest and process sensitive information, inadvertently exposing secrets through their training data, operational outputs, or by using borrowed human/workload credentials, leading to governance blind spots [2][8]. The sheer volume of secrets found in public repositories continues to climb, with millions of new hardcoded secrets discovered annually [9][5][6][7][10]. AI-service credential leaks alone have seen an 81% year-over-year increase [11][12][5][6][7][10], underscoring the urgent need for specialized strategies to manage secrets in this new paradigm.

The impact of compromised secrets extends beyond unauthorized access. It can lead to data breaches, financial loss, reputational damage, and severe operational disruption. Understanding the evolving threat vectors and implementing robust, automated controls is paramount for any organization serious about application security.

Core Mechanics of Secret Exposure

The lifecycle of a secret from creation to compromise is multi-faceted, involving numerous points where exposure can occur. At a fundamental level, secrets are exposed through direct leakage, misconfiguration, or exploitation of vulnerabilities.

Direct Leakage

The most common method of secret exposure is direct leakage, often through human error or oversight. This includes:

Misconfiguration and Vulnerabilities

Secrets can also be compromised through exploitable vulnerabilities and misconfigurations:

Orchestrated Abuse

Attackers often orchestrate credential abuse across multiple locations to achieve their objectives. Once a foothold is gained, they may use compromised credentials to access other systems, escalate privileges, or move laterally. AI agents can significantly shrink the time between credential discovery and abuse to near-zero [11][20][2][4], making detection and response even more challenging.

Notable Techniques

Attackers employ a sophisticated and evolving set of techniques to discover and exploit secrets. Understanding these methods is crucial for building effective defenses.

Hardcoded Credentials in Code and Configuration

This remains the most prevalent method of secret exposure. Developers often hardcode API keys, database passwords, and other sensitive tokens directly within source code or configuration files (.env, JSON, YAML) for ease of use during development. These secrets are then inadvertently committed to version control systems and deployed into production environments. The sheer volume of such leaks is staggering, with millions of new instances appearing on public GitHub annually [9][5][6][7][10]. Even seemingly innocuous configuration files, like those related to Model Context Protocol (MCP) for AI agents, can reveal sensitive information [11][17][3][24].

Exposed API Keys in Public Repositories

Beyond explicit hardcoding, API keys and other credentials can be leaked through various means within public repositories. This includes accidental commits, secrets present in generated files, or even in plain text within issue comments and pull request discussions [25]. The persistence of these leaks is a major concern, as valid secrets can remain discoverable for years [1][14][2][3][4][5][6][7]. GitGuardian's analysis found 23.8 million new secrets on public GitHub repos in 2024, a 25% year-over-year increase [26][27][28].

Credential Harvesting from Developer Machines

Developer endpoints are a goldmine for attackers. Secrets are frequently found in local environment files (.env), IDE configurations, browser history (DPAPI protected data, Chrome/Edge stores), and even temporary files or logs [15][16]. Over 40% of high/critical secrets on dev laptops can surface in AI tool directories or log files [29]. Tools like TruffleHog can scan these local environments, and specialized tools exist to extract browser-stored credentials [30][9].

CI/CD Pipeline Credential Leakage

CI/CD pipelines are rich targets due to their access to build, test, and deployment secrets. Leaks can occur via logs, artifacts, memory dumps, or by compromising the pipeline execution environment itself. For instance, 73,000 tokens/credentials have been exposed through Travis CI build logs [17]. The LiteLLM supply chain attack is a prime example, potentially exposing 2,500 organizations and 434,000 CI/CD pipelines [17][12]. Attackers can exploit vulnerabilities in CI/CD actions or workflows, such as the pull_request_target vulnerability, to gain access to secrets [31][32].

AI Agent Credential Misuse and Token Jacking

AI agents, including coding assistants and autonomous AI systems, present new vectors for secret exposure. Many agents utilize "borrowed" human or workload credentials, creating governance blind spots and increasing the attack surface [2][8]. Attackers can exploit AI agents to harvest credentials they have access to, or through "token jacking" where AI resources are abused for malicious purposes. AI service credential leaks have surged significantly, indicating a growing trend [11][12][5][6][7][10]. Hardcoded placeholders in AI agent skills are another vulnerability [33].

Supply Chain Attacks via Malicious Packages

The compromise of software supply chains is a major concern. Malicious code embedded in popular packages on registries like npm or PyPI can exfiltrate secrets during installation or runtime. The ChainDrop worm, affecting hundreds of millions of downloads per month, and the 'anthropickit' PyPI package are notable examples [20][21][34]. Attackers may disguise malicious code as telemetry or use techniques like embedding obfuscated payloads within build scripts (e.g., build.rs in Rust) [35].

Information Disclosure via Debug Pages and Backup Files

Debug pages, error logs, and backup files, especially when left accessible in production environments, can inadvertently reveal sensitive information, including secrets. For instance, Spring Boot Actuator heapdump endpoints can expose sensitive data if not properly secured [18].

Arbitrary File Read Vulnerabilities

Vulnerabilities that allow attackers to read arbitrary files on a server can be leveraged to extract secrets from configuration files, source code, or other sensitive locations. CVE-2026-66066 in Ruby on Rails is an example of a vulnerability chain that can lead to Remote Code Execution via file reads [19][4].

Orchestrated Credential Abuse

Attackers increasingly orchestrate the abuse of compromised credentials across multiple platforms and services. Once an initial secret is obtained, it can be used to gain access to other systems, pivot within networks, and exfiltrate data. AI agents can accelerate this process, reducing the window between discovery and abuse to near-zero [11][20][2][4]. This requires a holistic view of identity and access across the entire infrastructure.

Identity Phishing Through Trusted Channels

Attackers are leveraging trusted communication channels to conduct identity phishing and credential theft. This involves impersonating legitimate entities to trick users into divulging sensitive information, blurring the lines between genuine interactions and malicious ones [36].

Weak Session Secrets

Insufficiently strong or predictable session secrets can allow attackers to hijack user sessions, leading to unauthorized access and data breaches. Proper management and rotation of session secrets are critical.

Malicious Hooks in Development Tools

Compromised IDEs, editors, or their extensions can act as delivery mechanisms for malware that harvests secrets directly from the developer's environment. This includes malicious VS Code extensions or even compromised build tools [15][20].

Excessive Permissions for Service Accounts/AI Agents

Non-human identities (NHIs), including service accounts and AI agents, are often granted overly broad permissions, creating significant security risks. A substantial percentage of organizations have highly privileged non-human identities that are internet-exposed [37][38]. This can turn a single compromised NHI into a gateway for extensive damage.

Improper Tenant Isolation in Databases

In multi-tenant database environments, inadequate tenant isolation can lead to data leakage between tenants. This risk is amplified if secrets or sensitive customer data are not properly secured or segregated.

HDF5 External Storage for File Reads

Specific file formats like HDF5 can be leveraged for external storage, and vulnerabilities in their handling can lead to unauthorized file reads, potentially exposing secrets embedded within the data or accessible via path traversal within the HDF5 structure.

Detection & Prevention

Effectively managing secrets requires a multi-layered strategy encompassing detection, prevention, and remediation across the entire software development lifecycle (SDLC) and operational environments.

Proactive Scanning and Monitoring

Secure Credential Management Practices

Secure Development and Deployment

Incident Response and Remediation

Tooling

A robust set of tools is available to assist practitioners in detecting, preventing, and managing secrets across the software development lifecycle.

Secrets Scanning and Detection

Secrets Management Platforms

CI/CD and Developer Workflow Security

AI Security Tooling

History Rewriting Tools

Recent Developments

The landscape of secrets management is in constant flux, with recent developments largely driven by the rapid evolution of AI and the increasing sophistication of attack vectors.

AI-Driven Secrets Sprawl and Exposure

The adoption of AI coding assistants and agents has significantly contributed to secrets sprawl. These tools often ingest sensitive data from developer environments or training sets, leading to new exposure channels. GitGuardian reports an 81% surge in AI-service credential leaks year-over-year [33]. Many AI agents use borrowed human/workload credentials, creating governance blind spots [2][8]. There's a growing need for localized guardrails to manage secrets security within the context of AI-assisted development [28]. Research indicates that AI-assisted commits leak secrets at roughly double the baseline rate compared to traditional commits [56][57][58].

Escalation of Supply Chain Attacks

Supply chain attacks continue to be a major threat, with new variants and methods emerging regularly. The Shai-Hulud worm has evolved, targeting more diverse package ecosystems and employing stealthier exfiltration techniques [59][60]. Compromises of CI/CD actions and build tools are becoming more common, allowing attackers to inject malicious code and steal secrets directly from pipelines [22][61]. The TanStack npm package compromise demonstrated how attackers could create malicious packages with valid SLSA provenance, making detection harder [32].

Developer Endpoint as the New Perimeter

The traditional network perimeter has dissolved, with the developer endpoint emerging as the new edge of the security landscape [15]. Secrets stored on developer laptops represent a massive attack surface. Tools are emerging to specifically address this, focusing on scanning local environments, browser data, and IDE caches [16][29]. The complexity of answering "What was on this machine?" after a compromise highlights the need for pre-incident credential inventory [9].

GitHub's Role and Capabilities

GitHub has been actively enhancing its secret scanning capabilities. In 2024, GitHub reported detecting 39 million secrets leaked across its platform, with push protection aiming to prevent accidental exposure [62]. They also offer a secret risk assessment tool to help organizations understand their exposure [63]. However, a significant number of secrets still manage to bypass these protections [64].

AI Agent Security Posture Management

The rapid deployment of AI agents necessitates specific security posture management tools. Solutions are being developed to inventory AI components, assess their security risks, and manage their access credentials [55][65]. Understanding how AI agents handle secrets, including their training data and operational context, is becoming critical [43].

Validation of Leaked Secrets

The focus is shifting beyond mere detection of secret patterns to verifying if detected secrets are actually active. Tools that can validate credentials reduce the noise and allow security teams to prioritize remediation efforts more effectively [30][40]. This is particularly important given the sheer volume of leaked secrets, many of which may be stale but still detectable by basic pattern matching.

Persistence of Leaked Secrets

The problem of leaked secrets remaining valid for extended periods persists. 64% of secrets leaked in 2022 were still valid in 2026, emphasizing the critical need for automated rotation and expiry policies rather than relying on manual cleanup [66].

Where to Go Deeper

To gain a more profound understanding of secrets management and its associated security challenges, practitioners should consult the following resources:

Key Research and Analysis Platforms

Tool-Specific Deep Dives and Benchmarks

Developer Endpoint and AI Security

Broader Application Security Concepts

Sources cited in this guide

  1. Why Secrets Slip Through Every Layer of Your Security Stack — blog.gitguardian.com
  2. Your AI Agents Are Using Your Credentials — blog.gitguardian.com
  3. Mini Shai-Hulud's Latest Wave: 280 New Places It Hunts for Your Secrets — blog.gitguardian.com
  4. An AI Agent Breached Hugging Face. The Attack Playbook Was Older Than the Attacker — blog.gitguardian.com
  5. How to Reduce Time to Revoke for Exposed Credentials — blog.gitguardian.com
  6. How to Measure Time to Revoke for Exposed Credentials — blog.gitguardian.com
  7. How to Measure Time to Revoke for Exposed Credentials — blog.gitguardian.com
  8. Show HN: OneCLI – OSS credential gateway that keeps secrets out of AI agents — github.com
  9. What Was on This Machine? Answering the Blast Radius Question After a Laptop Compromise — blog.gitguardian.com
  10. How to Measure Time to Revoke for Exposed Credentials — blog.gitguardian.com
  11. AI Agent Threat Response: Why Pre-Runtime Controls Matter More Than Runtime Detection — blog.gitguardian.com
  12. Inside the LiteLLM hack: 153GB, 433,909 Files, 2,488 Organizations — blog.gitguardian.com
  13. Closing the Blind Spot: Securing Personal Repositories in the Software Supply Chain — wiz.io
  14. Credential Exposure and the Security Stack Gap — blog.gitguardian.com
  15. The Perimeter Moved to the Laptop: From Network, to Identity, to the Developer Endpoint — blog.gitguardian.com
  16. Every Laptop Is a Credential Store: Where Secrets Hide — blog.gitguardian.com
  17. CI/CD Credential Exposure: What Attackers Steal From Pipelines and What to Rotate — cloudsek.com
  18. The HTTP 303 SSRF Hack : From Python HTTP Client Defaults to AWS Credential Exfiltration. — infosecwriteups.com
  19. Full Rails RCE technical writeup... KindaRails2Shell: How a MATLAB file reads your secrets and pops a shell on Ruby on Rails | Ethiack — ethiack.com
  20. Machine-Speed Credential Abuse: What the ChainDrop npm Worm Changes — blog.gitguardian.com
  21. ChainDrop: Inside a Self-Propagating npm Worm — unit42.paloaltonetworks.com
  22. Compromised GitHub action codfish/semantic-release-action steals CI/CD secrets — aikido.dev
  23. Harvesting SSH Credentials: Insights from My Honeypot Network — uphillsecurity.com
  24. Why SAST and DAST Aren't Enough for Secrets Security — blog.gitguardian.com
  25. GitHub Comments Leak Live API Keys — trufflesecurity.com
  26. Top 16 Secrets Management Tools and Platforms for 2026 (Compared) — blog.gitguardian.com
  27. Secrets leaks increase and expand beyond the codebase — reversinglabs.com
  28. Local Guardrails for Secrets Security in the Age of AI Coding Assistants — blog.gitguardian.com
  29. Credential Harvesting Explained: How Attackers Collect Secrets From Developer Machines — blog.gitguardian.com
  30. TruffleHog: Deep Dive on Secret Management (Jit) — jit.io
  31. Code to Cloud Attacks: From Github PAT to Cloud Control Plane — wiz.io
  32. TanStack Npm Packages Compromised Inside The Mini Shai Hulud Supply Chain Attack — snyk.io
  33. AI Is Fueling Secrets Sprawl: GitGuardian Reports 81% Surge of AI-Service Leaks — blog.gitguardian.com
  34. Anthropic's Fever Dream: Claude's package that stole real keys — aikido.dev
  35. Compromised Rust crate onering performs code exfiltration — aikido.dev
  36. Identity Abuse Through Trusted Communication Channels — unit42.paloaltonetworks.com
  37. Identity Infrastructure: Why Credentials Are the Layer Directories Don't Secure — blog.gitguardian.com
  38. Top 10 Non-Human Identity Security Tools and Platforms for 2026 — blog.gitguardian.com
  39. Why identity-local signals and topology signals are two layers of the same blast radius — blog.gitguardian.com
  40. Gitleaks vs TruffleHog 2026 Benchmarks (AppSec Santa) — appsecsanta.com
  41. 10,000+ Docker Hub Images Leaking Credentials — bleepingcomputer.com
  42. Product showcase: Stop secrets from leaking through AI coding tools with GitGuardian — helpnetsecurity.com
  43. The Claude Code Security Checklist: What the Source Code Reveals — repello.ai
  44. Hardcoded Secrets in AI-Generated Code: Catch Them Before They Ship — toxsec.com
  45. Non-human identities: What they are and how to secure them (Netwrix) — netwrix.com
  46. Secret Rotation: How It Works — groundcover.com
  47. Secretless GitHub Actions to AWS via OIDC — codecentric.de
  48. Hardening HashiCorp Vault Best Practices — sjramblings.io
  49. AWS Secrets Manager vs HashiCorp Vault [2026] — infisical.com
  50. AWS Secrets Engine | HashiCorp Vault — developer.hashicorp.com
  51. Researcher Unearths Thousands of Leaked Secrets in GitHub's "Oops Commits" — infoq.com
  52. Secret Scanning Tools 2026: Protect Code and Prevent Credential Leaks — blog.gitguardian.com
  53. Google Cloud SIEM Service Account Token Leak — tenable.com
  54. Better generic secrets detection starts with finding non-secrets — aikido.dev
  55. Token Jacking: Cybercriminals Could Be Stealing Your AI Resources — unit42.paloaltonetworks.com
  56. The State of Secrets Sprawl 2026: AI-Service Leaks Surge 81% — blog.gitguardian.com
  57. 29 Million Secrets Leaked: AI Coding Tools Making It Worse — turbogeek.co.uk
  58. The State of Secrets Sprawl 2026: 9 Takeaways for CISOs — thehackernews.com
  59. Zero-day Extensive NPM Package Compromise - Shai Hulud Supply Chain Attack — snyk.io
  60. Supply Chain Campaign Targets SAP npm Packages with Credential-Stealing Malware — wiz.io
  61. KICS GitHub Action Compromised: TeamPCP Strikes Again in Supply Chain Attack — wiz.io
  62. GitHub Found 39M Secret Leaks in 2024 — The GitHub Blog — github.blog
  63. Understanding Your Organization's Exposure to Secret Leaks — GitHub — resources.github.com
  64. GitHub Secret Scanning 2026: New Patterns, Push Protection — buildmvpfast.com
  65. Fix SCA issues at scale in your terminal with Snyk Remediation Agent in the CLI — snyk.io
  66. 23.8 Million Secrets Leaked on GitHub: The Case for Expiring Credentials — zerohost.net
  67. Why 28 Million Credentials Leaked on GitHub in 2025 | Snyk — snyk.io
  68. Lessons Learned from CISAs Recent GitHub Leak — krebsonsecurity.com
  69. How We Got a CISA GitHub Leak Taken Down in Under a Day — blog.gitguardian.com
📚 This guide is synthesized from the full text of resources curated in the Secrets library, and refreshed as new material is added.