CVE-2026-59862 Kiota: Code Generation Literal Injection in the Python Generator
Attacker-controlled enum descriptions in OpenAPI specs can inject Python code into generated modules, leading to execution upon import.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2026-59862?
CVE-2026-59862 is a high-severity code injection vulnerability in microsoft kiota, published on 16 Jul 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
Kiota is an OpenAPI based HTTP Client code generator. Prior to 1.29.1 and 1.32.0, Kiota's Python generator let attacker-controlled enum value descriptions from x-ms-enum.values[].description flow through KiotaBuilder.SetEnumOptions into Documentation.DescriptionTemplate and PythonConventionService.RemoveInvalidDescriptionCharacters without newline sanitization, allowing generated inline comments to split and execute attacker-controlled Python code at module scope when generated modules were imported. This issue is fixed in version 1.29.1 and 1.32.0.
Weakness: CWE-94
Which versions are affected by CVE-2026-59862?
8 open source packages ship an affected version, including Microsoft.OpenAPI.Kiota, Microsoft.OpenAPI.Kiota.Builder and Microsoft.OpenApi.Kiota.
| Package | Affected | Fixed in |
|---|---|---|
Microsoft.OpenAPI.Kiota NuGet | From 1.30.0 | 1.32.0 |
Microsoft.OpenAPI.Kiota NuGet | From 1.30.0 | 1.32.0 |
Microsoft.OpenAPI.Kiota.Builder NuGet | From 1.30.0 | 1.32.0 |
Microsoft.OpenAPI.Kiota.Builder NuGet | From 1.30.0 | 1.32.0 |
Microsoft.OpenApi.Kiota NuGet | All versions | 1.29.1 |
Microsoft.OpenApi.Kiota NuGet | All versions | 1.29.1 |
2 more packages
Microsoft.OpenApi.Kiota.Builder NuGet | All versions | 1.29.1 |
Microsoft.OpenApi.Kiota.Builder NuGet | All versions | 1.29.1 |
How do I fix CVE-2026-59862?
Upgrade Microsoft.OpenAPI.Kiota to 1.32.0 or later.
Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.
Is CVE-2026-59862 being exploited?
There is no known exploitation of CVE-2026-59862 in the wild and no public exploit code.
Sources
Also known as GHSA-7f3j-j7jj-r3vr.