CVE-2026-41134: Kiota Code Generation Literal Injection Vulnerability

HIGH
Advisory Identifier: GHSA-2hx3-vp6r-mg3f
CVSS 0.0
CWE-94
Published
Advisory Summary

CVE-2026-41134 is a HIGH (CVSS 0.0) code generation literal injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Kiota libraries in the NuGet ecosystem. The issue involves code generation literal injection. Remediation is available by upgrading affected packages to version 1.31.1, 1.29.1.

CVE-2026-41134 at a Glance

CVE Identifier CVE-2026-41134
GHSA Identifier GHSA-2hx3-vp6r-mg3f
Severity HIGH
CVSS v3.1 Base Score 0.0
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Kiota
Package Ecosystem NuGet
Published Date
Last Updated

Security Impact

CVSS: 0.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-41134

To remediate this vulnerability, upgrade all affected Kiota dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Microsoft.OpenApi.Kiota fixed: 1.31.1
Upgrade Microsoft.OpenApi.Kiota to 1.31.1
Microsoft.OpenApi.Kiota.Builder fixed: 1.31.1
Upgrade Microsoft.OpenApi.Kiota.Builder to 1.31.1
Microsoft.OpenApi.Kiota fixed: 1.29.1
Upgrade Microsoft.OpenApi.Kiota to 1.29.1
Microsoft.OpenApi.Kiota.Builder fixed: 1.29.1
Upgrade Microsoft.OpenApi.Kiota.Builder to 1.29.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for Microsoft.OpenApi.Kiota

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-41134, inspect your project dependencies for Kiota:

inspect dependencies for Microsoft.OpenApi.Kiota

Analyze the terminal output to locate any version of Kiota in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.31.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Kiota, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# 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: 1. the OpenAPI description used for generation is from an **untrusted source**, or 2. 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) ```yaml 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) ```csharp 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 1. Upgrade Kiota to **1.31.1 or later**. 2. Regenerate/refresh existing generated clients as a precaution: ```bash 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.

CVE-2026-41134 Affected Kiota Versions

4 component(s)
Fixed Versions:
1.31.11.29.1
Product / Package Ecosystem Affected Versions Fixed Version
Microsoft.OpenApi.Kiota
NuGet
≥ 1.30.0
< 1.31.1
1.31.1
Microsoft.OpenApi.Kiota.Builder
NuGet
≥ 1.30.0
< 1.31.1
1.31.1
Microsoft.OpenApi.Kiota
NuGet
< 1.29.1
1.29.1
Microsoft.OpenApi.Kiota.Builder
NuGet
< 1.29.1
1.29.1

References

Frequently Asked Questions

What is CVE-2026-41134?
CVE-2026-41134 is a security vulnerability in Kiota involving Code Generation Literal Injection under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Kiota versions are affected?
Affected versions include releases prior to 1.31.1, 1.29.1 across affected packages: Microsoft.OpenApi.Kiota, Microsoft.OpenApi.Kiota.Builder.
What version fixes CVE-2026-41134?
Upgrading to 1.31.1, 1.29.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Microsoft.OpenApi.Kiota affected?
Yes, Microsoft.OpenApi.Kiota is affected in releases prior to 1.31.1, 1.29.1. Upgrade your dependency to 1.31.1, 1.29.1 or later.
Is Microsoft.OpenApi.Kiota.Builder affected?
Yes, Microsoft.OpenApi.Kiota.Builder is affected in releases prior to 1.31.1, 1.29.1. Upgrade your dependency to 1.31.1, 1.29.1 or later.
What is the CVSS score of CVE-2026-41134?
CVE-2026-41134 has a CVSS v3.1 base score of 0.0 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N.
What CWE is associated with CVE-2026-41134?
CVE-2026-41134 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check NuGet dependencies for CVE-2026-41134?
Run the dependency tree command: 'inspect dependencies for Microsoft.OpenApi.Kiota'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-2hx3-vp6r-mg3f",
  "modified" : "2026-08-17T14:58:37Z",
  "published" : "2026-04-14T23:39:41Z",
  "aliases" : [ "CVE-2026-41134" ],
  "summary" : "Kiota: Code Generation Literal Injection",
  "details" : "# CVE Advisory (CVE-2026-41134): Code Generation Literal Injection in Kiota\n\n## Summary\n\nKiota 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).\n\nWhen 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.\n\n## Impact and Preconditions\n\nThis issue is only practically exploitable when:\n\n1. the OpenAPI description used for generation is from an **untrusted source**, or\n2. a normally trusted OpenAPI description has been **compromised/tampered with**.\n\nIf you only generate from trusted, integrity-protected API descriptions, risk is significantly reduced.\n\n## Affected Versions\n\n- **Affected:** all versions **< 1.29.1** and **>= 1.30.0, < 1.31.1**\n- **Fixed:** **1.29.1, 1.31.1,** and later\n\n## Illustrative Exploit Example\n\n### Example OpenAPI fragment (malicious default value)\n\n```yaml\nopenapi: 3.0.1\ninfo:\n  title: Exploit Demo\n  version: 1.0.0\ncomponents:\n  schemas:\n    User:\n      type: object\n      properties:\n        displayName:\n          type: string\n          default: \"\\\"; throw new System.Exception(\\\"injected\\\"); //\"\n```\n\n### Example generated C# snippet before fix (illustrative)\n\n```csharp\npublic User() {\n    DisplayName = \"\"; throw new System.Exception(\"injected\"); //\";\n}\n```\n\nThe injected payload escapes the intended string context and introduces attacker-controlled statements in generated code.\n\n> 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.\n\n## Remediation\n\n1. Upgrade Kiota to **1.31.1 or later**.\n2. Regenerate/refresh existing generated clients as a precaution:\n\n```bash\nkiota update\n```\n\nRefreshing generated clients ensures previously generated vulnerable code is replaced with hardened output.\n\n## Acknowledgement\n\nWe would like to thank the researcher Thanatos Tian(Polyu) for finding this issue and for his contribution to this open source project.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Microsoft.OpenApi.Kiota"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.30.0"
      }, {
        "fixed" : "1.31.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Microsoft.OpenApi.Kiota.Builder"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.30.0"
      }, {
        "fixed" : "1.31.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Microsoft.OpenApi.Kiota"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.29.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Microsoft.OpenApi.Kiota.Builder"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.29.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/microsoft/kiota/security/advisories/GHSA-2hx3-vp6r-mg3f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-41134"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/microsoft/kiota"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-14T23:39:41Z",
    "nvd_published_at" : "2026-04-22T21:17:09Z"
  }
}