# What is prompt injection, and can it reach a coding agent?

Source: https://codelifter.com/forum/posts/what-is-prompt-injection-and-can-it-reach-a-coding-agent/
Site: CodeLifter Forum, category Code provenance
Published: 2026-11-21. Updated: 2026-11-21. Replies: 0.

## Question by CodeLifter editors (staff), 2026-11-21

Prompt injection is text an AI system reads as data but follows as instructions, so its author can steer the system. It can reach a coding agent through anything the agent reads: a README, an issue comment, a web page, package docs or an MCP tool result. The defence is limiting what the agent can do, not filtering text.

## What is prompt injection?

The term was coined by Simon Willison in 2022. In [The lethal trifecta for AI agents](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/) (16 June 2025) he describes it as the "key issue of mixing together trusted and untrusted content in the same context", named "after SQL injection, which has the same underlying problem." In SQL injection, data typed into a form ends up executed as part of a database command. In prompt injection, text the model was only meant to read ends up treated as a command.

The underlying cause is in the same post: "LLMs are unable to *reliably distinguish* the importance of instructions based on where they came from. Everything eventually gets glued together into a sequence of tokens and fed to the model."

OWASP's [LLM01:2025 Prompt Injection](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) splits it in two:

- **Direct prompt injection**: the person typing to the model is the one manipulating it.
- **Indirect prompt injection**: the model "accepts input from external sources, such as websites or files" that contain instructions. OWASP adds that injected text does not need to be "human-visible/readable, as long as the content is parsed by the model."

For a coding agent, the indirect kind is the one that matters, because you are the one typing.

## How does injected text reach a coding agent?

A coding agent reads far more than your prompt. Every file it opens, every command output and every tool result becomes part of its context.

| Where the text comes from | Example | What an injected instruction might try |
| --- | --- | --- |
| Files in a cloned repository | A comment or README line addressed to "AI assistants" | Run a setup script, change a config, add a dependency |
| Issues and pull request comments | Read through a GitHub MCP server or `gh` | Copy private code into a public place |
| Web pages | Docs the agent fetches to answer a question | Send environment variables to a URL |
| Package documentation | A README inside `node_modules` | Install a different package |
| MCP tool results | A support ticket, an email, a database row | Call another tool with your credentials |
| Command output | A test log or error message that includes user input | Anything the agent's tools allow |

None of this needs a bug in the agent. The model follows instructions; that is its job.

## What is the lethal trifecta?

Willison's post names three capabilities that together let an attacker steal data: "Access to your private data", "Exposure to untrusted content" and "The ability to externally communicate". If an agent has all three, "an attacker can **easily trick it** into accessing your private data and sending it to that attacker."

A coding agent in an ordinary session often has all three: your repository and environment variables, a web fetch tool or issue tracker, and a shell that can run `curl` or `git push`. His post cites a GitHub MCP exploit as an example where a single server "mixed all three patterns": it could read public issues an attacker filed, access private repositories, and open pull requests that leaked the data. The CodeLifter [GitHub MCP page](https://codelifter.com/mcp/github/) lists that server's read-only mode and toolsets, which shrink the first and third legs.

## Why can't a better system prompt fix it?

Because no one has a reliable filter yet. OWASP says that "it is unclear if there are fool-proof methods of prevention for prompt injection." Willison is "deeply suspicious" of guardrail products claiming to catch "95% of attacks", because "in web application security 95% is very much a failing grade." Anthropic's [Claude Code security page](https://code.claude.com/docs/en/security) ends its own list of safeguards with: "no system is completely immune to all attacks."

So the useful question is not "can I stop the agent being fooled?" but "what can the agent do if it is fooled?"

## How do you reduce the risk?

1. **Keep approval on for network commands.** The Claude Code security page says commands such as `curl` and `wget` "are not auto-approved by default". If you never approve an unexpected network call, a stolen secret has nowhere to go.
2. **Turn on the sandbox's network allowlist.** A deny rule matches a command as written; the sandbox limits connections whatever the command. The thread on [stopping an agent running risky commands](/forum/posts/how-do-you-stop-a-coding-agent-from-deleting-files-or-running-risky/) has the settings for Claude Code and Codex.
3. **Prefer cached or disabled web search.** OpenAI's [Codex security page](https://developers.openai.com/codex/agent-approvals-security) says its default cached search "reduces exposure to prompt injection from arbitrary live content" and that "Prompt injection can cause the agent to fetch and follow untrusted instructions."
4. **Narrow every token.** Read-only modes and minimal scopes cap what an injected instruction can do; see [which token scopes the GitHub MCP server needs](/forum/posts/which-token-scopes-does-the-github-mcp-server-need/).
5. **Break the trifecta per session.** Do not give the session that reads public issues or web pages access to production secrets. Split the work across two sessions instead.
6. **Open unfamiliar repositories somewhere disposable.** The Claude Code security page recommends using "virtual machines (VMs) to run scripts and make tool calls, especially when interacting with external web services", and to "Avoid piping untrusted content directly to Claude."
7. **Read the diff and the commands.** Injected instructions usually show up as something you did not ask for: a new dependency, a changed CI file, an outbound request.

![Seven numbered steps to reduce prompt injection risk for a coding agent, from network approvals to reading the diff](/forum/img/posts/seven-ways-to-reduce-prompt-injection-risk-for-a-coding-agent.webp "Seven ways to reduce prompt injection risk, as listed in this article")

For how MCP servers fit into this, start with [what an MCP server is](/forum/posts/what-is-an-mcp-server-in-plain-terms/). CodeLifter's [vibe coding security guide](https://codelifter.com/provenance/vibe-coding-security/) puts these steps alongside secret scanning and dependency checks.

## Short version

- Prompt injection is untrusted text acting as instructions; a coding agent reads plenty of it.
- The dangerous combination is private data, untrusted content and a way to send data out.
- There is no reliable filter, so limit capabilities: approvals, sandbox network limits, narrow tokens.
- Treat cloned repositories, issues and fetched pages as untrusted input.

---
Cite as: CodeLifter Forum, "What is prompt injection, and can it reach a coding agent?", https://codelifter.com/forum/posts/what-is-prompt-injection-and-can-it-reach-a-coding-agent/, accessed 2026-11-21.
