AI Coding Agent Credential Leaks: Technical Root Causes and Governance Practices

    This article analyzes a large-scale credential exposure caused by AI coding agents, explaining how locally stored permission rules, version control habits, and automatic commits combined to leak thousands of real credentials across public repositories. It covers the technical root causes, exposure data and impact, why local permission files become high-risk assets, and practical governance measures for individuals, teams, and tool platforms, along with a reusable security checklist.

    1. Incident Overview and Risk Classification

    In November 2026, the security community disclosed a large-scale developer credential leak. A mainstream AI coding agent had a design flaw in its local configuration mechanism: the original text of commands authorized by developers during interactive sessions was written into configuration files. Plaintext passwords, API keys, access tokens, and other sensitive information embedded in those files were then committed to code hosting platforms along with project directories. As a result, nearly 2,000 repositories and thousands of real credentials were exposed in publicly visible repositories.

    First, it is important to clarify that this was not a typical “hacker intrusion” or “platform breach.” It was a systemic leak triggered by development tool behavior combined with version control usage habits. What makes it especially dangerous is threefold:

    1. The leak happened “legitimately and voluntarily.” The developer clicked “agree,” the tool recorded it faithfully, and the hosting platform stored it faithfully. No step in the chain violated the permission model, and no alert was triggered.
    2. What leaked was not code, but directly usable credentials. A real database password in a configuration file is far more dangerous than a sample code snippet.
    3. Historical exposure is often larger than current exposure. Once a credential is committed into version history, it can still be recovered from history records, forked repositories, and cached snapshots even if it is deleted later.

    The typical characteristics of this type of incident can be summarized as follows: the process of granting permissions is silently persisted, the persisted result enters version control, and version control assumes by default that “commit means public.” Breaking any one of these three links would prevent the risk from materializing, yet in practice all three conditions are highly likely to hold at the same time.

    2. Technical Root Causes: From One Authorization to Thousands of Keys

    2.1 Layer 1: Turning “Temporary Authorization” into a “Permanent Rule”

    A typical AI coding assistant works by reading project context, generating Shell commands to execute, and requesting user confirmation before actual execution. The user interface usually offers a few options: “Allow once,” “Deny,” and “Allow and don’t ask again.”

    When the user chooses the third option, the tool internally performs a state transition of the authorization status: from “no rule” to “a permanent allow rule exists.” The problem lies in how this rule is persisted:

    1. User selects "Allow and don't ask again"
    2. │
    3. ▼
    4. Authorization rule written to a local config file (e.g., .claude/settings.local.json)
    5. │
    6. ├── Rule entry: allow execution of <original command text> ← Risk point A
    7. ├── Allow list accumulates and keeps appending across sessions ← Risk point B
    8. └── File resides in the project directory and can be committed ← Risk point C

    Risk point A: Using the “original command text” as the rule key. An authorization rule should express “allow this type of behavior, such as executing npm run build,” and its key should be the command semantics or tool name. But when the implementation degrades to “allow this exact string,” the command containing credentials that the developer previously typed for troubleshooting—for example:

    1. # First-time debugging: connection command with a plaintext password
    2. mysql -h db.internal.example -u root -p'Prod#2026!Secret' app_db
    3. # Later interaction: the tool is asked to "allow and don't ask again" for similar commands
    4. export DATABASE_URL="postgres://admin:Prod%232026@db:5432/orders"

    Its original text is then saved in full as the rule content, including the account, host, port, and plaintext password. The authorization action itself is not wrong; the mistake is that the “object being authorized” contains secrets.

    Risk point B: The file accumulates in an append-only manner. In practice, the allow list usually only grows and never shrinks, with no expiration time, no scope limit, and no content redaction. Observations in security research confirm this: the longer developers use “don’t ask again” and the more frequently they interact, the more sensitive information accumulates in the file. This means risk is positively correlated with the duration of tool usage: the more deeply a team uses AI coding capabilities, the larger the exposure surface.

    Risk point C: The file naturally resides in the project directory. To be automatically recognized by the tool, the configuration file is usually placed in a hidden directory under the project root, which naturally puts it within the tracking scope of the version control system.

    2.2 Layer 2: Ignore Rules “Happen” Not to Cover Real Scenarios

    By design, such local configuration files should be added to the developer’s global ignore list (i.e., the Git global ignore configuration) so they are not committed with the code. The common industry practice is to maintain a global ignore rule:

    1. # ~/.gitignore_global (global ignore rules)
    2. # Ignore local permission and preference files of AI coding tools
    3. .claude/settings.local.json
    4. .idea/
    5. .vscode/*.local.*
    6. *.local
    7. .env
    8. .env.*
    9. secrets/

    However, global ignore rules have an easily overlooked inheritance trap: they only take effect in the environment of that developer with the corresponding global configuration enabled. The following situations can directly cause the defense to fail:

    Scenario Why the global ignore fails
    The project is cloned to another machine The new environment may not have the global ignore rule configured, and there is no project-level .gitignore as a fallback
    A regular folder is initialized as a repository afterward Sensitive content already exists in the files at initialization time; ignore rules only apply to “untracked files”
    The ignore rule is overridden or commented out Negation rules in a project-level .gitignore may reverse-include the file
    Written using an IDE or other tools The editor’s global settings may override the command-line tool’s global settings
    Using CI/container environments Ephemeral environments do not retain the developer’s global configuration

    The most critical semantic point to make clear here is: .gitignore only works for “files that have not yet been tracked.” Once a file has entered the index, adding an ignore rule is completely ineffective:

    1. # Wrong approach: the file is already tracked, so the ignore rule does not take effect
    2. echo ".claude/settings.local.json" >> .gitignore
    3. git status # The file still shows as tracked with changes
    4. # Correct approach: untrack first, then add the ignore rule
    5. git rm --cached .claude/settings.local.json
    6. echo ".claude/settings.local.json" >> .gitignore
    7. git commit -m "chore: stop tracking local agent settings"

    2.3 Layer 3: The Tool Commits Changes Itself, Skipping Human Confirmation

    The most alarming aspect revealed by the research is that AI coding tools sometimes include configuration file changes in commits without the user confirming them one by one. This breaks one of the most basic assumptions in the security model: “only developers can decide what enters version history.” When a tool has the ability to automatically stage (git add), automatically commit, and even automatically push, a seemingly harmless “help me commit the changes” can bring sensitive configuration files into history.

    At the same time, note that the response mechanism for issue reports itself has structural flaws: the relevant risk was reported through the bug feedback channel as early as August 2025, pointing out that local settings files might not be correctly added to the ignore list, or that sensitive commands might be written into other files not covered by ignore rules. However, that report was automatically closed due to long-term inactivity (about 60 days). This reveals a common phenomenon: in the bug tracking processes of open-source and closed-source tools, “no one follows up” is equated with “the problem does not exist,” allowing known risks to persist silently until a large-scale outbreak.

    3. Exposure Data and Impact Analysis

    The timeline and key data of the incident can be organized as follows, allowing readers to gauge the scale of similar risks:

    Timeline

    • August 2025: The configuration ignore defect was first reported, then closed due to long-term inactivity.
    • January 2025 – November 7, 2026: Third-party security research continuously observed the presence of related configuration files on public code hosting platforms.
    • Early November 2026: Multiple security research organizations published scan results.
    • November 9, 2026: Technology media published an in-depth report pointing out that AI coding agents are accidentally exposing developers’ sensitive credentials to public repositories.
    • November 10, 2026: Domestic technology media followed up, and the incident entered broad discussion.
    • November 7, 2026: A core team member of the tool publicly responded that preventive measures were being studied and that an official fix was underway.

    Scan and identification data (results from two independent research organizations)

    Dimension Organization A (comprehensive analysis of configs/history/chat logs) Organization B (large-scale repository scan)
    Scan scope 104,185 public configuration files Public repositories from 2025-01 to 2026-11-07
    Direct hits 1,379 unique keys in 1,122 active files 23,276 repositories with the local config file
    Comprehensive identification 2,539 real credentials across 1,994 codebases 31,088 distinct sensitive credentials
    Still valid at detection time — 5,343
    Affected organizations 63 identified organizations Startups, payment companies, universities, software vendors

    The huge difference between the two datasets is itself important information: the scanning strategy determines the statistical scope of the exposure. Organization A further incorporated version history records, shared settings files, and agent interaction logs for correlation analysis, expanding “1,379” to “2,539.” This suggests to defenders that scanning only the current state of the workspace is far from enough.

    Among the types of leaked content (Organization B’s scope), the most representative are:

    • About 398 service-type API tokens (can directly call external services)
    • About 379 database passwords
    • About 149 AI model API keys

    Impact characteristics: Affected parties covered B2B startups, payment companies, higher education institutions, and software vendors; the exposure also extended to other hosting forms such as workspace-type services and private code hosting platforms. The actual leaked content included cloud database passwords, production environment tokens of payment service providers, root-level SSH login information for servers, and even owner passwords for medical record databases. From an attacker’s perspective, this list is equivalent to a pre-organized “lateral movement map”: with root SSH you can log into servers, with production tokens you can call payment interfaces, with database passwords you can directly read data, and AI model keys can be used to steal inference quotas and cause direct financial losses.

    4. Why “Local Permission Files” Inevitably Become High-Risk Assets

    Abstracting the above phenomena one level up, we can extract the characteristics of the new attack surface introduced by AI coding tools:

    1. Credentials move earlier in their location. Traditional leaks mostly occur in mid-to-late stages such as CI variables, configuration file repositories, and image layers; now credentials enter local text files during the interactive debugging stage, at an earlier point with fewer protection steps.
    2. Credentials aggregate in the form of natural language context. To understand tasks, agents proactively request or read environment variables, connection strings, and key file contents. This information is solidified in the form of “directly executable commands,” highly readable and requiring no additional reverse engineering.
    3. The boundary of human-machine collaboration is blurred. “Tool auto-commit” and “tool auto-replay commands” partially bypass the traditional “code review + commit approval” process; reviewers see the final code but not the contents of configuration files.
    4. Interaction logs become a second exposure surface. The agent’s session records are themselves text assets that often contain the same sensitive values, yet are rarely included in sensitive information governance.

    5. Governance and Protection Practices

    The following measures are organized in three levels: “individual—team—platform.” All can be implemented using general tool capabilities and do not depend on any specific vendor product.

    5.1 Individual Side: Change Defaults to Secure Defaults

    (1) Disable the “persistent authorization” option and use an allowlist mechanism instead. Do not make “Allow and don’t ask again” a daily operational habit. Instead, explicitly declare an allow list in project-level configuration, only allowing command forms with no parameters, no environment variables, and no credential parameters:

    1. {
    2. "$schema": "https://json-schema.org/draft/2020-12/schema",
    3. "permissions": {
    4. "allow": [
    5. "Bash(git status)",
    6. "Bash(git diff:*)",
    7. "Bash(npm run lint)",
    8. "Bash(npm run test)",
    9. "Bash(pnpm build)"
    10. ],
    11. "deny": [
    12. "Bash(rm -rf:*)",
    13. "Bash(curl:* | *)",
    14. "Read(./.env)",
    15. "Read(./.claude/settings.local.json)",
    16. "Read(./secrets/**)"
    17. ]
    18. }
    19. }

    The key point is: the allow list matches “command forms” rather than “original command text,” and explicit deny rules are set to block reading sensitive files.

    (2) Establish three-level ignore rules for defense in depth.

    1. # Level 1: user global ignore (covers all personal repositories)
    2. # ~/.gitignore_global
    3. .claude/settings.local.json
    4. .claude/*.local.*
    5. .env
    6. .env.*
    7. *.pem
    8. *.key
    9. # Level 2: repository-level ignore (distributed with the repo, protects collaborators)
    10. # .gitignore
    11. .claude/settings.local.json
    12. .claude/*.local.*
    13. .env
    14. .env.*
    15. *.pem
    16. *.key
    17. # Level 3: whole-repo templates and initialization scripts to ensure newly cloned/initialized repos automatically include the rules

    (3) Move sensitive values out of executable commands. Credentials should always be injected via environment variables or external key management, with only references left in commands:

    1. # Counter-example: the password enters command history and may be written into config files by the tool
    2. mysql -h db.internal -u root -p'Prod#2026!Secret'
    3. # Correct approach: no secrets in the command; secrets are injected by the environment/key management component
    4. export MYSQL_PWD_FILE=/run/secrets/db_password # injected externally
    5. mysql --defaults-extra-file=/etc/my.cnf.d/app.cnf

    (4) Regularly clean and inspect local configuration. Include configuration files in routine inspections and check for residual sensitive information:

    1. # List all local permission files
    2. find . -name "*.local.json" -o -name "settings.local.json" | head -50
    3. # Coarse-grained check: whether there are long strings resembling keys
    4. grep -REn "(password|passwd|token|secret|api[_-]?key|access[_-]?key)[[:space:]]*[:=][[:space:]]*[^[:space:]]{8,}" \
    5. .claude/ 2>/dev/null | sed -E 's/[:=].*/=<redacted>/'

    5.2 Team Side: Move Control Points Forward to Commits and Pipelines

    (1) Enable repository-level secret scanning and push protection. Enable secret scanning and push protection on the code hosting platform, and directly reject the push when suspected credentials are hit rather than alerting after the fact. The remediation cost of after-the-fact alerts is dozens of times that of prevention.

    (2) Add layered detection in CI. Set up at least three checkpoints in the pipeline:

    1. # Illustrative CI configuration; specific fields depend on the pipeline engine used
    2. stages: [detect, build, test, release]
    3. secret_scan:
    4. stage: detect
    5. script:
    6. # 1) Scan current workspace content (including config files, scripts, test data)
    7. - run_secret_scanner --path . --severity medium --fail-on-found
    8. # 2) Scan the full commit history (the most easily overlooked step)
    9. - run_secret_scanner --path . --history --fail-on-found
    10. allow_failure: false
    11. sast_and_deps:
    12. stage: detect
    13. script:
    14. - run_dependency_check --fail-on-high

    (3) Constrain commit behavior with an “immutable history” mindset. Once credentials enter history, deleting the file does not solve the problem; you must treat it as already leaked and rotate immediately:

    1. # Four-step emergency response
    2. # 1) Immediately rotate/revoke credentials (highest priority; do not clean history first)
    3. # Covers: database passwords, cloud API keys, payment tokens, SSH key pairs, AI service keys
    4. # 2) Investigate traces of credential access/use (audit logs, abnormal call sources)
    5. # 3) Clean history (only after collaboration is coordinated and backups are informed)
    6. git filter-repo --path .claude/settings.local.json --invert-paths
    7. git push --force --all && git push --force --tags
    8. # 4) Notify all collaborators to re-clone (old clones still retain the leaked content)

    The order is crucial: rotate first, clean later. History cleaning requires force pushes and invalidates everyone’s local repositories, while attackers often complete automated scraping before disclosure; cleaning only reduces the probability of being scanned later.

    (4) Establish sensitive information governance norms. Explicitly prohibit writing real credentials into: AI assistant configuration files, session records, test cases, sample documentation, debugging scripts, and container build contexts. For configurations that must be shared, use templates with placeholders:

    1. # config.example.yaml — can be committed
    2. database:
    3. host: ${DB_HOST}
    4. port: 5432
    5. user: ${DB_USER}
    6. password: ${DB_PASSWORD} # injected at runtime by the key management service

    5.3 Platform and Tool Side: Secure Defaults and Observability

    For designers of development tools, this incident provides clear design principles:

    1. Sensitive information should never be persisted as plaintext rules. Authorization rules should only store “command form/tool name + parameter patterns,” with parameters that may contain secrets redacted or refused for persistence.
    2. Default to refusing persistence; persistence requires explicit secondary confirmation. Change “don’t ask again” to require separate confirmation, and before saving, prompt “this rule will be written to a local file and may contain sensitive parameters.”
    3. Persisted files should be excluded from version control by default. Tools should automatically write project-level ignore rules during project initialization rather than relying on the developer’s global configuration.
    4. Auto-commit capability needs boundaries. When a tool executes git add, it should follow an explicit file list, prohibit git add -A/git add ., and run a secret scan before committing.
    5. Bug feedback must not “silently expire.” Feedback involving security semantics should have an independent handling SLA and must not share the “close on inactivity” policy with general issues.
    6. Provide visibility and cleanup entry points for local configuration. Let users see at a glance “which commands are currently allowed, which of them contain suspected secrets, and how to clean them up with one click.”

    6. Reusable Checklist

    No. Check item Pass criterion
    1 Whether local permission/preference files are covered by three-level ignore rules Not visible in git status of a newly cloned repo
    2 Whether previously tracked sensitive files have been git rm --cached The path does not exist in the index
    3 Whether commands contain plaintext passwords, tokens, or connection strings Zero scan hits
    4 Whether secret scanning is enabled for the repository and pipeline Blocks on hit, including history scanning
    5 Whether all leaked historical credentials have been rotated Rotation records are available and old values are invalid
    6 Whether there are long-standing broad authorizations of “Allow and don’t ask again” Narrowed to form-based allowlists
    7 Whether AI assistant session records are included in sensitive information management Session files are within the scope of ignoring and encryption
    8 Whether new members’ environments automatically get secure default configurations Initialization script completes it in one click

    7. Conclusion

    The technical core of this incident is not complex and can even be summarized in one sentence: development tools turned “the user’s temporary authorization” into “persistent text containing secrets,” while version control systems treat everything in the project directory as shareable assets by default. As long as any one of the ignore rules, scan interception, or commit boundaries is missing, the leak materializes.

    The deeper lesson is this: as AI coding capabilities become deeply embedded in daily development workflows, the generation point,停留 point, and spread point of credentials have all shifted—credentials enter local text earlier, appear more frequently in natural language interactions, and are more easily brought into version history automatically by tools. The traditional approach of “only managing CI/CD key management” is no longer enough; sensitive information governance must be extended to the editor and AI assistant layer.

    Three lowest-cost action recommendations for teams: today, add local permission files to three-level ignore rules and untrack existing ones; within this week, enable secret scanning for repositories and pipelines (be sure to include history scanning); within this quarter, establish and drill an emergency process of “rotate on suspected leak.” These three things require no new capabilities to purchase, yet cover most of the exposure surface of this type of risk.

    When building R&D systems in the cloud, several general capabilities can be used to implement the above norms: use a key management and credential hosting service to centrally store sensitive values and support automatic rotation; use object storage and artifact repositories to host configuration templates rather than real configurations; use a log audit service to retain credential call records for tracing anomalies; use monitoring and alerting to intercept token calls from abnormal sources in real time. Tool capabilities are only support; the real defense is still the process of “secure default configuration + layered detection + rapid rotation.”