Summary
Kiota: Code Generation Literal Injection
CVE Advisory (CVE-2026-41134): Code Generation Literal Injection in Kiota
Kiota versions prior to 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.31.1
- Fixed: 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.
Acknowledgement
We would like to thank the researcher Thanatos Tian(Polyu) for finding this issue and for his contribution to this open source project.
Impact
Untrusted input is evaluated as executable code within the application's runtime environment. Typical impact: arbitrary code execution within the application's privilege context.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
- 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.
Frequently Asked Questions
- What is CVE-2026-41134? CVE-2026-41134 is a high-severity code injection vulnerability in kiota (nuget), affecting versions < 1.31.1. It is fixed in 1.31.1. Untrusted input is evaluated as executable code within the application's runtime environment.
- Which packages are affected by CVE-2026-41134?
kiota(nuget) (versions < 1.31.1)Microsoft.OpenApi.Kiota(nuget) (versions < 1.31.1)Microsoft.OpenApi.Kiota.Builder(nuget) (versions < 1.31.1)
- Is there a fix for CVE-2026-41134? Yes. CVE-2026-41134 is fixed in 1.31.1. Upgrade to this version or later.
- Is CVE-2026-41134 exploitable, and should I be worried? Whether CVE-2026-41134 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-41134 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-41134?
- Upgrade
kiotato 1.31.1 or later - Upgrade
Microsoft.OpenApi.Kiotato 1.31.1 or later - Upgrade
Microsoft.OpenApi.Kiota.Builderto 1.31.1 or later
- Upgrade