Credential Leaks in AI Coding Assistant Local Authorization Files: Governance and Remediation

    This article examines how a single "don't ask again" checkbox in AI coding assistants can turn authorized shell commands—including database passwords, connection strings, and bearer tokens—into persistent credentials that leak through local authorization config files committed to repositories. It analyzes the two root-cause mismatches (authorization granularity and configuration scope), traces how one leaked file spreads across commit history, branches, forks, logs, and CI artifacts, and explains why generic secret scanners miss roughly half of these credentials. The article then lays out a "rotate first, clean up later" incident-response sequence, shows how to redesign authorization rules from literal commands to capability patterns, and presents four defense-in-depth gates plus an organizational implementation checklist. The central takeaway: authorization rules should be pattern-based, credentials should be managed by a secret store, and detection should be path-aware.

    1. Incident Review: How a “Don’t Ask Again” Checkbox Became a Credential Exit

    A security research team ran a large-scale scan across a public code hosting platform and zeroed in on an easily overlooked detail. When a smart coding assistant executes a shell command that requires authorization and the user chooses “Yes, and don’t ask again,” the tool persists that command verbatim as a durable authorization rule and writes it into a local authorization config file under the project directory (typically something like “tool config directory + settings.local.json”). The command line, however, is the most classic carrier of credentials—database passwords in the -p'password' form, connection strings like postgres://user:pass@host/db, and tokens like curl -H "Authorization: Bearer ..." all get saved unchanged.

    The quantitative results from the scan are as follows:

    Metric Result
    Publicly accessible local authorization config files ~104,185
    Files containing at least 1 secret ~1,122
    Deduplicated distinct secrets ~1,379
    Expanded scope (commit history, shared configs, agent run logs, code copies) ~2,539 secrets / ~1,994 repositories
    Of which database passwords ~379, over one-third
    Repositories with the leak present in the default branch for 217+ days ~half
    Detection by each of two common secret-scanning approaches ~564 / 643 hits, with ~215 files missed by both

    Other leaked artifacts include SSH credentials, cloud vendor access keys, and various third-party API tokens. The team compared the official documentation of a dozen-plus similar smart coding tools and pointed out that, so far, only this tool writes the full approved command into an in-project file by default—a crucial point, because it means this is not an “industry-wide problem” but a risk stemming from a default configuration choice. One caveat must be kept in mind: the team did not verify one by one whether these secrets were still valid; only one notified party confirmed its secret had been in a working state. The numbers above are therefore a lower bound on the risk, not an upper bound.

    2. Root Cause Analysis: Two Mismatches Between the Authorization Model and Configuration Scope

    “Yes, and don’t ask again” is a one-time decision at the interaction layer, but at the implementation layer it is a rule creation. The problem is that the only way to express the rule is the command text itself, not a semantic pattern. The user’s real intent is usually “let me run the database migration,” but what gets persisted is “allow this specific command with a plaintext password”—the two differ by an order of magnitude in permission semantics.

    2.2 Storage location mismatch: the user’s intent is “inside the project,” the side effect is “distributed with the repository”

    Putting the config file in the project directory has an upside: authorization rules travel with the project, so you don’t have to reconfigure when switching machines. But the downside is just as direct—it naturally falls within the scope of version control. Any add -A, any “let me just commit this real quick,” drags it into the repository.

    2.3 Ignore policy scope mismatch: the protection doesn’t travel with the project

    The tool adds the local authorization file to a machine-wide global ignore list, but does not write it into the repository’s own ignore file. This has two consequences. First, when collaborators clone the repository, they do not inherit this protection, and the first thing a new member does is commit it. Second, “I’ve already added it to the ignore list” creates a false sense of security—the ignore only affects future add operations and does nothing for files that have already been committed into history.

    2.4 Contrast with “cloud-side key encryption, model-side invisibility”

    The two narratives need to be kept separate. “API keys encrypted at rest in cloud sessions, invisible to the model in plaintext” describes the security design of the inference path and cloud-side storage; this incident describes the loss of control over local persistence and the commit path. The two are not contradictory, but their risk surfaces are entirely different: the former is bounded by the vendor’s control boundary, while the latter falls entirely on the developer’s own repository hygiene. Treating “the cloud can’t see plaintext” as an inference that “the plaintext was never written to disk” is a classic cognitive leap.

    3. Impact Amplification: Six Ways a Single File Spreads

    A single-file leak rarely stays at the single-file level; it keeps spreading along the following paths:

    1. Commit history: deleting the file does not erase history; objects in history can be restored by anyone with clone access.
    2. Branches and tags: security branches, release tags, and long-lived development branches each hold a copy.
    3. Forks and mirrors: once a public repository is forked, the original history spreads with the copy, and deleting the original repository cannot recall it.
    4. Shared configs and organization templates: some teams distribute shared configs as scaffold templates, so one leak contaminates every new project.
    5. Agent execution logs and terminal echoes: commands appear in terminal output, session records, and CI logs, and log systems often retain data for months.
    6. CI/CD artifacts and build caches: cache layers, artifact layers, and container image layers may retain snapshots of the config file.

    The data point that “roughly half of the repositories had credentials exposed in the default branch for 217+ days” shows that the exposure window is typically measured in months, not hours.

    4. Detection Blind Spots: Why Generic Secret Scanners Only Catch Half

    Among the 1,122 files containing secrets, the two common scanning approaches flagged only 564 and 643 hits respectively, and about 215 files were missed by both. The reasons come down to four points:

    • Rule sets favor structured credentials: mainstream rules target formats with fixed prefixes and length characteristics, such as cloud vendor keys and API tokens, whereas a password like mysql -h x -u y -p'zhangsan' has no recognizable features and cannot be matched with high confidence via regex.
    • Conservative entropy thresholds: short passwords have low character entropy, fall below common thresholds, and are filtered out outright.
    • Incomplete scan scope: by default the scan only covers the latest snapshot of the default branch and does not cover all branches or the full history.
    • Incremental scan mode breaks down: a mode that scans only changed lines skips entire regions during bulk imports, history migrations, and large-file replacements.

    The conclusion is clear: you must do path-aware detection. Rather than hoping generic rules identify every password, it is better to classify “authorization config files, CI config directories, and log directories” as high-priority scan paths and apply a dedicated rule set to those paths.

    5. Emergency Response: Why You Must “Rotate First, Clean Up Later”

    Getting the order wrong is the most common response mistake. Cleaning up history requires rewriting commits, force-pushing, and notifying everyone to re-clone—time-consuming and coordination-heavy—whereas once a credential has been cloned, the exposure is already a fact. Rotation stops the bleeding; cleanup is the wrap-up; stopping the bleeding always comes first.

    Recommended action sequence:

    Step Action Purpose and Notes
    0 Freeze and forensics Export the file and commit records as evidence first; do not delete immediately
    1 Assess and rotate In descending order of privilege: cloud high-privilege credentials → database accounts → SSH credentials → CI tokens → third-party APIs
    2 Revoke and audit Check cloud-side audit logs and database audit logs to determine anomalous source IPs and abnormal queries within the exposure window
    3 Index and history cleanup First use rm --cached to remove from tracking (keeping the local file), then rewrite history
    4 Add repository-level ignore Write the ignore rule into the repository’s own list so the protection ships with the project
    5 Authorization rule convergence and review Clean up plaintext rules already committed, and switch to pattern-based authorization

    Illustrative commands for discovery and cleanup:

    1. # 1) Locate whether a local authorization config exists on this machine
    2. find . -name "settings.local.json" -not -path "*/node_modules/*"
    3. # 2) Rough screening for suspected plaintext credentials (regex is only a hint; manual confirmation required)
    4. grep -rInE -- "(-p[[:space:]]*['\"]?[A-Za-z0-9@#!%^&*_-]{4,}|://[^/@[:space:]]+:[^/@[:space:]]+@)" \
    5. --include="settings*.json" .
    6. # 3) Remove from the version-control index while keeping the local file (illustrative; follow your specific system)
    7. vcs rm --cached agent-config/settings.local.json
    8. # 4) Write the ignore rule into the repository-level list so the protection ships with the project
    9. echo "settings.local.json" >> .gitignore

    6. Authorization Rule Redesign: Replace “Command Text” with “Patterns”

    After cleanup you must make a structural change, or the same file will simply be regenerated next week. The core principle is one sentence: the object of authorization should be a capability, not a command instance.

    1. {
    2. "permissions": {
    3. // Anti-pattern: one rule hard-codes the host, account, and plaintext password
    4. // "allow": ["Shell(mysql -h prod-db -u root -p'MyP@ssw0rd' *)"]
    5. // Correct pattern: pattern-based authorization by command prefix; inject credentials from environment variables or a secret management service
    6. "allow": [
    7. "Shell(npm run:*)",
    8. "Shell(make test)",
    9. "Shell(mysql *)",
    10. "Shell(psql *)"
    11. ],
    12. // Explicitly deny high-risk paths; higher priority than allow
    13. "deny": ["Read(.env*)", "Shell(curl * | sh)"]
    14. }
    15. }

    Companion changes on the credential side:

    • Credentials stay out of the command line: switch to environment variables, process-level temporary file descriptors, or credentials delivered at runtime by a secret management / credential management service.
    • Prefer short-lived dynamic credentials: use time-limited dynamic accounts on the database side to shrink the exposure window at the root, so that even if leaked, they expire automatically.
    • Least-privilege separation: migration accounts get read-only access to structure, and development accounts are barred from production databases, avoiding “one password rules them all.”
    • Disable frictionless authorization: prohibit “don’t ask again”-type options in engineering conventions, and convert frequent authorizations into a controlled allowlist + auditable approvals.

    7. Defense in Depth: Four Gates and One Detection Recommendation

    Gate one: at coding time (shift left). Converge authorization granularity on the tool side; provide templated ignore lists and config examples within the project; write “secrets must not enter the command line” into team coding standards and the new-hire checklist.

    Gate two: at commit time. Use a pre-commit hook for path-level blocking—very low cost:

    1. #!/bin/sh
    2. # Illustrative: block local authorization configs and common secret files from entering a commit
    3. for f in $(cat "$STAGED_FILE_LIST"); do
    4. case "$f" in
    5. */settings.local.json|*/.env|*/.env.*|*/credentials*|*id_rsa*)
    6. echo "[BLOCKED] $f appears to contain local credentials; add it to the ignore list or switch to secret management" >&2
    7. exit 1;;
    8. esac
    9. done

    Gate three: server-side. Enable the code hosting platform’s push protection (pre-receive blocking) and lock in a full secret-scan task in CI; enable branch protection and mandatory review for high-risk repositories.

    Gate four: at runtime. Enable operation auditing, anomalous-login detection, and alerting on the cloud and database sides; establish the emergency assumption that “once a credential is committed it is considered leaked,” backed by a rotation playbook and named owners.

    Example detection rule (for featureless passwords in authorization configs, use a dual condition of “path + pattern”):

    1. rules:
    2. - name: shell-embedded-credential
    3. description: Command-line embedded passwords/connection strings in authorization configs
    4. paths:
    5. - "**/agent-config/settings*.json"
    6. - "**/.agent/**"
    7. patterns:
    8. - "(?i)\\s-p\\s*['\"]?[A-Za-z0-9@#!%^&*_-]{4,}"
    9. - "(?i)://[^:@/\\s]+:[^@/\\s]+@"
    10. - "(?i)(password|passwd|pwd|token|secret)\\s*[:=]\\s*['\"]?[A-Za-z0-9_\\-]{6,}"
    11. entropy: 3.0 # OR'd with pattern matching to avoid missing short passwords via entropy alone
    12. severity: high
    13. allowlist:
    14. - "Placeholder constants in examples, such as <YOUR_PASSWORD>"

    Security note: even with path-level blocking in place, you should not treat a local authorization config file as trusted input. If your team genuinely needs to share authorization rules, share only pattern-based allowlists, and treat any entry with parameterized commands as pending review.

    8. Organizational Implementation Checklist

    Seven actions team leaders can schedule directly:

    1. Search organization-wide for settings.local.json and similar local authorization files to first understand the existing stock.
    2. Establish an emergency playbook where “rotation takes priority over cleanup,” clarifying who has the authority to revoke and how fast it must be done.
    3. Wire path-aware scanning into both CI and the pre-commit hook for two-sided coverage.
    4. Replace config files and command-line argument passing with a secret management / credential management service, prioritizing high-privilege credentials.
    5. Build ignore lists and config samples into a unified repository template so new projects are secure out of the box.
    6. Enable cloud-side and database-side audit alerting, and treat mean exposure duration as a security metric.
    7. Write “an AI coding assistant’s authorization rules are code assets” into engineering standards and bring them under code review.

    9. Conclusion: Convenience Must Have Boundaries

    What is most worth watching for in incidents like this is not any tool’s default setting, but the implicit trade between convenience and auditability: when a user clicks “don’t ask again,” what they buy is fluidity, and what they pay is a list of credentials they didn’t know existed and that gets distributed long-term with the repository. The point of protection therefore should not be “use AI coding assistants less,” but to make three things solid—pattern-based authorization rules, managed credentials, and path-based detection. Achieve these three, and even if a similar default-configuration problem recurs, the exposure surface will be constrained to a range that is rotatable, recoverable, and auditable.