Loading...
Skip to main content

CVE-2026-59866 — Vulnerability in Microsoft.OpenApi.Kiota — CVE...

HIGH

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

Published July 24, 2026Updated August 17, 2026Source: osv

Summary

### 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.

Advisory Timeline

  • First published July 24, 2026 (80 days ago).
  • Last revised August 17, 2026 — 24 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

NuGet
Update Microsoft.OpenApi.Kiota to 1.32.5 or later
dotnet add package Microsoft.OpenApi.Kiota --version 1.32.5
NuGet
Update Microsoft.OpenApi.Kiota.Builder to 1.32.5 or later
dotnet add package Microsoft.OpenApi.Kiota.Builder --version 1.32.5
NuGet
Update Microsoft.OpenApi.Kiota to 1.29.1 or later
dotnet add package Microsoft.OpenApi.Kiota --version 1.29.1
NuGet
Update Microsoft.OpenApi.Kiota.Builder to 1.29.1 or later
dotnet add package Microsoft.OpenApi.Kiota.Builder --version 1.29.1

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (4)

Affects 1 ecosystem: nuget (2).

PackageEcosystemAffectedFixed In
Microsoft.OpenApi.Kiota
nuget
1.30.0, 1.31.0, 1.31.1, 1.32.0 (+4 more)1.32.5
Microsoft.OpenApi.Kiota.Builder
nuget
All versions1.32.5
Microsoft.OpenApi.Kiota
nuget
0.1.0-preview, 0.1.1-preview, 0.1.2-preview, 0.1.3-preview (+62 more)1.29.1
Microsoft.OpenApi.Kiota.Builder
nuget
0.2.0-preview, 0.3.0-preview, 0.4.0-preview, 0.5.0-preview (+42 more)1.29.1

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 6.6 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
A
Scope
—
Confidentiality
—
Integrity
—
Availability
—

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

Frequently Asked Questions

What is CVE-2026-59866?
Microsoft Kiota: Arbitrary file write + code-injection via x-ms-kiota-info clientClassName and clientNamespaceName This vulnerability has been assigned a severity rating of HIGH (CVSS score: 6.6/10).
How do I check if my project is affected by CVE-2026-59866?
CVE-2026-59866 affects Microsoft.OpenApi.Kiota and Microsoft.OpenApi.Kiota.Builder. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-59866 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
6.6

Exploitation requires specific conditions or has limited impact. Remediate within weeks.

Also Known As

GHSA-4vv7-jj25-4gh6

Related CVEs

  • CVE-2026-59864
    CRITICAL

    Microsoft Kiota: Path/URL injection into generated Copilot plugin manifest via x-ai-* extensions

  • CVE-2026-59865
    CRITICAL

    Microsoft Kiota: Command injection via x-ms-kiota-info dependencyInstallCommand surfaced by `kiota info`

  • CVE-2026-59860
    HIGH

    Microsoft Kiota: XML Doc-Comment Newline Breakout Code Injection

  • CVE-2026-59863
    HIGH

    Microsoft Kiota Workspace-config poisoning: out-of-repo file write + generation-time SSRF

  • CVE-2026-59862
    HIGH

    Microsoft Kiota: Code Generation Literal Injection in Kiota Python Generator

  • CVE-2026-59859
    HIGH

    Microsoft Kiota: Code Generation Literal Injection in Kiota PHP Generator

  • CVE-2026-59867
    HIGH

    Microsoft Kiota: Generation-time SSRF + remote/local file inclusion via unrestricted $ref

  • CVE-2026-105796
    HIGH

    Kiota: Code injection through doc-comment delimiter reformation in Kiota Java and PHP generators

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies