Abstract technical illustration on a pale blue field with a faint grey grid. A large soft cyan glow sits in the upper right and a soft blue glow in the lower left. At the left, a small cluster of five teal dots; a thin grey horizontal line runs from it to a white rounded rectangle outlined in blue with small corner ticks. Inside the rectangle the same line continues in amber, crosses the outline to the right and ends in an amber starburst with a solid centre, two thin concentric rings and a soft amber halo. A few pale blue dots are scattered in the background. No text, no people, no brand marks and no readable lettering appear anywhere in the image. The OrcaRouter logo is composited in the bottom-right corner of the canvas.
AI Safety Incidents

A Prompt, a Filter String, a Shell: Two Semantic Kernel RCEs

Author

jinhao.song

Date Published

Models in this article · 1View all models →
Back to all posts

On 7 May 2026 Microsoft's Defender Security Research Team published its account of two remote code execution flaws in Semantic Kernel, Microsoft's own open-source framework for building AI agents, and the fixes that closed them. Neither needed a memory-corruption bug or a malicious attachment. In the Python SDK, the default filter behind InMemoryVectorStore built a lambda by string formatting and handed it to eval(), so a prompt-injected search argument that closed a quote could run Python on the agent's host; Microsoft demonstrated it by launching calc.exe from one prompt. In the .NET SDK, a helper inside SessionsPythonPlugin carried the [KernelFunction] attribute, which told the model the helper was a callable tool, and prompting the agent to download one file wrote it to the Windows Startup folder. The fixes are semantic-kernel 1.39.4 for Python and 1.71.0 for .NET. The full record, with its confidence grade and the entries filed around it, sits in the Orca AI Incident Archive, which catalogues documented AI incidents rather than only the ones that made headlines.

What Microsoft found, and where

Semantic Kernel is the layer Microsoft ships for wiring a language model to tools. The model chooses a tool, the framework turns that choice into a typed call, and the tool runs with the agent's own privileges. Microsoft's post puts the repository at "over 27,000 stars on GitHub" and describes frameworks like it as "the operating system for AI agents". The two CVEs it covers were not discovered by an outside researcher: they were found by Microsoft's own security research team, disclosed to the Microsoft Security Response Center, and patched by the Semantic Kernel maintainers before the technical detail was published.

The gap between patch and explanation is wide. Both advisories went out in February 2026 — CVE-2026-25592 on 6 February and CVE-2026-26030 on 19 February — and the Python fix, semantic-kernel 1.39.4, was on PyPI on 10 February. The mechanics of how either flaw was reached stayed private until the 7 May post, which is the date the AI incident archive files this record under.

CVE-2026-26030: the filter was a string, and the string went to eval()

Exploitation needed two conditions, both ordinary in production. The attacker had to have a prompt injection vector into the agent, and the agent had to use the Search Plugin backed by InMemoryVectorStore in its default configuration. Microsoft built a hotel finder to demonstrate it: an in-memory collection of hotel data, and a search_hotels(city=...) function exposed to the kernel so the model could call it. Ask for hotels in Paris and the model calls the plugin with city="Paris". The plugin then runs a deterministic filter to narrow the dataset before computing vector similarity.

That filter is where the flaw lived. The default filter function was implemented as a Python lambda built by interpolating the model-supplied argument into a string and executing the result with eval(). For Paris the string was lambda x: x.city == 'Paris'. Microsoft's post states the defect plainly: the argument is model-controlled and never sanitized, so the filter is a classic injection sink. Close the quote, append Python, and the lookup becomes a payload.

The framework's authors had anticipated exactly this. Before evaluation, the filter string was parsed into an abstract syntax tree and validated: only lambda expressions were accepted, so import statements and class definitions were rejected outright; the tree was scanned for dangerous identifiers such as eval, exec, open and __import__; and the code ran in an environment where Python's built-ins had been removed. Microsoft calls the approach "solid in theory" and notes the problem with it in the same breath — a blocklist in a dynamic language is fragile, because restricted operations can be reintroduced through other syntax, other libraries, or runtime evaluation.

The payload Microsoft's researchers used did not touch any of the blocked names. It closed the quote and climbed Python's type hierarchy from tuple(), which exists whether or not the built-ins do, until it reached BuiltinImporter, then used load_module to import a module and system to run a shell command. The names it touched — __name__, load_module, system, BuiltinImporter — were not on the list. The structural check passed, because the whole payload was still wrapped in a valid lambda. Emptying __builtins__ achieved nothing, because the payload never called a built-in directly. And the validator only inspected Name and Attribute nodes, so a payload that needed a blocked name could have reached it through bracket notation, producing a Subscript node the check ignored entirely. The result, on the demonstration machine, was calc.exe starting from one prompt.

The fix replaces the blocklist logic with four layers: an allowlist of AST node types, restricted to comparisons, boolean logic, arithmetic and literals; an allowlist of functions that a call node may invoke; a blocklist of attributes that enable class-hierarchy traversal, such as __class__ and __subclasses__; and a restriction that lets only the lambda's own parameter appear as a bare identifier. The GitHub advisory, published on 19 February 2026, classifies the flaw as CWE-94 and scores it 9.9 on CVSS v3.1 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H). The advisory's recommended workaround for anyone who cannot upgrade is blunt: avoid using InMemoryVectorStore for production scenarios.

HTML card headed 'The bypass in four moves', subtitled 'CVE-2026-26030 - Semantic Kernel Python SDK, before 1.39.4'. Four numbered rows read: one, a default filter is a string, and for Paris the framework builds lambda x: x.city == 'Paris' and hands it to eval(); two, the argument is model-controlled and unsanitized, so a closing quote and a payload turn the filter into lambda x: x.city == '' or PAYLOAD or ''; three, the validator checks the syntax tree for blocked names such as eval, exec and __import__ and runs the code with the built-ins emptied, and the payload uses none of them; four, it starts from tuple(), walks the type hierarchy to BuiltinImporter, calls load_module, then calls system(), so one prompt launches calc.exe on the host. A footer reads 'Source: Microsoft Security Blog, When prompts become shells, 7 May 2026; GitHub advisory GHSA-xjw9-4gw8-4rqx, 19 February 2026. Nothing in the payload was a built-in call, so removing __builtins__ removed nothing.' The card background is pale blue with a cyan glow in the top right. The OrcaRouter logo is composited in the bottom-right corner of the canvas.

CVE-2026-25592: one stray attribute, one sandbox escape

The second flaw is smaller in code and, in Microsoft's telling, more instructive. Semantic Kernel ships a plugin called SessionsPythonPlugin that lets an agent execute Python inside Azure Container Apps dynamic sessions — isolated, cloud-hosted sandboxes with their own filesystem. The whole security model rests on that boundary: code runs in the sandbox and cannot touch the host where the agent process lives. Helper functions, UploadFile and DownloadFile, run on the host side to move data across the boundary.

In the .NET SDK, DownloadFileAsync — one of those helpers — had been accidentally marked with the [KernelFunction] attribute. The attribute is how a developer advertises a method to the model as a callable tool, complete with a parameter schema. Marking the helper did not merely document it; it made the model able to call it, and it made the localFilePath parameter, which decides where File.WriteAllBytes() writes on the host device, entirely model-controlled. Microsoft's post says there was no path validation, no directory restriction and no sanitization behind it.

That turned function calling into a three-step escape. An injected instruction tells the agent to use the ExecuteCode tool to write a malicious script inside the container — contained, at that point, because the payload exists only in the sandbox. A second injected instruction tells the model to use DownloadFileAsync to fetch that file to a dangerous location on the host; the agent fetches it from the sandbox API and writes it into the Windows Startup folder. On the next user sign-in the script runs, and the host is compromised. Microsoft maps the chain onto MITRE ATLAS, from AML.T0051 (LLM Prompt Injection) to AML.T0016 (Obtain Capabilities).

The same class of mistake ran in the other direction. Microsoft notes that upload_file() in both the Python and .NET SDKs accepted any local file path without validation, so a prompt injection could pull sensitive host files — SSH keys, credentials — out of the host and into the sandbox. The advisory classifies the flaw as CWE-22, an arbitrary file write reached through path handling, and scores it 9.9 on the same CVSS v3.1 vector as the Python flaw.

The .NET fix addresses both the root cause and the damage path. The [KernelFunction] attribute was removed, so the model can no longer see or invoke the helper at all — Microsoft describes that single change as breaking the entire attack chain. For developers who call the function deliberately from their own code, a ValidateLocalPathForDownload() method was added, using path canonicalization through Path.GetFullPath() and an allowlist of permitted directories. Uploads got comparable opt-in controls in the same release: the fix requires EnableDangerousFileUploads to be set and AllowedUploadDirectories to be configured. The patched version is Microsoft.SemanticKernel.Core 1.71.0.

HTML card headed 'From one annotation to persistence', subtitled 'CVE-2026-25592 - Semantic Kernel .NET SDK, before 1.71.0'. A left column headed 'The chain' lists three numbered steps: one, ExecuteCode writes a script inside the Azure Container Apps sandbox, still contained because the file exists only in the container; two, a second prompt tells the model to call DownloadFileAsync and give it a localFilePath in the host's Windows Startup folder, and the agent writes the file to the host; three, on the next user sign-in the script runs on the host, the container boundary crossed by function calling alone. A right column carries two panels: an amber one headed 'The cause', reading that DownloadFileAsync carried the [KernelFunction] attribute so the model could call it and set the path itself, with no validation behind the write; and a blue one headed 'The fix', reading that the attribute was removed so the model cannot see the method, and that ValidateLocalPathForDownload() adds Path.GetFullPath() canonicalization and a directory allowlist for developer calls. A footer reads 'Source: Microsoft Security Blog, 7 May 2026; GitHub advisory GHSA-2ww3-72rp-wpp4, 6 February 2026. The chain maps to MITRE ATLAS AML.T0051 (LLM Prompt Injection) to AML.T0016 (Obtain Capabilities).' The OrcaRouter logo is composited in the bottom-right corner of the canvas.

Why an annotation counts as a vulnerability

The Python flaw is a familiar shape to anyone who has read web security: untrusted input reaching an interpreter, with a denylist standing in for a parser. The .NET flaw is harder to place in that lineage. An attribute that a developer adds to expose a method to a model is not documentation and not configuration; it is an authorization decision written in metadata, and nothing in the compiler or the type system treats it as one. Remove the attribute and the same method, with the same code, is no longer reachable by a prompt. Add it and a file-transfer helper becomes a host write primitive.

Microsoft's own framing is that neither issue is a model defect: the model is not the problem, because it is behaving as designed when it parses language into tool schemas, and the vulnerability lies in how the framework and the tools trust the parsed data. The post's summary line is the one worth keeping: "your LLM is not a security boundary. The tools you expose define your attacker's affected scope." Microsoft says the pair is a case study from a new research series on agent frameworks, with structurally similar issues in third-party frameworks to follow.

What is established, and what is not

Established: both flaws existed in shipped versions of Semantic Kernel, both were fixed in named releases, and both fixes are visible in the public repository. The two changes are pull request 13478, adding upload and download security controls to SessionsPythonPlugin and merged on 29 January 2026, and pull request 13505, hardening the filter and merged on 10 February 2026; the package releases are on PyPI and NuGet. The CVE identifiers, the CWE classifications and the fix versions are recorded in NVD, which lists CVE-2026-26030 as analyzed and CVE-2026-25592 as deferred, and in the GitHub advisories for the microsoft/semantic-kernel repository.

Not established, and not claimed by Microsoft: that anyone was attacked. The post describes what the researchers could do in a demonstration, not what an adversary did. It reports no victim, no affected-customer count and no incident. Neither NVD record carries CISA's known-exploited flag as of 2 November 2026, and FIRST's Exploit Prediction Scoring System put the two at 3.9% and 2.6% probability of exploitation in the next thirty days on 1 November 2026 — low figures, consistent with a flaw that requires an injection vector and a specific configuration to line up. The AI incident archive files this record as research rather than a deployment event, with real harm recorded as false, confidence A and no dispute attached.

On corroboration, the honest answer is that almost everything in this account comes from Microsoft. The advisories are Microsoft's own, published through the repository's GitHub advisory process; the blog is Microsoft's; the code changes are Microsoft's. The independent records this run could verify are the vulnerability databases that re-publish the identifiers and classifications — NVD, and OSV's PYSEC-2026-163 entry, which aliases the Python CVE and records 1.39.4 as the fixed version — plus package metadata showing when each fixed version shipped. The one non-Microsoft document found describing both flaws is a research chapter in the OWASP AISVS project, which lists the pair among agent-framework vulnerabilities and restates Microsoft's account and the fixed versions without adding facts of its own. Searches on 2 November 2026 surfaced no coverage in mainstream technology press, and the write-ups that do exist sit on security aggregator sites rather than in reported journalism. That is worth stating rather than papering over: a well-documented finding whose documentation is almost entirely first-party.

What changed after

For teams running Semantic Kernel, the response is a version check. Python deployments need semantic-kernel 1.39.4 or later; .NET deployments need Microsoft.SemanticKernel.Core 1.71.0 or later. Microsoft's post is explicit that no architectural rewrite is required, because the updates remove the model's ability to trigger the affected functions. The harder question it raises is retrospective. Patching closes the hole but does not say whether it was used before the patch, so the post defines the vulnerable window for each deployment — from the moment a vulnerable version was deployed to the moment the fixed one was installed — and points defenders at host-level telemetry inside that window: child processes spawned by the agent host, outbound connections, persistence artefacts. If any of that turns up, Microsoft's guidance is to treat the host as compromised, rotate the credentials and tokens the agent could reach, and work out what that host could touch.

The post also ships the queries to do it, as KQL hunts against process events, and a capture-the-flag package built from the vulnerable hotel-finder agent so defenders can try the payload themselves in a sandbox. The lesson the post keeps returning to is not about Semantic Kernel specifically. Any tool parameter a model can influence has to be handled as attacker-controlled input, and the place that has to happen is the tool's own code, because the model will do exactly what it is asked.

HTML card headed 'Patch, advisory, explanation', subtitled 'Semantic Kernel, 2026 - the fixes landed in February, the mechanics in May'. A six-row timeline reads: 29 January 2026, pull request 13478 merged, adding upload and download security controls to SessionsPythonPlugin; 6 February 2026, GitHub advisory GHSA-2ww3-72rp-wpp4 published for CVE-2026-25592, naming 1.71.0 as the fix; 10 February 2026, semantic-kernel 1.39.4 released on PyPI and pull request 13505 merged, hardening the filter, the row highlighted in amber; 19 February 2026, GitHub advisory GHSA-xjw9-4gw8-4rqx published for CVE-2026-26030; 7 May 2026, Microsoft Security Blog publishes the technical analysis of both flaws, the row highlighted in amber; 2 November 2026, neither NVD record carries CISA's known-exploited flag, and EPSS on 1 November recorded 3.9% and 2.6%. A footer reads 'Sources: Microsoft Security Blog, 7 May 2026; GitHub advisories; PyPI; NVD and FIRST EPSS, read 2 November 2026.' The OrcaRouter logo is composited in the bottom-right corner of the canvas.

The record matters less for what an attacker did with it — on the evidence available, nothing — than for where the boundary turned out to be. Both flaws sat in the seam between the model's output and the framework's trust in it, and in the .NET case the seam was one attribute wide. Microsoft's fix list reads like a description of that seam: an allowlist where there had been a denylist, a path check where there had been none, and an attribute removed so that a host-side helper stopped being a tool. Everything else in the post follows from the same sentence, that a model which translates intent into tool calls will faithfully translate a hostile intent too.