Get a Demo

Let's Patch It!

Book a short call with one our specialists, we'll walk you through how Endor Patches work, and ask you a few questions about your environment (like your primary programming languages and repository management). We'll also send you an email right after you fill out the form, feel free to reply with any questions you have in advance!

CVE

CVE-2026-59866

Microsoft Kiota: Arbitrary file write + code-injection via x-ms-kiota-info clientClassName and clientNamespaceName
Back to all
CVE

CVE-2026-59866

Microsoft Kiota: Arbitrary file write + code-injection via x-ms-kiota-info clientClassName and clientNamespaceName

Summary

Microsoft Kiota emitted the x-ms-kiota-info extension's clientClassName or clientNamespaceName value

raw, with no identifier or path sanitization, as both the generated client's class/namespace name

and part of the generated output path. When kiota generate is run without -c/--class-name — the

zero-config workflow that x-ms-kiota-info is explicitly designed for (the API provider supplies the names in

the description so consumers don't have to) — an attacker who controls or tampers with the OpenAPI description

could therefore:

  • (CWE-22) write the generated source file to a path outside the -o output directory — e.g.

  clientClassName: "/var/www/html/shell"; and

  • (CWE-94) inject arbitrary text into the generated class/namespace declaration, corrupting the generated

  client.

Confirmed on Kiota 1.32.4 (the self-contained linux-x64 release binary), i.e. after the earlier

writer-sink hardening — that fix escaped property/enum/default/serialization sinks but never sanitized the

provider-supplied clientClassName / clientNamespaceName.

Details

clientClassName reached two unsanitized sinks (observed in the generated C#; the same raw emission occurred

for Java, Go, TypeScript, Python, and PHP):

## output FILENAME (CWE-22): clientClassName flows into the file path
clientClassName: "/abs/path/PWNED"   ->   /abs/path/PWNED.cs   (written outside -o)
## class declaration (CWE-94): clientClassName flows verbatim into the type declaration
clientClassName: 'Pwn { } public class INJECTED { } public partial class RealClient'
   ->  public partial class Pwn { } public class INJECTED { } public partial class RealClient : ... { }

clientNamespaceName reached the analogous namespace/path sinks.

Impact

A developer or CI host generating a client from an attacker-controlled or compromised OpenAPI description

(without -c) could create/overwrite a generated source file at an attacker-influenced path and emit

attacker-controlled text into the generated client.

This does not reach clean remote code execution: because clientClassName is reused verbatim at multiple

sites (the class name and the constructor name), injected code cannot be made to compile — it breaks the

build. So the code-injection vector is a generation/build-corruption (integrity/DoS), and the high-severity

primitive is the file write. CWE-22 / CWE-94.

Patches

Fixed in 1.29.1 and 1.32.5 (https://github.com/microsoft/kiota/pull/7884). clientClassName and

clientNamespaceName sourced from x-ms-kiota-info are now sanitized before use:

GenerationConfiguration.SanitizeClientClassName strips any character outside [A-Za-z0-9_] and any invalid

leading character (falling back to ApiClient), and SanitizeClientNamespaceName restricts to

[A-Za-z0-9._-], collapses consecutive dots, strips invalid leading characters (falling back to ApiSdk).

This removes path separators, drive/colon, .., quotes, and braces, so the values can no longer influence

the output path or inject into the declaration.

Remediation

Upgrade to Kiota 1.29.1, 1.32.5, or later and regenerate affected clients.

Package Versions Affected

Package Version
patch Availability
No items found.

Automatically patch vulnerabilities without upgrading

Fix Without Upgrading
Detect compatible fix
Apply safe remediation
Fix with a single pull request

CVSS Version

Severity
Base Score
CVSS Version
Score Vector
C
H
U
9.3
-
4.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
C
H
U
0
-
C
H
U
8.2
-
3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L

Related Resources

No items found.

References

https://github.com/microsoft/kiota/security/advisories/GHSA-4vv7-jj25-4gh6, https://nvd.nist.gov/vuln/detail/CVE-2026-59866, https://github.com/microsoft/kiota/pull/7884, https://github.com/microsoft/kiota/commit/dc812dbbf88ef7edf53a890d36b2f9d1460e947d, https://github.com/microsoft/kiota, https://github.com/microsoft/kiota/releases/tag/v1.32.5

Severity

8.2

CVSS Score
0
10

Basic Information

Base CVSS
8.2
EPSS Probability
0.01413%
EPSS Percentile
0.72182%
Introduced Version
1.30.0,1.24.0-preview.202502270001,0.11.0-preview,1.0.0,0.6.0-preview,0.3.0-preview,0.1.0-preview
Fix Available
1.32.5,1.29.1

Fix Critical Vulnerabilities Instantly

Secure your app without upgrading.
Fix Without Upgrading