9.3critical
Kiota: Arbitrary file write + code-injection via x-ms-kiota-info clientClassName and clientNamespaceName
- Severity
- 9.3critical CVSS:4.0 by GitHub_M
- Exploit likelihood
- 1.35% (higher than 72% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-4vv7-jj25-4gh6
Description
Kiota is an OpenAPI based HTTP Client code generator. Prior to 1.29.1 and 1.32.5, Kiota emitted x-ms-kiota-info clientClassName and clientNamespaceName values without identifier or path sanitization as both generated client class or namespace names and generated output path components when `kiota generate` ran without -c/--class-name, allowing an attacker-controlled or compromised OpenAPI description to write generated source outside the -o output directory and inject arbitrary text into generated class or namespace declarations. This issue is fixed in version 1.29.1 and 1.32.5 by GenerationConfiguration.SanitizeClientClassName and SanitizeClientNamespaceName.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| microsoft kiota | >= 1.30.0, < 1.31.1, < 1.29.1 | CVE List |
| Microsoft.OpenApi.Kiota (NuGet) | from 1.30.0 before 1.32.5, before 1.29.1 | GitHub Advisory Database |
| Microsoft.OpenApi.Kiota.Builder (NuGet) | from 1.30.0 before 1.32.5, before 1.29.1 | GitHub Advisory Database |
All scores
| GitHub_M | 9.3critical CVSS: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 |
| GitHub | high CVSS:4.0 | 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 |
Classification
What each source says
CVE List
Kiota is an OpenAPI based HTTP Client code generator. Prior to 1.29.1 and 1.32.5, Kiota emitted x-ms-kiota-info clientClassName and clientNamespaceName values without identifier or path sanitization as both generated client class or namespace names and generated output path components when `kiota generate` ran without -c/--class-name, allowing an attacker-controlled or compromised OpenAPI description to write generated source outside the -o output directory and inject arbitrary text into generated class or namespace declarations. This issue is fixed in version 1.29.1 and 1.32.5 by GenerationConfiguration.SanitizeClientClassName and SanitizeClientNamespaceName.
GitHub Advisory Database
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
-ooutput 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.
NVD (es)
Kiota es un generador de código de cliente HTTP basado en OpenAPI. Antes de la versión 1.32.5, Kiota emitía valores x-ms-kiota-info clientClassName y clientNamespaceName sin saneamiento de identificadores o rutas, tanto como nombres de clase o espacio de nombres de cliente generados como componentes de ruta de salida generados, cuando kiota generate se ejecutaba sin -c/--class-name, permitiendo que una descripción OpenAPI controlada por un atacante o comprometida escribiera código fuente generado fuera del directorio de salida -o e inyectara texto arbitrario en las declaraciones de clase o espacio de nombres generadas. Este problema se solucionó en la versión 1.32.5 mediante GenerationConfiguration.SanitizeClientClassName y SanitizeClientNamespaceName.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-59866 changed 2026-08-17 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-4vv7-jj25-4gh6 changed 2026-08-17 | CC-BY-4.0 |
| NVD | CVE-2026-59866 changed 2026-10-24 | Public domain |