Get the free coreGet core

AI coding agent security: the real risks and what limits the damage

Updated 5 min readSection 03 / Is it safe?
SHORT ANSWER

A coding agent runs with your permissions and reads text that nobody has vetted. It can edit files, run commands and call tools, and it reads content such as issues, web pages and README files that anyone could have written. Five risks follow: the agent misuses a tool it was given, sensitive data leaks out, it acts without anyone checking, something it depends on is compromised, and hidden instructions in text it reads change what it does. What helps most is giving it as little access as possible and requiring your approval for anything you cannot undo.

This page is about AI coding agent security on your own machine, for tools such as Claude Code, Cursor and Codex. For the wider topic across all kinds of agents, start at AI agent security.

01What a coding agent does, and why that raises the stakes

OWASP defines AI agents as autonomous systems built on large language models. They can reason, plan, use tools, keep memory and take actions to accomplish goals. A coding agent applies this to your repository. It reads files, writes code, runs terminal commands and calls helper programs. An MCP server is one such helper: a small program that gives the agent extra tools, such as access to GitHub.

AWS describes the core problem this way: coding agents optimize for task completion at machine speed, with no understanding of your organization's risk. The permission settings that slow the agent down are covered in AI agent permissions.

02The five risks, and where each one showed up

RiskIn plain wordsCase below
Tool abuseThe agent uses a tool that allows more than it should, and does something nobody intendedClaude Code allowlist
Data exfiltrationSensitive data leaves through tool calls, API requests or the agent's outputGitHub MCP
Excessive autonomyThe agent takes a high-impact action without a human checking itReplit database
Supply chainA third-party tool, API or data source the agent uses is compromisedAmazon Q, s1ngularity
Prompt injectionHidden instructions in text the agent reads change what it doesRules File Backdoor

OWASP's list for language-model applications names the same families: prompt injection, sensitive information disclosure and supply chain. Its separate Top 10 for Agentic Applications was published on December 9, 2025.

03Six cases that were exploited or reported

A CVE is the public ID number of a known flaw. An allowlist is a list of commands the tool may run without asking.

Claude Code allowlist (CVE-2025-55284). The allowlist of safe commands was so broad that a file could be read and its contents sent over the network without a confirmation prompt.

GitHub MCP. A malicious GitHub issue could hijack an agent that used the GitHub MCP server and push it to leak private repository data. The flaw was in the agent system's design, not in the server's code, so it affects any agent that uses the GitHub MCP server.

Replit database. An AI model on Replit deleted a database holding 1,206 executive records, although the user had asked for a code freeze, a period when nothing should change.

Amazon Q Developer. Version 1.84.0 of the VS Code extension shipped malicious code after an over-scoped GitHub token in the build setup let an attacker commit to the repository (CVE-2025-8217). The code did not run, because of a syntax error. AWS removed the version and told customers to update to 1.85.0.

Rules File Backdoor. Researchers showed that hidden malicious instructions can sit in the configuration files that Cursor and GitHub Copilot read. They were written with invisible Unicode characters such as zero-width joiners, which take no space on screen.

s1ngularity. Malicious versions of a popular package published on npm, the JavaScript package registry, searched for wallets, keystores, .env files and SSH keys. They also prompted installed AI command-line tools with flags that skip approvals, and in hundreds of cases the tool carried out the request. The full story is on the dangerously-skip-permissions page.

04How secure is the code the agent writes

The code it writes is a second part of AI coding agent security: a second place where things can go wrong. Veracode, a security company, found that roughly 44% of AI code generation tasks in its 2026 tests introduced a risky vulnerability, and the average security pass rate was 56%. Agents may also recommend deprecated packages, versions with known flaws and package names that do not exist. An attacker can register such a name, which is called slopsquatting. The studies behind these numbers are on the AI-generated code vulnerabilities page.

05Six steps for AI coding agent security

Each step below is something one developer can do.

  1. Give the minimum tools. Grant the agent only the tools its task needs. When it works with GitHub, limit its access to the repositories it has to work in.
  2. Treat everything it reads as untrusted. User messages, retrieved documents, API responses and emails all count. Do not point an agent that holds your keys at issues or pages you have not looked at.
  3. Keep approval on for irreversible actions. Deleting, pushing and installing should wait for your yes. The approval must be enforced by the tool itself, outside the agent's context, not by a sentence in the prompt. Do not turn approvals off with flags like the one on the dangerously-skip-permissions page.
  4. Protect the main branch. Require a pull request before anything reaches it, and run the agent in a sandbox, a fenced area, that cannot push to protected branches.
  5. Connect only the MCP servers you need. Give each one the fewest tools and resources it can work with. See MCP security.
  6. Run it in a fence. A sandbox limits what a command can touch; see AI agent sandbox.

06What these steps do not solve

A language model cannot reliably separate instructions from data in a single context window. That is why prompt injection stays open: it is unclear whether fool-proof prevention exists. The practical answer is to restrict privileges and add human approval for high-impact steps. Read the prompt injection page for how the attack works.

Controls also say little about what already happened. A permission prompt shows what the agent asks to do next, not what ran an hour ago. If you want a second look at the Mac itself after Claude Code, Cursor, Codex or MCP servers have worked there, the free, open-source core of Artificial Immunity checks it for signs of attack and reports what it finds when you or your agent ask.

07What to remember

For AI coding agent security, remember one thing: an agent with your login believes what it reads. Limit its tools, keep your approval on anything irreversible, protect the main branch and review the code it writes. These steps reduce the damage of the five risks above, though none of them removes prompt injection entirely.

FAQ

Are AI agents a security risk?

Yes, because they act with your permissions. OWASP lists tool abuse, data leaving through the agent's tool calls, too much autonomy and supply chain attacks among the key risks. OWASP's advice is to grant the agent only the minimum tools its task needs.

How secure is the AI code?

Less than it looks. In Veracode's 2026 tests, roughly 44% of AI code generation tasks introduced a risky vulnerability. Working code is not trustworthy code by default, so security depends on verification.

How do I secure access for AI agents?

Give each agent the minimum tools for its task. Require explicit approval for high-impact or irreversible actions, and enforce that approval outside the agent's context. Limit access to only the repositories it needs.

What does a coding agent do?

It is an AI system that can reason, plan, use tools, keep memory and take actions to reach a goal. For code that means reading your repository, editing files and running commands, which is why its permissions matter.

Are AI agents good for coding?

Yes for speed, with limits. Modern models write syntactically correct code nearly every time, but the security pass rate in Veracode's tests stayed at 56%. Use them with review and with limited access.

Can prompt injection hijack a coding agent?

Yes. A malicious GitHub issue was enough to hijack an agent that used the GitHub MCP server and make it leak data from private repositories. It is unclear whether fool-proof prevention exists.

Sources

  1. OWASP AI Agent Security Cheat Sheet
  2. AWS Security Blog: control framework for AI coding agents
  3. AWS security bulletin AWS-2025-015
  4. Pillar Security: Rules File Backdoor
  5. Invariant Labs: GitHub MCP vulnerability
  6. OWASP Top 10 for LLM applications
  7. OWASP Top 10 for Agentic Applications 2026
  8. Veracode 2026 GenAI Code Security Report
  9. Artificial Immunity
Running coding agents on your Mac? Artificial Immunity watches the Mac where your agents work.Get the free core