AI Coding Tools Are Hiding Your Secrets: A Developer's Audit Checklist

··13 min read
AI Coding Tools Are Hiding Your Secrets: A Developer's Audit Checklist

Last spring, a developer I know pasted a chunk of production configuration into an AI coding assistant to help debug a failing deployment. The snippet included a database connection string, an internal API hostname, and a comment with a staging admin password that someone had left behind two years earlier. The fix took four minutes. The question that kept him up that night was simpler: where did that text go, who can read it, and how long does it live there?

Most developers have asked themselves some version of that question, and most have shrugged it off. AI coding tools have become part of the daily workflow for a large share of professional programmers. They autocomplete functions, explain legacy code, write tests, and refactor modules, and they do it by reading your code, your open files, your terminal output, and sometimes your entire repository. That is an enormous amount of context to hand over, often without anyone on the team reading the terms of service closely or thinking about what the tool actually retains.

The surprising part is how little friction there is. Installing an AI extension takes two clicks. Accepting a default setting that enables "improve the model with your data" takes one. Nothing in the editor flashes a warning when you paste a private key. The risk accumulates quietly, one completion at a time.

This article is a practical audit guide. It covers what these tools actually see, how to check what your organization's tools retain, where secrets most often leak, and a checklist you can work through in an afternoon. I have run versions of this audit on my own machine and on two small team setups, and the results were humbling enough that I now do it every quarter. Where I mention tools or products, I am describing trade-offs I have seen firsthand, not endorsing a vendor. Your threat model will differ from mine.

Key Takeaways

  • AI coding tools typically read far more than the file you are editing: open tabs, terminal history, nearby files, and sometimes the full repository.
  • Retention and training policies differ sharply between free, team, and enterprise tiers. Check the tier your developers are actually on, not the one you think they are on.
  • Secrets leak most often through pasted error logs, .env files that are not excluded, and hardcoded credentials in old commits that the assistant indexes.
  • Scope access with ignore files and workspace settings before you scope it with trust. Exclude secrets directories at the tool level.
  • Rotate any credential that has ever appeared in a prompt, even if you believe the vendor deletes it. Rotation is cheaper than an incident.
  • Run the full audit quarterly. New extensions, new defaults, and new plugin permissions arrive constantly, and yesterday's clean configuration drifts.

What Do AI Coding Tools Actually See in Your Environment?

The honest answer is more than most developers assume. The prompt you type is only the visible part. Depending on the tool and its configuration, an AI coding assistant may ingest several layers of context in every request.

The layers of context

  • The active file: the code you are editing, including any inline comments and string literals.
  • Open tabs and recently viewed files: many tools pull these in to improve suggestions.
  • The surrounding project: some assistants index the entire workspace to answer questions about it. That index can contain .env files, config folders, and test fixtures with real data.
  • Terminal output and logs: when you ask the tool to explain a failing build, the stack trace you paste or the terminal buffer the tool reads may contain tokens, hostnames, or customer identifiers.
  • Git history: if the tool can query commit history, a secret removed three commits ago can still be recoverable from the log.
  • Agent actions: newer agentic modes can read files, run commands, and call external APIs on your behalf. Each action is another surface.

Consider a typical small team of five developers. Each has an assistant installed in their editor, a shared .env.example that someone occasionally copies to .env, and a monorepo with three services. A conservative estimate is that each developer opens between 30 and 60 files in a working day and has perhaps 10 to 20 terminal sessions in rotation. Even if only 2 percent of that context contains something sensitive, the team is sending dozens of sensitive fragments a week. Most teams have never counted.

How Do You Check What Your AI Coding Tool Retains?

The question of retention is where vendors differ most, and where the marketing language is most slippery. "We do not train on your data" can mean very different things depending on the plan. Some tiers exclude customer content from model training but still retain prompts for abuse monitoring for a defined period. Others retain nothing beyond the request. A few keep logs indefinitely for debugging unless you ask otherwise.

Do not rely on the marketing page. Read the data processing addendum and the retention section of the terms for the specific plan you are on. Pay attention to three questions: whether prompts and completions are used for training, how long they are retained and where, and whether any human at the vendor can review them.

Step-by-step: verify retention for one tool

  1. Identify the exact product and plan each developer uses. Ask everyone to paste the account type shown in their settings, not what they think they bought.
  2. Locate the vendor's data retention policy and the data processing agreement. Search for the words "retention," "training," "human review," and "abuse monitoring."
  3. Record the retention period for prompts and for telemetry separately. These are often different numbers.
  4. Check the admin console (for team and enterprise tiers) for toggles governing training opt-out and data sharing. Screenshot the settings and date them.
  5. Confirm whether the setting applies to all seats or only to new ones. This catches the common case where a grandfathered account retained the old default.
  6. Email the vendor's support team and ask for written confirmation of the retention behavior for your plan. Keep the reply in your compliance folder.

Where Do Secrets Actually Leak?

Teams worry about the dramatic case, a malicious insider exfiltrating code through a plugin. The more common leak is boring. A developer pastes a stack trace that includes a bearer token. An assistant indexes a config/local.json that was never added to the ignore list. A test fixture contains a production email address and a real API key that someone copied from staging.

I have seen all three in the last year. None involved bad intent. All involved a default that nobody revisited.

The four leak patterns to check first

  • Pasted logs and errors. Stack traces from production frequently include request headers, query strings, and user identifiers.
  • Unexcluded environment files. .env, .env.local, secrets.yaml, and *.pem files are often indexed by default.
  • Historical secrets in git. A key committed and then deleted is still in history. If the assistant reads history, it reads the key.
  • Copied sample data. Fixtures pulled from production databases carry real personal data into the context window.

Scoping Access: Ignore Files and Workspace Controls

Before you decide what to trust a tool with, decide what it should never see. Most assistants respect some form of ignore file, though the mechanism and reliability vary. Treat the ignore file as a defense-in-depth layer, not a guarantee, and verify it by testing whether a known excluded file surfaces in a prompt.

A practical exclusion list

At minimum, exclude the following from any indexing or context pull:

  • .env* and any variant such as .env.production
  • **/secrets/**, **/credentials/**, and **/*.pem, **/*.key
  • Terraform state files (*.tfstate) and cloud config directories such as .aws/ and .kube/
  • Database dumps and anything under fixtures/prod/ or similar
  • Local terminal history files such as .bash_history

Verify the exclusion works

  1. Create a dummy file named .env.audit-test containing the string CANARY-7731.
  2. Open the assistant and ask it, in a fresh session, to list any environment variables it can see or to search the workspace for the string CANARY.
  3. If the canary appears in any response, your exclusion is not working. Fix the ignore configuration and retest.
  4. Delete the canary file and record the test date in your audit log.

Comparing Common Controls for AI Coding Tool Security

Teams often ask which control matters most. The honest answer depends on whether your problem is accidental leakage, vendor retention, or insider misuse. The table below compares five common controls on the criteria I find most useful when choosing where to spend effort.

Control Protects against accidental paste Protects against vendor retention Protects against indexing leaks Setup effort Ongoing maintenance
Developer training on what not to paste Medium None None Low Medium
Ignore files and workspace exclusions Low None High Low Low
Enterprise plan with zero-retention terms None High Medium Medium Low
Secret scanning pre-commit and in editor Medium None Medium Medium Medium
Credential rotation after exposure High (limits damage) High (limits damage) High (limits damage) Low Low

My view: start with exclusions and rotation, because they are cheap and address the most probable failures. Then pursue the enterprise plan if your data is regulated. Training alone helps but rarely holds up under pressure, because people paste under deadline.

A Worked Example: Auditing a Five-Person Team

Let me walk through a realistic scenario. Suppose a five-person team runs a SaaS product with three services, one shared database cluster, and a payment integration. Each developer uses an AI assistant on a mix of free and paid individual plans, because the team never standardized procurement. The team wants to know its exposure before a client security questionnaire arrives.

They start by inventorying. Across five developers, they find six separate accounts, because one developer has two (a personal and a work login). Three accounts are on individual free plans with default training settings enabled. Two are on individual paid plans. One is a team plan

Cover image: Software by I.Gouss, licensed under BY-SA 2.0 via Openverse.

Recent Posts

View all →

Most Popular Software

View all →

Browse by Platform

View all →