Prompt Injection Risks in Agents With Real Filesystem Access
Agents with file access turn prompt injection into remote code execution.

In June 2025, security researchers disclosed EchoLeak, the first zero-click data exfiltration attack against Microsoft 365 Copilot. An attacker sent a single crafted email that was formatted to look like an ordinary business document but carried hidden prompt injections. The user never opened it. Copilot read the message during background processing, and a later, entirely unrelated query triggered the leak of sensitive data. No link was clicked, no attachment opened, no credential stolen. That sequence shows that once an agent has ambient access to a user's environment, exposure no longer requires any action by the user.
This is the shift that matters: agents with real filesystem access turn prompt injection from a content problem into an execution problem. A manipulated chatbot once produced a wrong or embarrassing sentence. A manipulated agent with file access and working credentials can read private data, write new files, exfiltrate records to an external endpoint, or delete something that took months to build, and it can do all of this using authority it already legitimately holds. Large language models cannot distinguish instructions from data, because both arrive as the same stream of natural-language tokens, and that inability produces the entire category of risk. OWASP's Top 10 for LLMs ranks prompt injection as the number-one risk to AI systems for exactly this reason, and researchers at Stanford's Center for Research on Foundation Models have noted that language models follow instructions because doing so is their core design objective, not because they have any concept of a trust boundary to defend.
The model stopped being the endpoint the moment agents began reading files, calling APIs, querying databases, browsing the web, and triggering real-world actions through tool integrations. Every one of those input channels can carry attacker-written instructions that the agent has no reliable way to reject. Between 2024 and 2026, this risk moved out of the research lab and into production, with confirmed findings against Slack AI, Microsoft 365 Copilot, Cursor, GitHub MCP, and other AI coding assistants. None of those incidents required breaking authentication. The agents did what they were designed to do, with access they were explicitly granted, acting on instructions they had no way of knowing were hostile.
How the attack chain works when an agent has real filesystem access

Filesystem-capable agents expose a four-stage attack chain, running from influence to authorization to execution to persistence, and the controls built for traditional application security were never designed to interrupt it at any of those four points. The chain begins with influence: a stored or indirect injection plants a malicious instruction well before the agent starts its work, sitting in long-term memory, in embeddings, in a knowledge-base entry, in an indexed document, or in an agent configuration file, waiting for the moment it gets retrieved. It hides in exactly those places until something calls it back into context.
Once that instruction surfaces, the agent moves into the authorization stage without needing any exploit at all, because it already holds the credentials, OAuth grants, API keys, or cloud roles required to act. No privilege escalation is necessary. The injection simply redirects what the agent does with access it was legitimately given, a pattern Microsoft's guidance on self-hosted agent runtimes describes directly: these runtimes ingest untrusted text and then act using the credentials assigned to them, with no distinction made between instructions the operator intended and instructions an attacker planted. From there the agent enters the execution stage, invoking shell commands, reading and writing files, calling APIs, or running browser sessions, all of it falling entirely inside its granted execution boundary. Prompt injection at this stage can bypass role-based access controls and trigger unauthorized API calls without breaking a single authentication mechanism, because the mechanism was never the target.
Five boundaries together define the total surface this chain can exploit: identity, execution, persistence, instruction, and supply-chain. If a security program hardens only the application layer and leaves those five boundaries unaddressed, it is defending a system that isn't the one under attack. The economics only make the problem harder to close: an attacker needs exactly one instruction that works, while defenders have to block every malicious instruction across every input the agent touches, including emails, documents, web pages, internal wikis, and the outputs of other agents.
The Semantic Kernel CVEs and Framework-Level Injection Risk
A pair of CVEs disclosed in Semantic Kernel, an open-source framework used to orchestrate AI agents, manage plugins, and chain workflows, gives the clearest proof yet that prompt injection has become an execution risk at the framework layer. Microsoft's internal AI red team identified both vulnerabilities and disclosed them through the Microsoft Security Response Center.
The more severe of the two, CVE-2026-26030, lived in the In-Memory Vector Store's default filter function, which used Python's eval() on input controlled by the AI model with insufficient sanitization in place. An AST-based blocklist had been built specifically to prevent this kind of abuse, but it could be bypassed. By closing a quote character and appending additional Python logic, an attacker could turn a routine data lookup, something as mundane as "Find hotels in Paris," into an executable payload. A single prompt triggered host-level remote code execution, with no browser exploit, no malicious attachment, and no memory corruption bug anywhere in the chain. The framework's developers had anticipated the RCE risk and built a validator that parsed the filter string into an Abstract Syntax Tree before execution, and researchers still found a way through it. That outcome illustrates a broader truth about blocklist-based defenses: they fail against attackers willing to adapt, because the framework is doing what it was built to do. The vulnerability lives in how it trusts data that has already been parsed, not in any malfunction of the parsing itself.
Frameworks such as Semantic Kernel, LangChain, and CrewAI function as the operating system for AI agents, so a single vulnerability in how any of them maps model output to system tools carries systemic risk across every application built on that foundation. Both CVEs have since been patched, one in the.NET SDK and one in the Python SDK, in subsequent Semantic Kernel releases. Agents still running older versions of either SDK remain exposed to the exact exploit path described above.
MCP as a new injection surface: tool definitions, tool output, and cross-server trust
A standardized way for models to connect to external tools has opened up two injection surfaces that behave nothing like classic prompt injection and require defenses built specifically for them. The first is tool output. Whatever string an MCP server returns gets placed directly into the model's context window, where it sits alongside the system prompt and the conversation history with no separation between them. The attention mechanism that processes that context has no way to tell "this text came from a trusted tool" apart from "this text came from an attacker-controlled document," because to the model, both are simply tokens.
The second surface is tool poisoning, and it is in some ways more troubling because of when it fires. A malicious MCP server can embed attacker instructions directly in its tool description field, and the model reads that text the moment it loads the server. Those instructions reach the model before the user has called a single tool, so the attack executes at configuration time rather than at runtime, ahead of anything the user believes they are doing. Cross-server interactions compound both problems. When one MCP server's output flows into another agent's context, the only thing enforcing access boundaries is the agent's own internal reasoning, the very reasoning that injection is designed to subvert, rather than any explicit policy layer sitting outside the model's control.
Benchmarks built specifically for this threat class now exist. MCP-SafetyBench, presented at ICLR 2026, and MCPTox, presented at AAAI 2026, give practitioners measurable baselines for MCP-specific injection and tool-poisoning risk for the first time. So the research community has stopped treating MCP injection as a hypothetical and now treats it as a distinct, documented threat class with its own evaluation methodology.
Isolation Without Privilege Scoping
The strongest objection to treating micro-VM isolation as a complete solution turns out to be correct: an injected instruction that operates entirely within an agent's legitimately granted scope never needs to escape the sandbox to succeed. Isolation stops a compromised process from reaching the host or from reaching other workloads. It does nothing to stop a compromised process from doing damage with the permissions it was handed on purpose.
Consider an agent authorized to read a directory and call an external API, a grant of access that sounds reasonable and limited on paper. An injected instruction can direct that same agent to read every file in the directory and POST the contents to an attacker-controlled endpoint, and the entire operation happens inside the sandbox, using only permissions the agent was designed to hold from the start. NIST's description of this pattern, which it calls agent hijacking, captures the mechanism precisely: an attacker inserts malicious instructions into data the agent ingests, and the agent takes unintended, harmful action as a result, with no security boundary ever actually broken.
Sandboxing, then, is necessary but not sufficient on its own. Policy-as-code, least-privilege credential injection, and egress filtering have to work as co-equal requirements, not optional extras, because single-layer defenses do not hold up against adaptive attackers who can route around whichever single control a team happens to have deployed. The architectural implication follows directly: teams need four controls operating together, isolation boundaries, privilege scoping, policy-as-code, and runtime monitoring, and a gap in any one of the four makes the remaining three weaker than they would be on their own.
The four architectural controls that meaningfully contain injection risk
Meaningful containment comes from four controls working in concert: isolation boundaries, least-privilege credential scoping, policy-as-code, and egress filtering. Each one closes a specific gap that the other three leave open, and none of the four substitutes for any of the others.
Isolation boundaries form the first layer. At what practitioners describe as isolation Level 3, micro-VMs such as Firecracker, Kata Containers, and libkrun give each workload its own kernel running on hardware virtualization, so a kernel exploit inside one VM has no path to the host or to any other VM running alongside it. Firecracker in particular boots in under 125 milliseconds with under 5MiB of memory overhead, which makes per-agent VM isolation operationally realistic even for interactive workloads that can't tolerate slow startup. Managed Firecracker infrastructure became a commodity service when Vercel Sandbox reached general availability in January 2026, and that removed the months-long path to production that had kept micro-VM adoption out of reach for most teams. The ephemeral-per-run pattern, one disposable environment created for each execution and discarded afterward, means nothing carries over between runs: no cached credential, no leftover file, no state one run can pass to the next. So a compromised run becomes a compromised throwaway, not a compromised system.
Least-privilege credential scoping forms the second layer, and it works by treating the agent itself as an untrusted intermediary. So you restrict API permissions and use scoped credentials instead of granting an agent ambient access to everything it might conceivably need later. The identity boundary, meaning which tokens, API keys, OAuth grants, and cloud roles an agent is allowed to use, is the single most direct lever available for limiting what an injected instruction can accomplish. Narrow that boundary and the blast radius of a successful injection shrinks in proportion, every time.
Policy-as-code forms the third layer, and what matters is where enforcement happens. It moves the enforcement point out of the model's context window, which is inherently susceptible to injection, into a deterministic layer that sits outside the model's reach and that no amount of clever language can override. The same principle applies to cross-server MCP interactions: they should be mediated through an explicit policy layer rather than left to the agent's internal reasoning, because that reasoning is precisely what an attacker is trying to manipulate.
Egress filtering and runtime monitoring form the fourth layer. Output filtering checks AI responses before they are executed or displayed, so it catches data-exfiltration attempts that isolation alone cannot stop, because those attempts typically travel over legitimate outbound channels that look no different from ordinary traffic. A real defense requires three layers operating together, architectural prevention, runtime detection, and governance, and monitoring does not replace the architectural controls that come before it. It is, however, the only layer positioned to catch what slips past every other control in the chain. Joint guidance issued by the Five Eyes alliance in May 2026 put the governance obligation in direct terms: strong governance, explicit accountability, rigorous monitoring, and human oversight are not optional safeguards but essential prerequisites, and organizations should prioritize resilience, reversibility, and risk containment ahead of efficiency gains. Isolation, privilege scoping, policy-as-code, and egress filtering each address a failure mode the other three cannot reach on their own, and an architecture missing any one of them leaves exactly the kind of gap an injected instruction is built to find.

Sources
- Prompt Injection Attack Explained: AI Cybersecurity Threat (2026 Guide)
- When prompts become shells: RCE vulnerabilities in AI agent frameworks
- The Landscape of Prompt Injection Threats in LLM Agents: From Taxonomy to Analysis
- Don't Let AI Agents YOLO Your Files: Information and Control in Agent-Native Filesystems
- Self-State Attacks on Self-Hosted AI Agents: How Far Can OS Defenses Go?
- Agent Security is a Systems Problem
- The Framing Gap: Indirect Prompt-Injection Exfiltration Defeats Surface-Level Defenses in Tool-Using Agents
- Prompt Injection in MCP: Tool Poisoning and Blast Radius


