title: "When Prompts Become Shells: Microsoft Semantic Kernel RCE via Prompt Injection"

date: "2026-05-14"

category: "security"

tags: ["AI security", "prompt injection", "RCE", "Semantic Kernel", "CVE", "agent frameworks"]

sources:

When Prompts Become Shells: Microsoft Semantic Kernel RCE via Prompt Injection

Disclosed: May 7, 2026

On May 7, 2026, Microsoft's Security Response Center published a research blog titled "When prompts become shells." The post detailed two critical vulnerabilities in Semantic Kernel, Microsoft's open-source AI agent framework with over 27,000 GitHub stars. The flaws, CVE-2026-25592 and CVE-2026-26030, both carry a CVSS score of 9.9. They prove that prompt injection is no longer just a content problem. It is now a code execution primitive.

This article breaks down how both vulnerabilities work, why they matter beyond Semantic Kernel, and what defenders should do about it.


What Changed on May 7

For years, prompt injection was treated as a chatbot safety issue. A malicious prompt might trick a model into generating offensive text, leaking a system prompt, or bypassing content filters. The damage was assumed to stop at text.

That assumption collapsed in May 2026.

Semantic Kernel is not a chatbot. It is an operating system layer for AI agents. It handles tool registration, model orchestration, plugin lifecycle, and the translation layer between LLM output and actual function calls. When a vulnerability exists at that layer, it does not just affect one application. It affects every application built on the framework, no matter the model or cloud provider.

Microsoft's disclosure included proof-of-concept details, a capture-the-flag challenge, and a clear warning: more framework disclosures are coming.


CVE-2026-26030: eval() in the In-Memory Vector Store

The Setup

Imagine a hotel-finder agent. A user types, "Find hotels in Paris." The agent calls a search plugin backed by an in-memory vector collection. The plugin first narrows the dataset with a deterministic filter, then computes vector similarity.

The filter function is built through string interpolation:

new_filter = f"lambda x: x.city == '{user_supplied_value}'"
result = eval(new_filter, {"__builtins__": {}}, {})

The framework developers saw the RCE risk. They added an AST blocklist to reject dangerous identifiers like eval, exec, open, and import. They stripped builtins to deny access to built-in functions. This is textbook defense-in-depth. In theory, it works.

The Bypass

Blocklists in dynamic languages are fragile. The researchers found four ways the safeguards failed:

1. Missing dangerous names

The payload used name, load_module, system, and BuiltinImporter. None were on the blocklist.

2. Structural check passed

The payload was wrapped in a valid lambda. The isinstance(tree.body, ast.Lambda) check passed because the entire payload lived inside a lambda body.

3. Empty builtins was irrelevant

The payload never called built-ins directly. It started with tuple(), then traversed Python's type hierarchy to reach BuiltinImporter and load os.system.

4. No ast.Subscript checking

The validator only checked ast.Name and ast.Attribute nodes. An attacker could bypass name blocks with bracket notation like obj['class'].

The Exploit

A single crafted prompt manipulated the agent into calling search_hotels with a malicious city parameter. The lambda became:

lambda x: x.city == '' or <payload> or ''

The payload escaped the template string, climbed Python's class hierarchy to BuiltinImporter, loaded os, and called system() to launch calc.exe on the host.

No browser exploit. No malicious attachment. No memory corruption. Just a prompt and a tool.

The Fix

Microsoft rewrote the filter path to avoid eval() entirely. The new implementation uses four layers of protection:

  • AST node-type allowlist: Only safe constructs like comparisons, booleans, and arithmetic are permitted.
  • Function call allowlist: Even allowed call nodes are restricted to a known-safe set.
  • Dangerous attribute blocklist: Class hierarchy traversal is blocked.
  • Name node restriction: Only the lambda parameter is allowed as a bare identifier.

Upgrade semantic-kernel Python to version 1.39.4 or higher.


CVE-2026-25592: The [KernelFunction] Attribute as a Footgun

The Setup

Semantic Kernel includes SessionsPythonPlugin, which lets agents execute Python code inside Azure Container Apps dynamic sessions. The security model relies on container isolation: code runs in the sandbox, not the host.

Helper functions like UploadFile and DownloadFile bridge the boundary. They run on the host side to transfer files in and out.

The Bug

In the .NET SDK, DownloadFileAsync was accidentally decorated with [KernelFunction]. This advertised it to the LLM as a callable tool. The signature:

[KernelFunction]
public async Task DownloadFileAsync(string remoteUrl, string localFilePath)
{
    var content = await _httpClient.GetByteArrayAsync(remoteUrl);
    await File.WriteAllBytesAsync(localFilePath, content);
}

No path validation. No directory restriction. No canonicalization. The localFilePath parameter was fully AI-controlled.

The Attack Chain

A crafted prompt instructs the agent in two steps:

Step 1: Build the payload in the sandbox

The agent uses ExecuteCode to write a malicious script inside the isolated container.

Step 2: Escape the sandbox

The agent calls DownloadFileAsync to fetch the script and save it to C:\Windows\Start Menu\Programs\Startup\. On the next login, the script runs.

The result: full host compromise from a single prompt.

The Fix

Microsoft removed the [KernelFunction] attribute from DownloadFileAsync, making it invisible to the AI model. For programmatic callers, they added path validation with Path.GetFullPath() and directory allowlist matching.

Upgrade Microsoft.SemanticKernel.Plugins.Core to version 1.71.0 or higher.


Why This Is a Framework Problem, Not a Bug Problem

Microsoft stated it directly: "A single vulnerability in how these frameworks map AI model outputs to system tools carries systemic risk."

The attack surface is not the LLM. The model behaves exactly as designed. It parses language and emits tool-call schemas. The attack surface is the tool registry: the layer that maps LLM-generated strings to real functions with real filesystem access, real network access, and real process execution.

Every major agent framework has one:

  • LangChain: @tool decorator
  • CrewAI: tools=[...] passed at agent instantiation
  • AutoGen: registerforexecution / FunctionTool
  • Semantic Kernel: [KernelFunction] attribute

If any registered function wraps eval(), exec(), raw file writes, subprocess calls, or unsandboxed network downloads, prompt injection is no longer a content moderation issue. It is a scope definition problem: what should the LLM be allowed to touch, and who enforces that?

Both CVEs show the enforcement was assumed, not implemented.


Indicators of Exploitation

CVE-2026-26030:

  • Subprocess spawns (calc.exe, cmd.exe, powershell.exe) from Python processes hosting Semantic Kernel agents
  • AST tracebacks in agent logs followed by unexpected network connections
  • Anomalous process activity after eval-related log entries

CVE-2026-25592:

  • Files written to startup folders by .NET agent processes:
  • Windows: C:\Windows\Start Menu\Programs\Startup\
  • Linux: ~/.config/autostart/
  • macOS: ~/Library/LaunchAgents/
  • HTTP GET requests from agent processes to unusual external domains for binary content
  • DownloadFileAsync telemetry with external URLs and sensitive localFilePath values

Defender Playbook

Immediate (Patch Within 48 Hours)

  • Upgrade semantic-kernel Python to >= 1.39.4
  • Upgrade Microsoft.SemanticKernel.Plugins.Core .NET to >= 1.71.0
  • Inventory every [KernelFunction]-decorated or @tool-decorated method in your agent code
  • Review each for filesystem access, subprocess execution, or network I/O

Detection

  • Add EDR rules for child processes spawned by Python / .NET agent workloads
  • Alert on file writes to startup / autostart paths by agent-hosting processes
  • Alert on HTTP downloads of binary content from agent processes to non-approved domains
  • Review agent telemetry for DownloadFileAsync with external URLs

Architecture

  • Implement a tool allowlist at the framework layer
  • Run agent processes under dedicated low-privilege service accounts
  • Restrict filesystem access via ACLs
  • Add a RAG sanitization layer before content enters LLM context
  • Treat every RAG-retrieved document as untrusted input
  • Run agents in sandboxed environments with no-exec mounts and read-only filesystems

The Bigger Picture

These two CVEs formalize an attack class that has been growing since mid-2025. When you deploy an AI agent in production, you are not deploying a chatbot. You are deploying a process that will invoke functions from its tool registry on command from anyone who can influence its inputs.

The security posture of that deployment is defined not by the model's safety training but by the hygiene of the registry.

The developer who decorates DownloadFileAsync with [KernelFunction] is not being reckless. They are following the framework's documented pattern. The gap is that neither the documentation nor the typical developer's threat model accounts for the fact that every registered tool is now reachable from untrusted input.

Three implications for enterprise defenders:

  1. RAG pipelines are prompt injection delivery mechanisms. Every retrieved document is a potential payload.
  2. Tool registry audits are not optional. Every LLM-callable function needs the same review you would give a public API endpoint.
  3. Agent telemetry is now an EDR signal. The process tree of agent-hosting services is an exploitation signal that existing EDR configurations likely are not monitoring.

Final Thoughts

Microsoft's disclosure is not a one-off fix. It is the opening shot of a research series targeting AI agent frameworks across the ecosystem. The company packaged the vulnerable hotel-finder agent into a CTF challenge and invited the security community to test their skills.

The lesson is clear. Untrusted data being fed into high-risk operations is not new. Web developers learned it with SQL injection and path traversal. AI developers are learning it now with tool registries.

Your LLM is not a security boundary. The tools you expose define your attacker's scope. Any tool parameter the model can influence must be treated as attacker-controlled input.

Patch now. Audit your tool registry. Monitor your agent processes.

The next disclosure is already coming.