7.3high
Kiota: Code Generation Literal Injection
- Severity
- 7.3high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.32% (higher than 26% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-2hx3-vp6r-mg3f
Description
Kiota is an OpenAPI based HTTP Client code generator. Versions prior to 1.29.1 and 1.31.1 are affected by a code-generation literal injection vulnerability in multiple writer sinks (for example: serialization/deserialization keys, path/query parameter mappings, URL template metadata, enum/property metadata, and default value emission). When malicious values from an OpenAPI description are emitted into generated source without context-appropriate escaping, an attacker can break out of string literals and inject additional code into generated clients. This issue is only practically exploitable when the OpenAPI description used for generation is from an untrusted source, or a normally trusted OpenAPI description has been compromised/tampered with. Only generating from trusted, integrity-protected API descriptions significantly reduces the risk. To remediate the issue, upgrade Kiota to 1.29.1, 1.31.1, or later and regenerate/refresh existing generated clients as a precaution. Refreshing generated clients ensures previously generated vulnerable code is replaced with hardened output.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| microsoft kiota | >= 1.30.0, < 1.31.1, < 1.29.1, before 1.31.1 | CVE List, NVD |
| Microsoft.OpenApi.Kiota (NuGet) | from 1.30.0 before 1.31.1, before 1.29.1 | GitHub Advisory Database |
| Microsoft.OpenApi.Kiota.Builder (NuGet) | from 1.30.0 before 1.31.1, before 1.29.1 | GitHub Advisory Database |
All scores
| GitHub_M | 7.3high CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| GitHub | 0.0high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| NVD | 7.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.
What each source says
CVE List
Kiota is an OpenAPI based HTTP Client code generator. Versions prior to 1.29.1 and 1.31.1 are affected by a code-generation literal injection vulnerability in multiple writer sinks (for example: serialization/deserialization keys, path/query parameter mappings, URL template metadata, enum/property metadata, and default value emission). When malicious values from an OpenAPI description are emitted into generated source without context-appropriate escaping, an attacker can break out of string literals and inject additional code into generated clients. This issue is only practically exploitable when the OpenAPI description used for generation is from an untrusted source, or a normally trusted OpenAPI description has been compromised/tampered with. Only generating from trusted, integrity-protected API descriptions significantly reduces the risk. To remediate the issue, upgrade Kiota to 1.29.1, 1.31.1, or later and regenerate/refresh existing generated clients as a precaution. Refreshing generated clients ensures previously generated vulnerable code is replaced with hardened output.
GitHub Advisory Database
CVE Advisory (CVE-2026-41134): Code Generation Literal Injection in Kiota
Summary
Kiota versions prior to 1.29.1 and 1.31.1 are affected by a code-generation literal injection vulnerability in multiple writer sinks (for example: serialization/deserialization keys, path/query parameter mappings, URL template metadata, enum/property metadata, and default value emission).
When malicious values from an OpenAPI description are emitted into generated source without context-appropriate escaping, an attacker can break out of string literals and inject additional code into generated clients.
Impact and Preconditions
This issue is only practically exploitable when:
- the OpenAPI description used for generation is from an untrusted source, or
- a normally trusted OpenAPI description has been compromised/tampered with.
If you only generate from trusted, integrity-protected API descriptions, risk is significantly reduced.
Affected Versions
- Affected: all versions < 1.29.1 and >= 1.30.0, < 1.31.1
- Fixed: 1.29.1, 1.31.1, and later
Illustrative Exploit Example
Example OpenAPI fragment (malicious default value)
openapi: 3.0.1
info:
title: Exploit Demo
version: 1.0.0
components:
schemas:
User:
type: object
properties:
displayName:
type: string
default: "\"; throw new System.Exception(\"injected\"); //"
Example generated C# snippet before fix (illustrative)
public User() {
DisplayName = ""; throw new System.Exception("injected"); //";
}
The injected payload escapes the intended string context and introduces attacker-controlled statements in generated code.
Note: this exploit is not limited to default values, but may also impact properties names (serialization), path or query parameters, enum representations and other locations.
Remediation
- Upgrade Kiota to 1.31.1 or later.
- Regenerate/refresh existing generated clients as a precaution:
kiota update
Refreshing generated clients ensures previously generated vulnerable code is replaced with hardened output.
Acknowledgement
We would like to thank the researcher Thanatos Tian(Polyu) for finding this issue and for his contribution to this open source project.
NVD (es)
Kiota es un generador de código de cliente HTTP basado en OpenAPI. Las versiones anteriores a la 1.31.1 están afectadas por una vulnerabilidad de inyección literal en la generación de código en múltiples sumideros de escritura (por ejemplo: claves de serialización/deserialización, mapeos de parámetros de ruta/consulta, metadatos de plantillas de URL, metadatos de enumeraciones/propiedades y emisión de valores predeterminados). Cuando valores maliciosos de una descripción OpenAPI son emitidos en el código fuente generado sin el escape apropiado para el contexto, un atacante puede salir de los literales de cadena e inyectar código adicional en los clientes generados. Este problema solo es prácticamente explotable cuando la descripción OpenAPI utilizada para la generación proviene de una fuente no confiable, o una descripción OpenAPI normalmente confiable ha sido comprometida/manipulada. Generar únicamente a partir de descripciones de API confiables y protegidas por integridad reduce significativamente el riesgo. Para remediar el problema, actualice Kiota a la versión 1.31.1 o posterior y regenere/actualice los clientes generados existentes como precaución. La actualización de los clientes generados asegura que el código vulnerable generado previamente sea reemplazado por una salida reforzada.
References
| https://github.com/microsoft/kiota/security/advisories/GHSA-2hx3-vp6r-mg3f | exploit, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-41134 | advisory | |
| https://github.com/microsoft/kiota | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-41134 changed 2026-08-17 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-2hx3-vp6r-mg3f changed 2026-08-17 | CC-BY-4.0 |
| NVD | CVE-2026-41134 changed 2026-10-26 | Public domain |