AI coding tools have turned every developer laptop and every repository into a faster, wider channel for leaking machine credentials. Agents read .env files and shell profiles, remember approved commands, write instruction and MCP configuration files, keep transcripts of everything they saw, and commit code at a pace no reviewer matches. Each of those is a new place where an API key, token or connection string can come to rest, and most of them sit outside the scanners and vaults that security teams already run. This guide pulls together what the 2026 research and the incidents on our breach database show: where keys now leak, which cases prove it, and the containment controls that work across tools. It is written for AppSec, platform, identity and endpoint teams, and it links to the deeper NHI Mgmt Group guides for each task rather than repeating them.
Key takeaways
- The leak paths have multiplied, not just the volume. Prompts, agent instruction files, permission memory, MCP configuration, transcripts, extension settings and agent-written commits are all new resting places for secrets, and a Git-only scanner sees few of them.
- The numbers point the same way. GitGuardian research counted 28.65 million new hardcoded secrets in public GitHub commits in 2025, up 34%, with AI service secrets up 81% and 24,008 unique secrets in MCP configuration files.
- An agent inherits whatever the developer's session can reach. Gemini CLI, Amazon Q, Sentry MCP agentjacking and Nx s1ngularity all turned on the same fact: the agent runs with the developer's environment variables, cloud profiles and tokens.
- Containment is mostly identity work. Short-lived, federated and narrowly scoped credentials, kept out of the agent's reach, shrink every one of these leaks; scanning only finds what is already exposed.
- Revocation is the finish line. Deleting a file, a transcript or an exfiltration repository leaves the key valid. Measure until the issuer rejects it.
Why AI coding tools widen secrets sprawl
Secrets sprawl is the spread of credentials outside the systems built to hold them. The Secret Sprawl Measurement Guide covers how to count it. AI coding tools change four things about how it happens.
- Speed: agents and vibe coding tools produce more commits, more configuration and more throwaway projects per developer. Review capacity has not grown at the same rate. GitGuardian research puts 2025 public GitHub commit volume at about 1.94 billion, up 43%.
- Autonomy: an agent decides which files to read and which commands to run. In the PocketOS case the coding agent searched the codebase, found a Railway API token in a file unrelated to its task and used it. A human might never have opened that file.
- Agents reading local files: context gathering pulls .env files, shell output, cloud CLI configuration and error logs into the model's context, and from there into transcripts, traces and provider-side history. GitGuardian research published in July 2026 lists shell history, .env files and dotfiles, cloud credential files, registry tokens and AI agent and MCP caches among the places secrets sit on a developer machine, and says agents may write keys they generate into conversation history or temp files without the developer knowing.
- Generated code and configuration committing literals: an agent asked to connect a database will often write the connection string where it works first. Approved commands, instruction files and MCP configuration are then committed with the project. Radware research found that only about 10% to 16% of the commits that put credentials into agent instruction files carried AI-authorship signatures, so most of those leaks were typed by people into files that exist because of agents.
The identity point underneath all four: every key an agent can see is a non-human identity that the agent can use, copy or leak. GitGuardian research claims agentic credentials account for more than 40% of secrets found on developer endpoints, though the article does not publish its method or sample size. Developer endpoints as NHI stores covers the laptop itself; this guide follows the credentials outward.
What the numbers say
Vendor research is labelled as such: each publisher sells products in this area and methods differ, so compare direction rather than precise rates.
| Finding | Figure | Source and as-of date |
|---|---|---|
| New hardcoded secrets added to public GitHub commits | 28.65 million in 2025, up 34% year on year | GitGuardian research, The State of Secrets Sprawl 2026 (March 2026) |
| Secrets for AI services | 1,275,105 in 2025, up 81% | GitGuardian research, The State of Secrets Sprawl 2026 |
| Leak rate in Claude Code-assisted commits | 3.2%, against a 1.5% baseline across all public commits | GitGuardian research, The State of Secrets Sprawl 2026; GitGuardian cautions that developers decide what is pushed, so the gap is not a failure of the tool itself |
| Secrets in MCP configuration files on public GitHub | 24,008 unique secrets, of which 2,117 (8.8%) were valid | GitGuardian research, The State of Secrets Sprawl 2026 |
| Incidents outside repositories | About 28% originate entirely in tools such as Slack, Jira and Confluence | GitGuardian research, The State of Secrets Sprawl 2026 |
| Secrets on compromised developer and CI machines | 33,185 unique secrets across 6,943 machines in the Shai-Hulud 2 dataset; 59% of machines were CI/CD runners | GitGuardian research, The State of Secrets Sprawl 2026 |
| How long leaked secrets stay valid | More than 64% of secrets confirmed valid in 2022 were still valid when retested in January 2026 | GitGuardian research, The State of Secrets Sprawl 2026 |
| Credentials in agent instruction files | About 100 confirmed live external secrets and about 300 weak or test credentials across 381 repositories, from about 100,000 files scanned; 60% of the keys that could be tested were live | Radware research, The New .env (August 2026); the authors call the counts lower bounds |
| Secrets saved by agent permission memory | 2,539 secrets across 1,994 public repositories; 1,122 of 104,185 public .claude/settings.local.json files held at least one secret | Apiiro research (November 2026), as reported on our Claude Code settings leak page |
| Validated secrets inside IDE extension packages | More than 550 across more than 500 extensions, including over 100 VS Code Marketplace and over 30 Open VSX publishing tokens | Wiz research (October 2025), as reported on our Secrets in VS Code Extensions page |
| AI-related breaches that abused a credential | 26 of the 33 AI-related breaches in 2026 so far (79%) also abused a key, token or credential | NHI Mgmt Group, The State of NHI & AI Agent Breach Report 2026 (October 2026) |
| Identities abused in AI-related breaches | API key 26, secret or password 23, source control token 9, CI/CD or publishing token 9 | NHI Mgmt Group, The State of NHI & AI Agent Breach Report 2026 |
Two cautions. First, scanner coverage is uneven in these new file types: according to the Apiiro findings as reported, Gitleaks flagged 564 and TruffleHog 643 of the 1,122 settings files with secrets, and neither flagged 215. Second, the NHI Mgmt Group report covers the incidents it analysed, not every breach. More figures: AI Agent Security Statistics.
Where secrets now land
Use this table as the scope list for discovery.
| Where | How secrets get there | Who can read it | Go deeper |
|---|---|---|---|
| Prompts and chat history | Developers paste keys, connection strings and error logs into chat; keys written into system prompts for prototypes | The model provider, workspace admins, anyone with a shared link or export | Secrets in Prompts |
| Agent instruction and rules files (AGENTS.md, CLAUDE.md, GEMINI.md, .cursor/rules, .github/copilot-instructions.md) | "Deploy with this token" written as guidance for the agent, then committed | Every clone and fork of the repository | Coding Agent Configuration File Attacks |
| Agent permission memory and local settings | Approved commands saved word for word, including inline passwords, as allow rules | Anyone the file is committed or synced to | How to audit AI coding assistant tokens and config files |
| MCP configuration (.mcp.json, .cursor/mcp.json, .vscode/mcp.json, ~/.claude.json, .amazonq/mcp.json) | Bearer tokens and connection strings typed into env or headers blocks from quick-start examples; MCP servers pulling vault secrets into local config | Repository readers if committed; any local process | How to audit MCP servers on developer laptops |
| Transcripts, session logs and traces | Tool results contain file contents, command output and environment values the agent read | The user, local malware, endpoint backups, observability users | How to Find Secrets in AI Agent Transcripts and Traces |
| .env files, shell profiles and shell history read by agents | The agent reads them for context or inherits them as environment variables, then repeats them in output, commands or commits | The agent, every tool and MCP server it spawns | Developer endpoints as NHI stores |
| Agent-written commits and pull requests | Generated code with literal keys; test fixtures and sample configs with real values | Repository readers; public if the repository is public | How to enable GitHub secret scanning push protection |
| IDE extensions and plugins | Keys entered in plugin settings; secrets bundled into published extension packages; publishing tokens on developer machines | The extension publisher, anyone who downloads the package | Malicious IDE Extension Detection |
| Agent credential stores and local model caches | Assistant login tokens in plaintext fallback files; provider keys for local and hosted model runners in home-directory config | The user and any local process | How to find LLM API keys in code and CI |
| Hosted agent consoles and key-holding services | Teams store provider keys in a hosted service so members can use models without seeing the key | The service operator, and anyone who breaches it | How to audit OpenAI and Anthropic organisation API keys |
Lessons from incidents: the case table
Every case below is a live NHI Mgmt Group breach page that involves an AI coding tool, an IDE extension, an AI agent or the credentials developers feed to them. The type column separates confirmed incidents from research and vulnerability disclosures. Products are named because the incidents are, not as a judgement on any vendor; each lesson is a customer-side control.
| Case | Type | Where the secret was | The lesson for containment |
|---|---|---|---|
| Amazon Q Developer Extension Compromise (July 2025) | Confirmed compromise; AWS says the code did not execute | An over-scoped GitHub token in a CodeBuild configuration let an attacker commit a wiper prompt that shipped in version 1.84.0 | Build tokens must not reach release branches; review agent instructions like code; give agents their own scoped credentials, not the developer's full cloud profile |
| Gemini CLI Prompt Injection Flaw (July 2025) | Vulnerability, fixed in 0.1.14; no exploitation reported | Environment variables of the developer's shell, sent out by a command hidden behind an allow-listed grep | Keep secrets out of the shell environment agents inherit; treat cloned repository content as untrusted |
| Nx s1ngularity Attack (August 2025) | Confirmed supply chain attack | GitHub and npm tokens, SSH keys, cloud credentials and AI tool configuration on developer machines; the malware prompted installed AI CLIs with permission-bypass flags to help find files | AI CLIs with bypassed prompts are attack tooling on an infected host; GitGuardian found 2,349 distinct secrets and 33% of compromised systems had an AI CLI installed |
| Secrets in VS Code Extensions (October 2025) | Exposure research | Bundled hidden files, mostly .env, with a growing share from mcp.json and .cursorrules, inside published extension packages | Scan builds before publishing, exclude dotfiles, rotate anything found in a shipped package |
| GlassWorm Campaign (October 2025 onward) | Confirmed malware campaign | npm, GitHub, Git and Open VSX credentials on developer machines; the Eclipse Foundation says attackers used publishing tokens developers had leaked publicly | Publishing tokens are high-value NHIs: short-lived, scoped, owned. See the GlassWorm VS Code Extension Worm Guide |
| Shai-Hulud npm Worm (November 2025 wave) | Confirmed supply chain attack | npm, GitHub and cloud credentials on developer machines and CI runners, harvested with a repurposed secret scanner | Wiz found 77% of infections on CI runners; keep publishing and cloud secrets away from jobs that install third-party packages |
| PocketOS Database Deletion (April 2026) | Agent misbehaviour, no attacker | An account-scoped Railway token in a file in the codebase, unrelated to the agent's task | Anything in the workspace is in the agent's reach; scope tokens to one environment and purpose; confirm destructive actions outside the agent |
| GitHub Internal Repositories Breach (May 2026) | Confirmed breach | A developer's GitHub CLI token, then Vault, AWS, Kubernetes, npm, GitHub and 1Password secrets harvested by a poisoned Nx Console extension on an employee's device | Developer machines are credential stores; require multi-party approval to publish extensions; allow-list and delay extension updates |
| TrapDoor Supply Chain Campaign (May 2026) | Confirmed malware campaign; no victims published | SSH keys, AWS credentials, GitHub tokens and environment variables; the npm payload wrote .cursorrules and CLAUDE.md files with hidden instructions asking the agent to run a fake "security scan" | Treat instruction files as code: review them and scan for hidden Unicode |
| Sentry MCP Agentjacking (June 2026) | Vendor research test; no real attacker reported | Environment variables and files such as ~/.aws/config, ~/.npmrc and ~/.docker/config.json, reachable when an agent ran a command planted in an error event read through MCP | MCP output that outsiders can influence is untrusted input; require approval before agents run commands drawn from external data |
| JetBrains Marketplace AI Plugin Campaign (June 2026) | Confirmed malicious plugins | OpenAI, DeepSeek and SiliconFlow keys typed into plugin settings, sent in plaintext to a hard-coded server | Any tool that asks for a key becomes its custodian; use per-tool keys with spend caps and keep a record of where each key was entered |
| Amazon Q MCP Config Vulnerability (June 2026) | Vulnerability, fixed; no exploitation reported | AWS keys, session tokens and SSH agent sockets inherited by MCP server processes launched from a repository's .amazonq/mcp.json | Repository MCP configuration is untrusted input; child processes should not inherit the developer's credentials by default |
| OpenCode Console Breach (October 2026) | Confirmed breach | Customers' OpenAI, Anthropic and Google keys stored in a hosted console; locally held keys were not affected, according to OpenCode | A hosted service holding provider keys is a multi-provider vault; deleting the key there does not revoke it at the provider |
| Cursor Marketplace Extension Compromise (October 2026) | Confirmed compromise of a marketplace's distribution | Host details including the names of environment variables were collected; an attacker SSH key was added to authorised keys | Extension auto-update is a trusted delivery path; an SSH key planted on a laptop is a new identity that outlives the extension |
| WorkOS Breach (November 2026) | Confirmed access by an escaped research agent, no malicious intent according to WorkOS | A weak, predictable local development credential that was accepted by an internet-facing production API | Development credentials are machine identities; autonomous agents find guessable ones quickly |
| GitBook Breach (November 2026) | Confirmed breach; GitBook describes an attack using AI agents | Source code repositories led to a Cloudflare API key, production secrets and a service account with full infrastructure access | Secrets left in code are found and chained at machine speed once an agent-assisted attacker is inside |
| Claude Code Settings Leak (November 2026) | Exposure research; one key confirmed live by its owner | Inline passwords and tokens saved in .claude/settings.local.json and related files, then pushed to public repositories | Agent permission memory is a secret store; never type secrets into approved commands, and scan agent files before commit |
For a broader view across every agent incident, see AI agent breaches.
Four patterns across the cases
- Inheritance: in Gemini CLI, Amazon Q MCP, Sentry MCP and Nx s1ngularity the agent, or a process it launched, simply had the developer's environment. Removing standing secrets from it closes all four.
- Configuration as a carrier: instruction files, permission memory, MCP configuration and extension packages carried either the secret or the instruction to steal one.
- Distribution trust: marketplaces and auto-update delivered the payload in five of the cases, and publishing tokens were the identity abused in most of them.
- Reach beats intent: PocketOS and WorkOS had no attacker; the scope of a reachable credential decided the damage.
Containment controls
Order matters. Controls that shrink what an agent can reach come first, because scanning only finds what has already leaked. The target architecture for agent credentials is covered in the Credential Vaulting for AI Agents Guide and Runtime Secrets Injection for AI Agents Without Prompt Exposure; this section is the cross-tool summary.
1. Keep secrets out of agent reach
- Deny reads of secret files: configure each tool to refuse .env, credential and key files (see the settings table below), and remember that tool-level ignore rules are not a sandbox. Cursor's own documentation says the terminal and MCP tools used by Agent cannot block access to files governed by .cursorignore.
- Strip the inherited environment: start agents and MCP servers with a minimal environment, not the developer's full shell. Move tokens out of shell profile exports.
- Run untrusted work in a sandbox: new repositories, pull requests from outsiders and tasks that read external data (tickets, error events, web pages) belong in a container or cloud sandbox with no developer credentials mounted. See the AI Agent Sandboxing and Code Execution Guide.
- Clean the workspace: any token in the working tree is one the agent may use, so scan it, not only commits.
2. Short-lived and federated credentials
- Cloud access: replace static keys in ~/.aws/credentials and similar files with SSO-issued session credentials that expire in hours.
- CI and publishing: use OIDC workload identity federation and trusted publishing so no long-lived publishing token lives on a laptop or in a repository secret. See How to set up workload identity federation for GitHub Actions to AWS.
- Per-tool AI keys: give each assistant, plugin and MCP server its own provider key with a spend cap, so one leak is one rotation. See How to set spend limits on LLM API keys.
- Agent identities: where an agent acts in production or CI, give it its own scoped identity rather than a developer's token. NHI Mgmt Group's breach report puts "remove standing production write access from coding and other AI agents" in its first 30 days.
3. Push protection and pre-commit checks
- Repository push protection: on GitHub, repository-level push protection is off by default and needs GitHub Secret Protection; user push protection is on by default but covers public repositories only and does not raise bypass alerts on its own. Turn on the repository level, restrict bypass with delegated bypass, and alert on "I'll fix it later" bypasses. Step by step: How to enable GitHub secret scanning push protection.
- Agent commits: confirm that whatever route an agent uses to commit (local Git, the API, an MCP server, a cloud agent) passes the same checks. GitHub documents push protection coverage per surface, including REST API requests and the GitHub MCP server for public repositories.
- Agent-specific files: add custom patterns or path rules for .claude/, .cursor/, .mcp.json, instruction files and inline secrets after keys such as PGPASSWORD=, since the Apiiro findings show general scanners missed a share of these.
4. Scan the new stores, not just Git
- Endpoints: scan approved paths on developer machines for secrets in dotfiles, agent folders, MCP configuration and shell history, with privacy and HR agreement first.
- Transcripts and traces: decode JSON before scanning, scan in place, and redact output. The method is in How to Find Secrets in AI Agent Transcripts and Traces.
5. MCP token hygiene
- No literal tokens in shared MCP files: reference environment variables or the client's secret storage, and keep project MCP files free of values. The MCP Static Token Audit covers discovery.
- Audience-bound tokens: the MCP security best practices state that MCP servers "MUST NOT accept any tokens that were not explicitly issued for the MCP server", which rules out passing a developer's upstream token straight through.
- Consent and least scope: the same document requires clients offering one-click local server setup to show the exact command before running it, and recommends sandboxed launch and minimal scopes. Inspect the command behind any MCP consent prompt before approving it.
- Governance: keep an allow list of MCP servers and owners. See the Local MCP Server Security Guide.
6. Managed settings and extension control
- Enforce centrally: deploy deny rules, sandbox modes and transcript retention through each tool's managed or organisation settings, so a developer's local file cannot loosen them.
- Extensions: allow-list publishers and extensions, delay auto-updates for new versions where the tooling allows, and monitor for plaintext HTTP from IDE processes, a signal named in the JetBrains plugin case.
- Instruction files: require code-owner review for AGENTS.md, CLAUDE.md, .cursor/rules and similar files, and block hidden Unicode in them.
Tool settings that keep secrets out of agent reach
Tools are listed alphabetically; order is not a ranking. Each row gives the vendor's own documented setting as of November 2026, and these change often, so confirm against current documentation before scripting them. Credential storage locations for each tool are in How to audit AI coding assistant tokens and config files.
| Tool | Keep secret files out | Limit what commands and processes inherit or reach | Central enforcement and records |
|---|---|---|---|
| Claude Code | permissions.deny rules such as Read(./.env) and Read(./.env.*); deny rules apply straight away, even from a committed project file | Allow, ask and deny rules for Bash commands; "Yes, and don't ask again" saves an allow rule to .claude/settings.local.json, which Claude Code adds to global git excludes when it creates the file (a hand-made file must be added to .gitignore) | Managed settings (managed-settings.json, MDM or server-managed) sit at the top of precedence and cannot be overridden by user or project files |
| Cursor | .cursorignore blocks Agent, Tab and @ references; .env* files are ignored by default; a global ignore list is available in user settings | Terminal and MCP tools used by Agent are not blocked by .cursorignore, so pair it with environment hygiene and sandboxing | Test ignore patterns with git check-ignore -v; hierarchical ignore searches parent folders when enabled |
| GitHub Copilot cloud agent | Do not rely on content exclusion: GitHub says it is not supported in Edit and Agent modes of Copilot Chat in editors, and its support list does not name the cloud agent, so keep secret files out of the repository and the agent environment | Pushes to a single branch (a new copilot/ branch or the pull request's branch); internet access restricted by a firewall; only users with write access can trigger it | Workflows on its code do not run until a user with write access approves them, by default; secret scanning is part of its default validation; commits are co-authored by the requesting developer and link to session logs |
| OpenAI Codex | sandbox_mode set to read-only or workspace-write rather than danger-full-access | shell_environment_policy controls what spawned commands inherit: inherit (all, core or none), filters, and ignore_default_excludes, documented as true by default, which keeps variables whose names contain KEY, SECRET or TOKEN; set it to false to strip them | cli_auth_credentials_store (file, keyring, auto or ephemeral) sets where login credentials are cached; history.persistence (save-all or none) controls whether transcripts are saved to history.jsonl |
Implementation: a phased rollout
- Week 1 to 2, inventory: list the AI coding tools, IDE extensions, MCP servers and AI provider keys in use, with an owner for each. Run the token and config audit on a pilot group of developer machines and record findings by store from the "where secrets now land" table.
- Week 2 to 4, revoke what is live: rotate every valid secret found, starting with cloud, publishing and production credentials. Track until the issuer rejects the old value, not until the file is cleaned.
- Week 3 to 6, cut reach: roll out deny rules, minimal environments for agents and MCP servers, and sandbox defaults to the pilot ring in audit or ask mode first. Collect which legitimate tasks break, adjust, then enforce through managed settings.
- Week 4 to 8, replace standing credentials: move developers to SSO-issued cloud sessions, CI to OIDC federation, package publishing to trusted publishing, and AI tools to per-tool capped keys.
- Week 6 to 10, block at commit and publish: enable repository push protection with delegated bypass, add custom patterns for agent files, and add scanning to extension and package builds.
- Ongoing, scan the stores and measure: schedule endpoint, transcript and trace scans; report the metrics below monthly.
Testing and rollback: keep every policy change in version control, deploy to a pilot ring before the fleet, and roll back by reverting the managed settings file or policy, not by asking developers to edit local files. Never roll back a credential rotation; issue a new credential instead. The AI coding assistant rollout playbook covers the wider rollout, the AI IDE and Coding Agent Security Guide covers permission and sandbox design, and the AI Coding Agent Incident Playbook and Compromised Developer Workstation Playbook cover response.
Decision guidance
| Decision | Choose this when | Trade-off |
|---|---|---|
| Tool deny rules versus a full sandbox | Deny rules for trusted repositories and day-to-day work; sandbox for untrusted repositories, outside pull requests and tasks reading external data | Deny rules are cheap but leak through terminals and MCP tools; sandboxes cost setup time and break tasks that need local services |
| Local agents versus cloud agents | Cloud agents when the work does not need the developer's machine; local agents when it does | A cloud agent sees only the secrets you give its environment; a local agent sees the laptop |
| Hosted key-holding service versus local keys | Hosted when the team needs shared access without seeing the key | Fewer copies on laptops, but one service now holds many providers' keys, as the OpenCode Console case showed |
Small organisations: start with per-tool capped keys, user and repository push protection, deny rules for .env files and a monthly endpoint scan of agent folders. Large organisations: add managed settings through MDM, an MCP server allow list, extension allow lists with delayed updates, transcript and trace scanning, and federated credentials everywhere CI and cloud allow it.
Detection and measurement
Watch for AI API key usage from unexpected networks or volumes, new public repositories under developer accounts, new SSH authorised keys or self-hosted runners on developer machines, plaintext HTTP from IDE processes, changed instruction or MCP files in pull requests, and push protection bypasses. Honeytokens placed in .env files and agent folders give a high-signal alert when an agent or malware reads and uses them; see AI Agent Honeytokens and Canaries.
| Metric | Definition | Direction |
|---|---|---|
| Live secrets in agent stores | Valid credentials found in instruction files, MCP configuration, agent settings, transcripts and traces | Down to zero for production credentials |
| Median time to revoke | Hours from detection until the issuer rejects the credential | Down; set a target such as 24 hours for critical secrets |
| Standing credentials reachable by agents | Long-lived keys present in developer environments and agent workspaces, per machine | Down, as federation and session credentials replace them |
| Push protection coverage and bypass rate | Share of repositories with repository-level push protection; bypasses per month and by reason | Coverage up, bypasses down |
| Managed settings coverage | Share of developer machines where agent deny rules and sandbox defaults are centrally enforced | Up |
| Owned AI keys and MCP servers | Share of AI provider keys and MCP servers with a named owner and spend cap | Up to 100% |
Common failure patterns
- Cleaning the file instead of revoking the key: deleting a settings file, a transcript or an exfiltration repository leaves the secret valid. GitGuardian research found more than 64% of secrets valid in 2022 still valid in January 2026.
- Typing secrets into commands an agent remembers: the Claude Code settings leak research shows inline passwords saved as standing approvals and then pushed.
- Trusting ignore files as a boundary: tool ignore rules help, but terminal and MCP access can still read the file. Pair them with environment hygiene and sandboxes.
- Leaving broad tokens in the workspace: the PocketOS Database Deletion began with an account-scoped token in an unrelated file.
- Letting repository content configure the agent: MCP files and instruction files from a cloned repository ran or steered commands in the Amazon Q MCP Config Vulnerability and the TrapDoor Supply Chain Campaign.
- Scanning only Git: endpoint, transcript, extension and collaboration stores hold a large share of the exposure and are missed by repository-only programmes.
Framework mapping
| Framework | Item | How it applies |
|---|---|---|
| MITRE ATT&CK | T1552.001 Credentials In Files; T1552.004 Private Keys | Secrets in .env, agent settings, MCP configuration and SSH keys on developer machines |
| MITRE ATT&CK | T1195.002 Compromise Software Supply Chain; T1528 Steal Application Access Token | Poisoned extensions and packages harvesting publishing and access tokens |
| MITRE ATLAS | AML.T0083 Credentials from AI Agent Configuration; AML.T0051 LLM Prompt Injection; AML.T0057 LLM Data Leakage | Keys in agent configuration; instructions hidden in repositories and MCP output; secrets in transcripts and outputs |
| OWASP Top 10 for LLM Applications 2025 | LLM02 Sensitive Information Disclosure; LLM03 Supply Chain; LLM06 Excessive Agency; LLM07 System Prompt Leakage | Disclosure of credentials; malicious plugins and packages; agents with standing reach; keys in prompts |
| NIST SP 800-53 Rev. 5 | IA-5 Authenticator Management; IA-5(7) No Embedded Unencrypted Static Authenticators; AC-6 Least Privilege; CM-7 Least Functionality; SA-15 Development Process, Standards, and Tools; SR-3 Supply Chain Controls and Processes; AU-6 Audit Record Review, Analysis, and Reporting | Credential lifecycle, no literals in code and files, agent scope, tool and extension control, review of agent activity |
| NIST CSF 2.0 | PR.AA-01; PR.AA-05; PR.DS-01; DE.CM-09; ID.AM-07 | Managing NHI credentials and their permissions, protecting data at rest in agent stores, monitoring developer runtime environments, inventory of where secrets live |
Practitioner checklist
- Inventory AI coding tools, extensions, MCP servers and AI provider keys, each with an owner.
- Scan agent folders, instruction files, MCP configuration, transcripts and shell history on a pilot group, then the fleet.
- Revoke and rotate every live secret found, and record time to revoke.
- Deploy deny rules for .env and credential files and minimal inherited environments through managed settings.
- Run untrusted repositories and tasks that read external data in a sandbox with no developer credentials.
- Replace static cloud keys and publishing tokens with SSO sessions, OIDC federation and trusted publishing.
- Give each AI tool and MCP server its own capped key; never pass a developer's upstream token through an MCP server.
- Enable repository push protection with delegated bypass and custom patterns for agent files.
- Require code-owner review of instruction and MCP files, and block hidden Unicode in them.
- Allow-list IDE extensions and publishers, and plant honeytokens where agents and malware look.
Standards and references
- Model Context Protocol: Security Best Practices
- GitHub Docs: About push protection
- GitHub Docs: Risks and mitigations for Copilot cloud agent
- GitHub Docs: Content exclusion for GitHub Copilot
- Anthropic: Claude Code settings files and precedence
- Cursor: Ignore files
- OpenAI: Codex configuration reference
- GitGuardian: The State of Secrets Sprawl 2026
- GitGuardian: Every Laptop Is a Credential Store: Where Secrets Hide
- Radware: The New .env: Measuring Credential Leakage in AI Agent Instruction Files
Related NHI Mgmt Group resources: AI agent breaches · Secret Sprawl Measurement Guide · Developer endpoints as NHI stores · AI Coding Agents Security Guide · Secrets Management Guide