CVE-2026-59866: Microsoft Kiota Arbitrary File Write + Code-injection Vulnerability
HIGHCVE-2026-59866 is a HIGH arbitrary file write + code-injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Microsoft Kiota libraries in the NuGet ecosystem. The issue involves arbitrary file write + code-injection via x-ms-kiota-info clientclassname and clientnamespacename. Remediation is available by upgrading affected packages to version 1.32.5, 1.29.1.
CVE-2026-59866 at a Glance
How to Fix CVE-2026-59866
To remediate this vulnerability, upgrade all affected Microsoft Kiota dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade Microsoft.OpenApi.Kiota to 1.32.5
Upgrade Microsoft.OpenApi.Kiota.Builder to 1.32.5
Upgrade Microsoft.OpenApi.Kiota to 1.29.1
Upgrade Microsoft.OpenApi.Kiota.Builder to 1.29.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for Microsoft.OpenApi.Kiota
How to Check if You Are Affected
To determine whether your application is affected by CVE-2026-59866, inspect your project dependencies for Microsoft Kiota:
inspect dependencies for Microsoft.OpenApi.Kiota
Analyze the terminal output to locate any version of Microsoft Kiota in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.32.5), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Microsoft Kiota, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-59866 Affected Microsoft Kiota Versions
4 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
Microsoft.OpenApi.Kiota
|
NuGet |
≥ 1.30.0
< 1.32.5
|
1.32.5
|
|
Microsoft.OpenApi.Kiota.Builder
|
NuGet |
≥ 1.30.0
< 1.32.5
|
1.32.5
|
|
Microsoft.OpenApi.Kiota
|
NuGet |
< 1.29.1
|
1.29.1
|
|
Microsoft.OpenApi.Kiota.Builder
|
NuGet |
< 1.29.1
|
1.29.1
|
References
Frequently Asked Questions
What is CVE-2026-59866?
Which Microsoft Kiota versions are affected?
What version fixes CVE-2026-59866?
Is Microsoft.OpenApi.Kiota affected?
Is Microsoft.OpenApi.Kiota.Builder affected?
What CWE is associated with CVE-2026-59866?
How can I check NuGet dependencies for CVE-2026-59866?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4vv7-jj25-4gh6",
"modified" : "2026-08-17T14:55:49Z",
"published" : "2026-07-24T16:12:14Z",
"aliases" : [ "CVE-2026-59866" ],
"summary" : "Microsoft Kiota: Arbitrary file write + code-injection via x-ms-kiota-info clientClassName and clientNamespaceName",
"details" : "### Summary\n\nMicrosoft Kiota emitted the `x-ms-kiota-info` extension's `clientClassName` or `clientNamespaceName` value\n**raw**, with no identifier or path sanitization, as **both** the generated client's class/namespace name\n**and** part of the generated output path. When `kiota generate` is run **without `-c/--class-name`** — the\nzero-config workflow that `x-ms-kiota-info` is explicitly designed for (the API provider supplies the names in\nthe description so consumers don't have to) — an attacker who controls or tampers with the OpenAPI description\ncould therefore:\n\n- **(CWE-22) write the generated source file to a path outside the `-o` output directory** — e.g.\n `clientClassName: \"/var/www/html/shell\"`; and\n- **(CWE-94) inject arbitrary text into the generated class/namespace declaration**, corrupting the generated\n client.\n\nConfirmed on Kiota **1.32.4** (the self-contained `linux-x64` release binary), i.e. **after** the earlier\nwriter-sink hardening — that fix escaped property/enum/default/serialization sinks but never sanitized the\nprovider-supplied `clientClassName` / `clientNamespaceName`.\n\n### Details\n\n`clientClassName` reached two unsanitized sinks (observed in the generated C#; the same raw emission occurred\nfor Java, Go, TypeScript, Python, and PHP):\n\n```\n# output FILENAME (CWE-22): clientClassName flows into the file path\nclientClassName: \"/abs/path/PWNED\" -> /abs/path/PWNED.cs (written outside -o)\n\n# class declaration (CWE-94): clientClassName flows verbatim into the type declaration\nclientClassName: 'Pwn { } public class INJECTED { } public partial class RealClient'\n -> public partial class Pwn { } public class INJECTED { } public partial class RealClient : ... { }\n```\n\n`clientNamespaceName` reached the analogous namespace/path sinks.\n\n### Impact\n\nA developer or CI host generating a client from an attacker-controlled or compromised OpenAPI description\n(without `-c`) could create/overwrite a generated source file at an attacker-influenced path and emit\nattacker-controlled text into the generated client.\n\nThis does **not** reach clean remote code execution: because `clientClassName` is reused verbatim at multiple\nsites (the class name **and** the constructor name), injected code cannot be made to compile — it breaks the\nbuild. So the code-injection vector is a generation/build-corruption (integrity/DoS), and the high-severity\nprimitive is the file write. CWE-22 / CWE-94.\n\n### Patches\n\nFixed in **1.29.1 and 1.32.5** (https://github.com/microsoft/kiota/pull/7884). `clientClassName` and\n`clientNamespaceName` sourced from `x-ms-kiota-info` are now sanitized before use:\n`GenerationConfiguration.SanitizeClientClassName` strips any character outside `[A-Za-z0-9_]` and any invalid\nleading character (falling back to `ApiClient`), and `SanitizeClientNamespaceName` restricts to\n`[A-Za-z0-9._-]`, collapses consecutive dots, strips invalid leading characters (falling back to `ApiSdk`).\nThis removes path separators, drive/colon, `..`, quotes, and braces, so the values can no longer influence\nthe output path or inject into the declaration.\n\n### Remediation\n\nUpgrade to Kiota **1.29.1, 1.32.5,** or later and regenerate affected clients.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:H/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "NuGet",
"name" : "Microsoft.OpenApi.Kiota"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.30.0"
}, {
"fixed" : "1.32.5"
} ]
} ]
}, {
"package" : {
"ecosystem" : "NuGet",
"name" : "Microsoft.OpenApi.Kiota.Builder"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.30.0"
}, {
"fixed" : "1.32.5"
} ]
} ]
}, {
"package" : {
"ecosystem" : "NuGet",
"name" : "Microsoft.OpenApi.Kiota"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.29.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "NuGet",
"name" : "Microsoft.OpenApi.Kiota.Builder"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.29.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/microsoft/kiota/security/advisories/GHSA-4vv7-jj25-4gh6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-59866"
}, {
"type" : "WEB",
"url" : "https://github.com/microsoft/kiota/pull/7884"
}, {
"type" : "WEB",
"url" : "https://github.com/microsoft/kiota/commit/dc812dbbf88ef7edf53a890d36b2f9d1460e947d"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/microsoft/kiota"
}, {
"type" : "WEB",
"url" : "https://github.com/microsoft/kiota/releases/tag/v1.32.5"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22", "CWE-94" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-24T16:12:14Z",
"nvd_published_at" : "2026-07-16T16:19:15Z"
}
}