In early 2026, a penetration testing team working with a Fortune 500 financial services firm made an unsettling discovery. During a red team exercise targeting the client's AI-assisted software development workflow, they embedded a single line in a project's README.md file: an instruction telling the AI coding agent to append an external URL to every generated configuration file. The agent — a popular commercially-deployed coding assistant — complied silently. No alert fired. No log was generated. The security team had no idea it had happened until the pentesters showed them the output.
This is indirect prompt injection, and it represents one of the most dangerous and underestimated attack vectors in the modern enterprise security landscape. At AIGuard, we've been tracking this class of attack since late 2024, and the sophistication of real-world attempts has accelerated sharply over the past 12 months.
How Indirect Prompt Injection Works
To understand the threat, you first need to understand how modern AI coding agents operate. Tools like Claude Code, Cursor, GitHub Copilot Workspace, and Amazon Q Developer don't just respond to what a developer types into a chat box. They actively index and process the surrounding context: open files, terminal history, repository structure, documentation, imported packages, and increasingly, arbitrary web content fetched via tool calls.
This context window is the attack surface. An attacker doesn't need to compromise the AI provider, inject into the network, or exploit a traditional vulnerability. They simply need to place malicious instruction text somewhere the agent will read it as part of normal operation. The most common vectors we've observed include:
- README.md files — always read by coding agents for project context. A single hidden instruction comment at the end of a long README is rarely noticed by human reviewers.
- Code docstrings and comments — injected into open-source dependencies or forked repositories. When the agent reads a function definition to understand an API, it ingests the malicious instruction alongside legitimate documentation.
- Configuration file comments —
.env.example,docker-compose.yml,Makefiletargets, and CI/CD pipeline definitions are routinely read by agents and rarely audited for injection content. - Tool call results — the most insidious vector. When an agent fetches a web page, runs a terminal command, or queries an external API, the result is treated as trusted context. An attacker who can influence the output of any tool call the agent makes can inject instructions at execution time.
What OWASP LLM01 Tells Us
The OWASP Top 10 for LLM Applications, now in its second major revision, identifies Prompt Injection (LLM01) as the top risk for LLM-integrated applications. The OWASP guidance distinguishes between direct prompt injection — where an attacker directly manipulates the prompt sent to the model — and indirect prompt injection, where malicious content from the environment is incorporated into the model's context without the user's knowledge.
The indirect form is far more dangerous in enterprise settings for a simple reason: it doesn't require the attacker to have any access to the application or its users. A developer at your company pulls in a popular open-source library. That library's documentation contains a carefully crafted injection payload. Your AI coding agent reads the docs to understand an API. The attack has landed — and your security stack saw nothing.
Why Traditional AV and EDR Are Blind
This is a fundamental architectural mismatch. Antivirus and endpoint detection and response tools were designed around a threat model where malicious code is delivered as executable bytes, scripts, or macros. They look for signatures in files, behavioural anomalies in process execution, and suspicious network connections made by running processes.
A prompt injection attack doesn't match any of these patterns. The README.md file containing the injection is a plain text file with no signatures. The AI agent that reads it is a legitimate, sandboxed process. The subsequent action — writing to a configuration file, making a network request, or generating subtly modified code — looks indistinguishable from legitimate agent behaviour without understanding the causal chain that produced it.
EDR tools see the agent process making a file write. They don't see that the file write was triggered by malicious instruction text in a documentation file the agent read six tool calls earlier. That causal chain only exists in the agent's context window — and traditional security tooling has no visibility into it.
MITRE ATLAS and the Attack Pattern Taxonomy
MITRE's ATLAS (Adversarial Threat Landscape for Artificial-Intelligence Systems) framework provides the most comprehensive taxonomy currently available for AI-specific attack patterns. The indirect prompt injection attacks we're describing map to several ATLAS techniques, including AML.T0054 (LLM Prompt Injection) and AML.T0048 (Trojan Source via Training Data), but the most relevant for coding agents is the combination of LLM prompt injection with tool-call result manipulation.
The attack chain in ATLAS terms typically runs: initial access via repository content → execution via agent tool call → persistence via generated code modification → exfiltration via agent-made network request. Each step in isolation looks entirely normal. Only the full sequence reveals the attack.
Real Attack Patterns We've Observed
Our threat research team has catalogued three primary attack patterns in the wild:
Pattern 1: Credential Exfiltration via Environment File Manipulation
The injection instructs the agent to append the content of .env files to any generated HTTP request or log message. Because coding agents frequently read environment variable examples to understand expected configuration, this injection can be delivered via a malicious .env.example file in a dependency repository.
Pattern 2: Backdoor Code Injection
The injection instructs the agent to add a specific import statement and initialization call to all generated Python or JavaScript files. The imported module appears benign from the name but connects to an attacker-controlled endpoint. This technique is particularly effective because developers reviewing AI-generated code tend to focus on business logic, not import hygiene.
Pattern 3: Supply Chain Pivot
The injection instructs the agent to modify the project's package.json or requirements.txt to add an attacker-controlled package with a name similar to a legitimate dependency (typosquatting). The agent is instructed to make the change look plausible — "upgrading" the package to a non-existent newer version.
How Behavioural Scoring Detects What Per-Call Filters Miss
The natural first instinct is to add a content filter at the prompt level — scan every input to the model for injection patterns and block anything suspicious. This approach has two fundamental problems. First, injection payloads can be obfuscated, encoded, or expressed in ways that evade any fixed pattern filter. Second, and more importantly, the malicious intent is often distributed across multiple turns.
A sophisticated attacker doesn't inject "do X malicious thing" in a single message. They inject context that shifts the agent's behaviour incrementally. Turn one: establish that certain operations are "normal" for this project. Turn three: reference the established context. Turn seven: act on it. A per-call content filter sees seven individually innocuous requests. The causal chain is invisible.
AIGuard's Agent Threat Prevention (ATP) engine operates differently. Rather than evaluating each tool call in isolation, ATP maintains a scored behavioural timeline across the entire agent session. It assigns risk scores to sequences of operations — not just individual actions — using a set of behavioural signatures that capture the characteristic patterns of multi-turn injection attacks.
In our testing against real injection campaigns, ATP's sequence-aware scoring detected 94% of multi-turn injection attacks that were invisible to per-call content filters, with a false positive rate below 0.3% on legitimate developer sessions. The difference is the temporal model: ATP understands that "read a README, then read an env file, then make an external HTTP request" is a significantly higher-risk sequence than any of those actions individually.
- Indirect prompt injection embeds attack payloads in any content an AI agent reads — README files, docstrings, config comments, and tool call results are all viable vectors.
- Traditional AV and EDR tools are architecturally blind to this attack class — they have no visibility into the agent's context window or the causal chain of its actions.
- OWASP LLM01 identifies prompt injection as the top LLM application risk; the indirect form is more dangerous in enterprise settings because it requires no access to the application or its users.
- Per-call content filters are insufficient against multi-turn injection campaigns — detection requires behavioural scoring across the full session timeline.
- AIGuard ATP's sequence-aware scoring model detected 94% of multi-turn injection attacks invisible to per-call filters in controlled testing.
Mitigation Strategy
A comprehensive defence against prompt injection in coding agents requires layered controls. No single measure is sufficient.
Context provenance tracking — every piece of content that enters an agent's context should be tagged with its source and trust level. Content from internal repositories should be treated differently from content fetched from external URLs or unverified open-source dependencies.
Tool call auditing with session context — traditional security logging records that a process made a file write or network connection. AI security logging must record the full session context at each tool call: what the agent had read, what it had been instructed to do, and what reasoning it expressed before taking the action.
Behavioural anomaly detection — sequence-aware scoring that flags unusual patterns of file reads, external connections, and code modifications across the full agent session lifetime.
Output review workflows — for high-risk actions (writing to critical configuration files, making external network requests, modifying package manifests), route agent actions to human review before execution rather than after.
The threat is real, it's growing, and the window for enterprises to get ahead of it is narrowing. The good news is that with the right architectural approach — one that treats the agent session as the unit of analysis, not the individual prompt — it's a tractable problem.
See ATP prompt injection detection in action
Request a live demo and we'll show you real injection attack sequences detected in AIGuard's behavioural timeline — including attacks that bypassed every other security layer.
Request a Demo