What matters in AI.

Subscribe

Learn / AI security

Definition · AI security

Credential exposure

Credential exposure is a security problem where an unauthorised person or system can read a secret that gives access. Examples are a password, an API key or an access token. Anyone who finds the secret can then do work as its owner. In AI systems, agent configuration files, code repositories and training data are frequent locations for it.

Last reviewed

Key points

  • A credential is exposed when an unauthorised person or system can read it. Use of it is a second step that frequently follows.
  • MITRE ATLAS has a technique for it in AI systems, AML.T0083, Credentials from AI Agent Configuration, added in September 2025.
  • GitGuardian counted 28.65 million new hardcoded secrets on public GitHub in 2025. AI service secrets increased 81% in that year.
  • To erase an exposed secret does not make it safe. Revoke or rotate it first, because copies stay in forks, clones and history.

How credential exposure happens

A credential is exposed when it is where an incorrect reader can get it. MITRE ATT&CK technique T1552 names the usual locations: plaintext files, shell history, application stores and private key files.

AI systems add these new locations:

  • Agent configuration. MITRE ATLAS technique AML.T0083 says agents keep API keys, tokens and connection strings in configuration files.
  • Code from a coding agent. GitGuardian found a 3.2% secret leak rate in Claude Code assisted commits, against 1.5% for all public commits in 2025.
  • MCP server settings. GitGuardian found 24,008 unique secrets in MCP related configuration files on public GitHub. 2,117 were valid.
  • Training data. Truffle Security found 11,908 live secrets in the December 2024 Common Crawl archive, a dataset used to train LLMs.
  • Chat and ticket tools. About 28% of the incidents GitGuardian saw started outside code, in Slack, Jira and Confluence.
One secret in one file reaches many readers. Each copy works until the secret is revoked.
One secret in one file reaches many readers. Each copy works until the secret is revoked.

Why credential exposure matters

An exposed key gives the attacker the access of its owner. The system cannot tell the attacker from the owner. CWE-798 says hard-coded credentials “can lead to the exposure of resources or functionality to unintended actors”.

Result Population Date Source
28.65 million new hardcoded secrets, up 34% Public GitHub commits 2025 GitGuardian
AI service secrets up 81%, to 1,275,105 Public GitHub commits 2025 GitGuardian
65% leaked verified secrets Forbes AI 50 companies Nov 2025 Wiz
More than 64% still valid Secrets confirmed valid in 2022, tested Jan 2026 2026 GitGuardian

The last row shows the primary problem. Exposed secrets stay valid for years. A leak from 2022 can open a door in 2026.

In practice

An example in an AI tool. In Claude Code before version 2.0.65, a malicious repository could set ANTHROPIC_BASE_URL to an attacker server. Claude Code then sent API requests before it showed the trust prompt. Those requests could leak the Anthropic API keys of the user (CVE-2026-21852, CVSS 5.3).

An example in an AI company. Wiz found a Hugging Face token in a deleted fork of an AI 50 company. The token gave access to about 1,000 private models.

4 controls that decrease credential exposure

  1. Revoke or rotate first. GitHub says this is the first step for a committed secret. A rewrite of history alone leaves copies in clones and forks.
  2. Stop the secret before the push. GitHub push protection blocks pushes that contain secrets.
  3. Scan the full history. Wiz found secrets in deleted forks, gists and developer repositories that most scanners do not touch.
  4. Give each key fewer permissions. With least privilege, an exposed key opens fewer doors.

What does not work

  • To erase the file or the commit. Copies stay in forks, clones and cached views.
  • Private repositories as a safe location. GitGuardian says internal repositories are about 6 times more likely than public ones to contain hardcoded secrets.
  • To wait for a report. Almost half of the disclosures Wiz sent did not get to the company or got no answer.

Questions and answers

What is the difference between credential exposure and a data leak?

A data leak lets a person read data. Credential exposure lets a person read a key that gives access. The attacker can then get more data or do tasks as the owner. MITRE puts the search for exposed credentials under its Credential Access tactic, AML.TA0013 in ATLAS.

Is it sufficient to remove a leaked API key from the code?

No. GitHub says the first step is to revoke or rotate the secret. A rewrite of history does not remove copies in clones and forks. Wiz found a Hugging Face token in a deleted fork that still gave access to about 1,000 private models.

Why do AI agents make credential exposure worse?

Agents use keys for each tool, and they frequently keep them in configuration files. MITRE ATLAS added AML.T0083 for this in September 2025. GitGuardian found 24,008 unique secrets in MCP related configuration files on public GitHub, 2,117 of them valid.

Sources

  1. Unsecured Credentials, Technique T1552MITRE ATT&CK, 24 Oct 2025
  2. MITRE ATLAS data (ATLAS.yaml)MITRE ATLAS, 13 Oct 2025
  3. CWE-798: Use of Hard-coded CredentialsMITRE CWE
  4. LLM02:2025 Sensitive Information DisclosureOWASP GenAI Security Project
  5. The State of Secrets Sprawl 2026GitGuardian, 17 Mar 2026
  6. Exposure Report: 65% of Leading AI Companies Found with Verified Secret LeaksWiz, 10 Nov 2025
  7. Research finds 12,000 'Live' API Keys and Passwords in DeepSeek's Training DataTruffle Security, 27 Feb 2025
  8. GHSA-jh7p-qr78-84p7: Malicious repo configuration can trigger data leakage via environment configuration used before trust confirmationAnthropic (GitHub security advisory), 20 Jan 2026
  9. Removing sensitive data from a repositoryGitHub Docs
  10. About push protectionGitHub Docs

In the news