AI coding assistant security risks start with a deceptively simple act: a developer pastes code into a prompt. That paste can carry API keys, customer records, proprietary algorithms and database credentials — and once it leaves your network, there is no practical way to pull it back. This guide explains what actually goes into the prompt, what can go wrong with it, and the policies that keep your team fast.
If your developers use GitHub Copilot, Cursor, Claude Code or a similar tool, this is not hypothetical. Four in five developers now use or plan to use AI tools, according to Stack Overflow’s 2025 survey. The question is no longer whether to allow these tools, but how to use them without the prompt becoming the weakest point in your security posture.
What your developers actually paste into the prompt
The prompt is never just the question a developer types. A modern coding agent builds its context from everything it can read: the files in the working directory, command output, environment variables, and the contents of whatever the developer highlights. When a developer asks an agent to fix a failing test, the agent may see the test, the code under test, and the configuration that wires them together.
In practice, the things that end up in prompts include whole source files, environment files, configuration, stack traces containing tokens, SQL queries with real customer data, internal API documentation, and proprietary business logic. Most developers do not think of this as sending data to a third party. It feels like asking a colleague a question. But a colleague works inside your network and under your contracts. A hosted model provider is neither unless you have an agreement that says otherwise — and a paste never goes through the version-control review that would have caught the credential inside it.
AI coding assistant security risks: the five that matter
Every risk below has been demonstrated against production tools. They are not edge cases, and they do not require a vulnerability in the model itself. Most of them work by borrowing permissions the developer already granted.
1. Secrets and source code leaving the building
This is the most common risk and the easiest to measure. GitGuardian’s State of Secrets Sprawl 2026 report found that commits assisted by Claude Code leaked secrets at a rate of 3.2 percent, against a 1.5 percent baseline across all public GitHub commits. The same research counted 24,008 unique secrets exposed in MCP configuration files on public GitHub, of which 2,117 were still valid when discovered. The leak is rarely deliberate: an agent writes a config file or a debug script, and a credential sitting in an environment variable lands in a file that gets committed, at a speed that outruns manual review. Read the full analysis in this breakdown of how coding agents leak secrets.
2. Prompt injection through everything the agent reads
A coding agent cannot reliably tell data from instructions. Anything it reads — a GitHub issue body, a pull request title, a README, a dependency changelog, a fetched web page, an error trace — can carry instructions the agent treats as authoritative. Researchers demonstrated this against production tools: Claude Code, Google’s Gemini CLI and GitHub Copilot Agent could each be hijacked through GitHub pull request titles, issue bodies and comments, turning the repository’s own CI secrets into stolen data exfiltrated through GitHub itself. A paper analysing 78 studies catalogues 42 distinct attack techniques and found defences fail more than 85 percent of the time once an attacker adapts. The full research is summarised in this guide to prompt injection and credential theft in AI agents.
3. Poisoned instruction files that travel with the repo
The files that tell a coding agent how to behave — CLAUDE.md, AGENTS.md, .cursor/rules and .github/copilot-instructions.md — are read as instructions and travel with the repository. They can be written by anyone whose code you clone. A poisoned instruction file can tell the agent to send secrets elsewhere, skip tests, or install a package, and the developer who launched the agent may never read the file that gave the order. Treat instruction files as code, with the same review bar as any other change.
4. Malicious dependencies that weaponise the agent
In August 2025, attackers published malicious versions of Nx, a widely used JavaScript build system, to the npm registry. The payload was unusual: it did not carry much of its own logic for hunting secrets. It first checked whether the developer had an AI coding agent installed, and if one was present, it put that agent to work. Claude Code was launched with –dangerously-skip-permissions, Gemini CLI with –yolo, and Amazon Q with –trust-all-tools. Each flag switches off the confirmation prompts that normally sit between the agent and the developer’s filesystem. No model was jailbroken, and no vulnerability in any of the agents was exploited. The malware borrowed permissions the developer had already granted. This account of the Nx attack sets out the three planes the risk operates on: what enters the agent’s context, what the agent can execute, and where data can leave.
5. Insecure code, generated at machine speed
Veracode’s 2025 study of more than 100 models found that AI-generated code introduced security vulnerabilities in 45 percent of coding tasks. Apiiro’s analysis of Fortune 50 repositories found AI-assisted developers produced three to four times more code but ten times more security findings, and exposed cloud credentials and keys nearly twice as often. As the security case for technology companies notes, one insecure suggestion propagates downstream as a supply-chain vulnerability.

The incidents that prove this is not theoretical
Research disclosed in December 2025, known as IDEsaster, found more than 30 vulnerabilities across ten AI-integrated development environments, and every one of the ten tools tested could be pushed into code execution or data exfiltration through prompt injection. Four 2026 advisories for Claude Code show the pattern: a repository settings file could point the agent at an attacker’s API endpoint and leak API keys, a committed settings file could bypass permission prompts, worktree handling let code run outside the macOS sandbox, and a stored API key could override enterprise sign-in. Microsoft disclosed two Semantic Kernel CVEs where prompt injection chained into host-level remote code execution. These cases are collected in this enterprise security guide for AI coding agents. The attacker does not break the model — they find something the agent already trusts and use it.
From our experience: the failures are process failures
We have built software with AI assistants in daily use for several years, and the pattern is consistent: the teams that get hurt are not the ones with the weakest models, they are the ones with the weakest habits. The agent amplifies whatever the team already does. A team that reviews diffs carefully gets a faster version of careful work; a team that rubber-stamps pull requests gets insecure code at four times the volume.
Three habits cause most of the damage we have seen. The first is running the agent with the safety prompts switched off: –dangerously-skip-permissions, –yolo and –trust-all-tools are debugging conveniences, not a working mode, and the Nx attack showed what happens when malware finds them already set. The second is letting the agent work in the same directory as production credentials, with the developer’s full shell access and no sandbox. The third is treating agent output as reviewed because a human glanced at the summary the agent wrote about its own change. The summary is marketing. The diff is the work. The controls below take an afternoon to set up; a leaked credential takes weeks to clean up and can cost a client relationship. That is the trade-off we put in front of clients when scoping AI integration and automation work.
A policy that works without slowing developers down
A good policy is short, specific, and enforced by tooling rather than by memory. These seven controls cover the five risks above, and none of them asks a developer to stop using the tools that make them productive.
- Approve the tools, ban the long tail. Pick two or three assistants, put them under an enterprise or zero-retention agreement, and block the rest. Shadow assistants are where unreviewed output and uncontracted data flows come from.
- No personal accounts for work code. If the provider’s terms allow training on prompts, work code does not go through it. Enterprise sign-in should be the only way the tool reaches your repositories.
- Secrets scanning in pre-commit and CI. Scan every commit for credentials before it lands, and scan the repository continuously.
- Never switch the safety prompts off. The permission-bypass flags stay off on every machine, in every script, in every CI job. If a workflow needs unattended execution, it runs in a sandbox with scoped credentials, not on a developer’s laptop with their keys.
- Sandbox the agent. Give the agent a workspace with network access allow-listed by default and no access to production credentials.
- Review instruction files like code. Changes to CLAUDE.md, AGENTS.md, .cursor/rules and copilot-instructions.md go through the same review as any other change.
- Review the diff, not the prompt. Agent-written code gets the same review bar as human-written code, plus automated checks: static analysis, dependency review, and tests that run.

Frequently asked questions
Can an AI coding assistant leak my source code?
Yes, in two ways. First, code you paste or that the agent reads is sent to the model provider unless you use a local model or an enterprise agreement with zero retention. Second, secrets inside that code can end up committed: GitGuardian measured a 3.2 percent secret-leak rate in Claude Code-assisted commits, more than double the 1.5 percent baseline. Use an enterprise agreement, keep credentials out of the working directory, and scan every commit.
What is prompt injection in a coding assistant?
Prompt injection is when content the agent reads — a GitHub issue, a pull request comment, a README, a dependency changelog, a tool response — contains instructions crafted to look like legitimate input but which are actually commands for the model to follow. Because the agent processes data and instructions through the same channel, it can be tricked into leaking credentials or running commands. Researchers demonstrated this against Claude Code, Gemini CLI and GitHub Copilot Agent using nothing more than pull request titles.
Should developers paste production secrets into an AI assistant?
No, never. Production credentials, API keys and customer data do not belong in a prompt, in a test fixture, or in a file the agent can read. Replace them with placeholders or test credentials before the agent sees the code, and keep production secrets in a vault the agent cannot reach. If a secret has already been pasted, rotate it.
Are enterprise versions of coding assistants safe?
Safer, not safe. An enterprise agreement with zero data retention removes the training and retention risk, and organisation policy controls help enforce tool choice. But the agent can still be prompt-injected through repository content, still generate insecure code, and still be weaponised by a malicious dependency.
How do I stop developers using unapproved AI tools?
Make the approved path the easy path: provide the approved tools preconfigured with enterprise sign-in, sandboxing and secrets scanning already switched on, then enforce it technically with network controls, device management and repository scanning.
AI coding assistants are not going away, and neither is the productivity they bring. The teams that keep the benefit are the ones that treat the prompt as a security boundary: decide what the agent may read, what it may run, and where data may leave, and enforce those decisions with tooling instead of good intentions. If your team is rolling out coding assistants and you want the controls set up properly, talk to us — we build custom software and AI integrations for clients. Our AI tools directory is a useful starting point if you are still evaluating which assistant to standardise on.