Blog / 31 October 2026

Deep dive · 31 October 2026 · 7 min read

Prompt injection in coding agents: repos, issues, and web pages as attack surface

Every file, issue, web page and tool result a coding agent reads is a place an attacker can leave instructions, and current defences do not reliably tell those instructions apart from your own. The workable approach is to assume an injection will succeed and design the agent's environment so the injected instruction cannot reach your keys, your other repositories or the open internet.

prompt injection coding agentgithub issue prompt injectionreadme prompt injectionindirect prompt injectionis prompt injection solvable

01Where does prompt injection reach a coding agent?

Indirect prompt injection means the instructions arrive in content the agent retrieves rather than in what the user typed. For a chatbot that might be one web page. For a coding agent it is most of the job: the agent's work is reading text written by other people and acting on it with a shell, a file system, a network connection and often a set of tool servers. OWASP keeps prompt injection first in its 2026 Top 10 for LLM applications, and its Top 10 for Agentic Applications lists the agent version as ASI01, Agent Goal Hijack.

It helps to list the surfaces concretely, because each one arrives through a different door and is trusted for a different reason.

  • The repository: README files, code comments, test fixtures, and instruction files such as AGENTS.md or CLAUDE.md that agents load automatically.
  • Issues, pull requests and review comments, often written by anyone with a GitHub account.
  • Web pages and documentation the agent fetches while researching an error or an API.
  • Dependencies: package READMEs, install scripts and error messages printed by third-party code.
  • Tool output and tool descriptions from MCP servers, which the model reads as text.

02How does a GitHub issue turn into a data leak?

Invariant Labs published a clear example in May 2025. An attacker opened an issue containing a prompt injection on a public repository. The repository's owner, who also had private repositories, asked an agent connected through the GitHub MCP server to look at the open issues. The agent read the issue, followed it, pulled information from a private repository into its context and published it in a new pull request on the public repository, where the attacker could read it.

Three details matter. The tools were not compromised; Invariant stressed that the problem arises with fully trusted tools. The model was a current frontier model, which Invariant said was still open to relatively simple injections. And the owner's token reached every repository, public and private, so the agent could carry data across a boundary the person would never have crossed by hand. Invariant's conclusion was that security has to be enforced at the system level, for example by limiting a session to one repository, rather than left to the model.

03Is prompt injection solvable?

Not with filters alone, on current evidence. In October 2025 Milad Nasr, Nicholas Carlini, Florian Tramèr and colleagues published The Attacker Moves Second. They took 12 recent defences against jailbreaks and prompt injection, most of which had reported near-zero attack success, and bypassed them with adaptive attacks, with success above 90% for most. Their argument is about method: a defence tested against a fixed list of attack strings tells you little about an attacker who adapts to that defence.

The more promising results change the architecture instead of the model. CaMeL, described by Edoardo Debenedetti and colleagues in 2025, derives the program's control flow from the trusted user request, so data retrieved later cannot change which actions run, and it attaches capabilities to data to stop private values flowing to unauthorised tools. On the AgentDojo benchmark it solved 77% of tasks with provable security, against 84% for an undefended system. A companion paper, Design Patterns for Securing LLM Agents against Prompt Injections, catalogues similar patterns and their trade-offs between usefulness and security.

For a general-purpose coding agent with a shell, those patterns are hard to apply in full, because the task itself is open-ended. What carries over is the principle: decide in advance, outside the model, what the agent is able to do, so it does not matter which text persuaded it.

04How do you design for an injection that succeeds?

Ask three questions about the agent's environment as if the attacker is already giving the orders. What can it read? What can it send, and to where? What can it change that is hard to undo? Each answer should be as small as the task allows, and each limit should be enforced somewhere the agent cannot edit.

Our earlier post on egress brokers covers the key question in depth: if the real API key is never in the agent's environment, no instruction can read it out. The same thinking applies to everything else the agent could carry. A token that covers one repository cannot leak another. A machine that sees one folder cannot read your SSH keys. A network closed to an allow-list gives a stolen secret nowhere obvious to go.

  • Read: one workspace folder, no home directory, no Git credential helper or SSH agent forwarded in.
  • Send: network closed except named hosts; keys added outside the sandbox; no broad upload destinations.
  • Credentials: a token scoped to the one repository or project the task needs.
  • Change: a checkpoint or snapshot before risky steps, so damage inside the machine can be rolled back.

05Where does human approval help, and where does it fail?

Approval prompts are a real control, and OWASP lists human approval for high-impact actions among its mitigations. They are weakest when they are frequent. Invariant noted that many users choose Always Allow for tool calls, which is how its GitHub demonstration ran without review. OWASP's agentic list names the other failure as ASI09, Human-Agent Trust Exploitation: confident, polished explanations that lead people to approve harmful actions.

So spend approvals where they count. Let the sandbox absorb routine commands without asking, and hold the few actions that cross a boundary: pushing, merging, deploying, sending, paying, or reaching a host that is not on the list. An approval that comes up rarely, names the exact action and cannot be granted by the agent itself is worth far more than one that appears for every ls.

Takeaways

  1. For a coding agent, READMEs, issues, web pages, dependencies and tool output are all ways in for instructions.
  2. Invariant Labs showed one public GitHub issue making an agent leak private repository data through a pull request.
  3. Adaptive attacks bypassed 12 published prompt-injection defences with over 90% success for most, so filters are not a boundary.
  4. Architectural designs such as CaMeL restrict what untrusted data can do instead of trying to detect it.
  5. Assume the injection succeeds: limit what the agent can read, send and change, and enforce it outside the agent.
  6. Keep human approvals rare and aimed at actions that cross a boundary, or they turn into Always Allow.

Where kosa8 fits

kosa8 does not detect prompt injection; it limits what an injected agent can reach. kosa8 agent run starts the agent in its own microVM that sees one workspace folder, not your home directory or SSH keys. For the brokered kits the API key stays on the host and the sandbox holds only a placeholder, and the network is closed except for the broker and an allow-list you write, enforced on the host where the agent cannot change it. Refused and brokered requests go to a hash-chained audit log. A checkpoint saves the whole running machine so changes inside it can be rewound, and risky actions can wait for one or two named human approvers. The kosa8 docs state the gap plainly: the agent can still send anything it can read to a host you allowed, and text a tool returns is not searched for hidden instructions.

Check yourself · +100 XP

In Invariant Labs' GitHub MCP demonstration, what made it possible for a public issue to leak private repository data?

Questions people ask

Can a GitHub issue or README hijack an AI coding agent?

Yes. Any text the agent reads can contain instructions it may follow. Invariant Labs showed a public GitHub issue making an agent leak private repository data, and instruction files such as AGENTS.md are loaded automatically.

Is prompt injection solvable?

Not reliably by detection today: a 2025 study bypassed 12 published defences with adaptive attacks. Designs that restrict what untrusted data can do, plus least privilege and network limits enforced outside the agent, are the dependable part.

What is the most important control against prompt injection in coding agents?

Limit what a hijacked agent can reach: one workspace folder, no secrets inside its environment, a network closed except for named hosts, and narrowly scoped tokens. Then an injection that succeeds has little to take and nowhere to send it.

Sources

  1. GitHub MCP exploited: accessing private repositories via MCP — Invariant Labs
  2. The Attacker Moves Second: Stronger Adaptive Attacks Bypass Defenses against LLM Jailbreaks and Prompt Injections — Nasr et al., arXiv
  3. Defeating Prompt Injections by Design — Debenedetti et al., arXiv
  4. Design Patterns for Securing LLM Agents against Prompt Injections — Beurer-Kellner et al., arXiv
  5. LLM03:2026 Excessive Agency — OWASP GenAI Security Project on GitHub
  6. OWASP Top 10 for Agentic Applications — OWASP Gen AI Security Project
  7. Prompt injection meets your API keys: why the key should never enter the sandbox — kosa8 blog
  8. How do I restrict an AI agent's network access to an allow-list? — kosa8 guides
  9. How do I require human approval before an AI agent runs a risky command? — kosa8 guides

Written by the kosa8 team. Every kosa8 command was checked against the CLI, and every claim about another product links to that product's own documentation. Spotted a mistake? Tell us.

Try it on your own machine

Give your next agent its own sealed machine.

One line installs kosa8 on your own machine. Every feature, plans from $29 a month.