AI Coding Tools Leaking Sensitive Information: Causes and Remediation

    An AI security research group found roughly 100,000 AI coding assistant local settings files embedded in public repositories, with over a thousand containing plaintext passwords, tokens, or private keys. This article breaks down the three causes that compound into a stable defect chain—verbatim persistence of command authorization records, ignore rules that stay at the global or user level instead of the repository level, and tool-side auto-commit—and lays out a four-step response (discover, stop the bleeding, rebuild, verify) plus a four-layer governance framework for engineering teams. It also covers cloud development exposure surfaces and the metrics worth tracking. Readers will find concrete gitignore patterns, scanning commands, pre-push hook examples, and runtime secret injection configurations.

    Why AI Coding Assistants Leak Sensitive Information: Root Causes and Remediation Practices

    1. What Happened: A Small Problem That Keeps Recurring

    An AI security research group found roughly 100,000 AI coding assistant local settings files embedded in public repositories on a code hosting platform. About a thousand of them, coming from dozens of different organizations, contained plaintext passwords, tokens, or private keys.

    The risk had already been reported through feedback channels nearly a year earlier. Other reports noted that the settings file sometimes failed to land in the ignore list, or that sensitive commands were written to a separate file that version-control sharing does not protect. Those reports were automatically closed after 60 days without follow-up.

    This is not an isolated case of a user misconfiguring a single parameter. It is a stable defect chain built from tool behavior, version-control semantics, and collaboration habits. The key to understanding it is to move the problem from “a bug in one product” to a general engineering proposition: when an AI coding tool is granted shell execution permission, the authorization record is a complete copy of the command, and its sensitivity is on par with the command itself. Putting that record into a Git working tree means permanently storing a credential exposure in the version history.

    2. Three Causes and Their Compounding Effect

    1. Authorization records are written verbatim, so secrets embedded in commands spread with the record

    Take persistent authorization such as “allow and don’t ask again.” The tool typically writes the original command text into a local settings file under the user’s home directory. The design is reasonable on its own—staying out of the way requires persistence—but it overlooks one fact: most repeatedly executed commands are not “clean.” They often carry inline password strings, connection URLs with embedded keys, or temporary tokens. If the recording stage performed structural normalization—keeping only the executable and argument positions, replacing suspected credential positions with placeholders and external references—the leak radius would narrow immediately.

    2. Ignore rules stay at the global or user level instead of the repository level

    Official documentation usually suggests adding the local settings file to the global ignore list, but the ignore mechanism has clear semantic boundaries:

    1. # Global ignore (depends on developer machine config, not portable)
    2. .claude/settings.local.json
    3. # Repository-level ignore (distributed with the repo, portable and auditable) — recommended
    4. .ai/*.local.json
    5. .ai/secrets/
    6. *.local.json
    7. !.ai/example.local.json

    Global ignore only takes effect for “this machine, this user.” Once the repository is cloned to a new machine, checked out by CI under a different identity, or a previously untracked directory is later promoted to the repository root, the rules do not travel with it, and sensitive files enter the pending-commit set.

    3. Tool-side auto-commit widens the error window

    In some implementations, the tool automatically commits changes to the settings file without the user explicitly typing anything. This turns the error from “possible” into “default”: auto-commit converts a misconfiguration that could have been rolled back locally into a fait accompli that requires rewriting history, cleaning mirrors, and notifying downstream consumers.

    Stacked together, the three causes multiply the leak radius. A deeper mechanism is the copy semantics of code hosting platforms: deleting a file from a repository does not delete the fork copies that have already been generated. Because repositories are mirrored, forked, and cached once they become publicly visible, deletion only affects the source point, and the exposure surface has already shifted from “one file” to “one persistent copy inside a fork network.” That is why post-hoc remediation costs far more than prevention.

    3. How to Identify and Handle It Systematically

    Move through four steps—discover, stop the bleeding, rebuild, verify—rather than deleting a key once.

    Step 1: Full discovery. Cover three sources: repository history (including deleted commits and squashed history segments), uncommitted working-tree content, and build artifacts and image layers. Use pattern matching plus a rule set for a coarse pass, focusing on connection strings, private key headers, long-lived tokens, and basic-auth URLs.

    1. # Example: scan the working tree and tracked history for high-risk patterns (no specific toolchain required)
    2. git grep -nE \
    3. '(password|passwd|secret|token)[[:space:]]*[:=][[:space:]]*[^[:space:]]{6,}' \
    4. $(git rev-list --all | head -n 200)
    5. git log --all -p -S 'BEGIN OPENSSH PRIVATE KEY' --oneline

    Step 2: Stop the bleeding. Revocation comes before cleanup. Any credential already pushed to remote history or the fork network should be treated as leaked: rotate it, shorten its lifetime, reduce its privileges, and bind source restrictions. History cleanup (rewriting commits, force-pushing, clearing caches and mirrors) is a coordinated operation and needs confirmation with downstream consumers.

    Step 3: Rebuild. Replace inline secrets with runtime injection: environment variables, a secrets management service, short-lived tokens, or reference-style configuration. Keep only placeholders in the settings file, for example:

    1. {
    2. "permissions": {
    3. "allow": [
    4. { "tool": "shell", "cmd": "mysql --defaults-extra-file=~/.ai/db.cnf" },
    5. { "tool": "shell", "cmd": "git push origin ${BRANCH:-main}" }
    6. ]
    7. }
    8. }
    1. # ~/.ai/db.cnf (mode 600, and never inside any repository)
    2. [client]
    3. user=app
    4. password=${DB_PASSWORD}

    Step 4: Verify. Move detection forward into the commit and push stages, and keep blocking checks as the final gate.

    1. # pre-push hook example: block if a suspected secret is found
    2. if git diff --cached --name-only | xargs -r grep -IlE \
    3. 'PRIVATE KEY|password[[:space:]]*=' ; then
    4. echo "Suspected sensitive information, commit blocked" >&2; exit 1
    5. fi

    4. A Governance Framework for Engineering Teams

    Governance has to land on four layers; missing one still leaves a bypass path.

    Layer 1: Authorization record design. Persistent authorization should store only command templates and argument constraints, never credential content. High-risk operation families (credential reads, data exports, remote pushes, delete operations) should not be silently allowed, nor permitted into any “no confirmation needed” allowlist. Also provide the narrowest-scope, shortest-lifetime authorization granularity—per directory, per session, per command family—and expire it by default when the session ends.

    Layer 2: Repository-level ignore and a visibility baseline. The ignore list must ship with the code and be auditable. Template files (example configs, placeholder configs) should be version-controlled, while real configs are always excluded. Write “which paths are off-limits for commits” into team conventions and fix it in the review checklist.

    Layer 3: Automated measurement. Build observable metrics instead of relying on self-discipline: the number of sensitive files in public repositories, the number of blocked commits, rotation timeliness, and the share of authorization records still containing plaintext secrets. These metrics reflect the real risk level better than “did anything go wrong.”

    Layer 4: Source cleanup and a closed accountability loop. A feedback channel that “closes after 60 days without follow-up” signals to users that reporting is pointless, and the risk migrates from a product defect to a social-engineering surface. Set an independent response deadline, reproduction path, and public status page for security reports, and give clear closure guidance for known high-risk behavior—for example: move real config files out of version control, switch to placeholders, and prefer ephemeral environments that do not persist to disk when cloud debugging is involved.

    5. Additional Notes for Cloud-Based Development

    Cloud development adds an often-overlooked exposure surface: temporary config files generated during debugging, log output, and build caches. Three general principles apply—credentials never enter image layers or build logs; debugging environments use short-lived authorization that is reclaimed when the session ends; sensitive directories are mounted as runtime volumes rather than distributed with the image. Combined with config baseline scanning, a secrets management service, and audit logs, an event like “a file was accidentally committed” turns from an uncontrollable public leak into an internal event that can be located, blocked, and traced.

    6. Conclusion

    The essence of this class of incident is that automation, while improving efficiency, also converts “each user confirmation” into a persistable data asset. Tools amplify convenience by default; security requires the exposure surface to shrink by default: authorization records carry no secrets, ignore rules ship with the repository, auto-commit yields to explicit confirmation, and credential rotation comes before history cleanup. Only when these four things are written into the process instead of depending on individual vigilance does large-scale leakage on the order of “100,000 files exposed, thousands containing plaintext keys” truly lose the ground it needs to happen.