Credential Leakage in AI Coding Tools: How a Convenience Feature Exposed Thousands of Secrets

    This article examines a disclosed credential leakage incident involving AI coding agents, where an "allow and don't ask again" authorization rule was persisted together with raw command text containing plaintext passwords, tokens, and private keys. It breaks down the root causes across authorization persistence, ignore-rule scope, version history, and broken feedback loops, then outlines a reusable defense system covering repository templates, secret management and rotation, least-privilege authorization, and runtime isolation. A post-incident response checklist and three practical recommendations for teams are also included.

    1. Incident Recap: How a Convenience Option Turned into a Mass Credential Leak

    In November 2026, the security research community disclosed a typical credential leakage incident involving AI coding agents. When handling authorization for automatic command execution, a class of AI coding tools wrote the user’s “allow and don’t ask again” rule to a local settings file together with the original command text. That command text often carried plaintext passwords, access tokens, and private keys. Under certain conditions, the file ended up in version control, ultimately exposing thousands of real credentials across nearly two thousand repositories.

    According to the publicly disclosed statistics, the problem shows a clear three-layer amplification pattern:

    • Layer one is the current working copy: researchers scanned more than one hundred thousand publicly visible configuration files and located over a thousand distinct keys in more than a thousand active files.
    • Layer two is version history: after including commit history, shared settings files, and agent session logs in the analysis, the number of affected repositories and credentials multiplied.
    • Layer three is the time window: another dimension of the analysis covered roughly the past two years and found tens of thousands of sensitive entries in total, with thousands still valid at the time of detection.

    The types of leaked content were also highly representative: service-side API tokens, database passwords, model invocation keys, production environment tokens, remote host login details, and even account credentials for medical databases. Affected parties included startups, payment companies, universities, and software vendors, and the exposure spilled over into model hosting spaces and other forms of code hosting. This shows that the risk does not pick an industry; it only picks whether secrets were written into files.

    2. Root Cause Breakdown: Four Points of Failure at Once

    2.1 Authorization Decisions Persisted as Plaintext Records

    “Don’t ask again” is essentially a permission rule, and in its ideal form it should only record a command pattern or a tool identifier. In practice, however, writing the full command string to disk degrades the rule file into a container for sensitive information. More critically, coarse authorization granularity and the lack of parameter placeholders and variable redaction mean that a one-time convenience buys long-term exposure.

    2.2 The Scope of Ignore Rules Was Misunderstood

    Developers usually add sensitive files to a global ignore list and assume everything is handled. But global rules do not necessarily cover every individual repository: a project cloned to a new machine, an ordinary directory that is only later initialized as a repository, and the presence of submodules and nested directories can all create blind spots in the ignore policy. In addition, agents in some scenarios commit settings changes on their own, further bypassing human expectations.

    2.3 History Means “Deleted” Is Not “Safe”

    Even if the file has been removed in the current state, commit history, branch snapshots, review references, and session logs may still retain the original text. Once a credential enters history, it must be treated as leaked rather than resolved by simply deleting the file.

    2.4 The Feedback Loop Broke Down

    More than a year earlier, there were already defect reports about settings files not being properly ignored and sensitive commands being written into unprotected files, and they were eventually closed automatically after long periods of inactivity. When security feedback lacks a triage and tracking mechanism, low-priority issues settle into systemic risk.

    3. A Reusable Defense System: From Repository to Runtime

    3.1 Repository Side: Make “Secure by Default” a Template

    • Adopt an annotated ignore-list template that covers local settings, caches, logs, and environment files, and apply it automatically when a repository is initialized.
    • Enable pre-commit secret scanning and history scanning in CI, and block merges on any hit.
    • For configuration that must be shared, keep only placeholders and example values.

    Example ignore-list snippet:

    1. # Local personal settings and cache
    2. .claude/settings.local.json
    3. *.local.json
    4. .env.*
    5. !.env.example
    6. # Logs and temporary artifacts
    7. logs/
    8. tmp/

    3.2 Secret Side: Externalize, Manage, and Rotate

    • Keep all secrets in a dedicated secret management service or an environment injection layer, with code and configuration referencing only identifiers.
    • Define an expiration and automatic rotation for each type of credential to avoid “leaked once, valid forever.”
    • Never pass passwords in command-line arguments; use standard input or protected environment variables instead.

    Example of externalized configuration:

    1. # References only, no plaintext
    2. database:
    3. password_ref: secret://prod/db/password
    4. api:
    5. token_ref: secret://shared/model/token

    3.3 Authorization Side: Least Privilege and Revocability

    • Limit “don’t ask again” to a command-pattern allowlist and prohibit storing full command strings.
    • Assign separate risk levels to high-risk actions such as writing files, network access, and package manager invocations, with a second confirmation by default.
    • Provide an entry point to view and revoke granted rules in one step, and audit them regularly.

    3.4 Runtime Side: Isolation and Observability

    • Run agents in containers or isolated workspaces, restricting filesystem and network egress.
    • Use logging services and monitoring alerts to baseline-alert on abnormal outbound connections and abnormal commits.
    • Combine with artifact repository access policies to narrow the usable scope of credentials.

    4. Incident Response Checklist: Golden Actions After Confirming a Leak

    1. Immediately revoke and rotate all involved credentials; stop the bleeding before collecting evidence.
    2. Clean the version history and notify all parties that cloned the repository to pull again.
    3. Check whether the same keys are reused in other repositories, images, and hosting spaces.
    4. Review authorization and ignore policies, and fill the gaps with templates and pipeline gates.
    5. Establish a triage and deadline mechanism for security feedback so issues are not closed automatically.

    5. Three Practical Recommendations for Teams

    • Write “secrets never land on disk” into development standards and review checklists as a hard condition for merging.
    • Use templated scaffolding to unify the security baseline of new repositories and reduce human omissions.
    • Make credential governance part of daily operations: scan regularly, rotate regularly, and rehearse regularly.

    Conclusion: The efficiency gains from AI coding tools are real and visible, but a convenience option without boundaries settles risk into the codebase. Making authorization fine-grained, externalizing secrets, controlling history, and closing the feedback loop is the sustainable engineering practice. If an organization already uses cloud development environments and unified secret management capabilities, it can further consolidate the strategies above into an organization-level baseline, so that security and efficiency move in the same direction.