Vulnerabilities in pkg:nuget/Microsoft.OpenAPI.Kiota

PACKAGE
Advisory Identifier: GHSA-7f3j-j7jj-r3vr
Advisory Summary

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

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:nuget/Microsoft.OpenAPI.Kiota

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:nuget/Microsoft.OpenAPI.Kiota. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-7f3j-j7jj-r3vr CVE-2026-59862 HIGH Microsoft Kiota: Code Generation Literal Injection in Kiota Python Generator
GHSA-xg2h-5xr2-29jw CVE-2026-59861 HIGH Microsoft Kiota: Code Generation Literal Injection in Kiota Ruby Generator

CVE-2026-59862 at a Glance

CVE Identifier CVE-2026-59862
GHSA Identifier GHSA-7f3j-j7jj-r3vr
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Microsoft Kiota
Package Ecosystem NuGet
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:H).

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 High (A:H)

How to Fix CVE-2026-59862

To remediate this vulnerability, upgrade all affected Microsoft 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.32.0
Upgrade Microsoft.OpenAPI.Kiota to 1.32.0
Microsoft.OpenAPI.Kiota.Builder fixed: 1.32.0
Upgrade Microsoft.OpenAPI.Kiota.Builder to 1.32.0
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-59862, inspect your project dependencies for Microsoft Kiota:

inspect dependencies for Microsoft.OpenAPI.Kiota

Analyze the terminal output to locate any version of Microsoft Kiota in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.32.0), 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 Microsoft 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

Code Generation Literal Injection in Kiota Python Generator Leads to Arbitrary Code Execution at Import Time. The Kiota Python code generator is vulnerable to a code generation literal injection issue when processing malicious or untrusted OpenAPI specifications. Specifically, attacker-controlled enum value descriptions from x-ms-enum.values[].description can flow into generated Python files without newline sanitization, allowing injected content to escape a comment context and execute at module scope when the generated module is imported. This issue requires user interaction in the form of generating a client from a malicious specification and importing the generated code, which is a common development and CI workflow. # Impact A malicious OpenAPI specification can cause arbitrary Python code to be emitted into generated model files. The payload executes when the affected module is imported. ## Potential impact includes Credential theft from developer or CI environments Exfiltration of environment variables and secrets Source code disclosure Persistence via regenerated backdoored client output Who is impacted Developers generating Python SDKs from external or untrusted OpenAPI specs Teams with CI/CD automation that regenerates clients from remote specification URLs Any environment importing generated Python modules before manual review Vulnerability details Two gaps combine to enable exploitation: ### Enum description cleanup gap In KiotaBuilder.SetEnumOptions, enum option descriptions are assigned to Documentation.DescriptionTemplate without CleanupDescription on this path, allowing control characters such as newlines to propagate. ### Python description sanitization gap PythonConventionService.RemoveInvalidDescriptionCharacters escapes backslashes and triple quotes but did not remove carriage return/newline characters, unlike some other language convention services. # Exploit path Malicious newline in x-ms-enum description is emitted through enum writing path. Generated inline comment output is split by newline. Subsequent attacker-controlled line lands at module scope in generated .py file. Importing the module executes the injected code. # Attack vectors OpenAPI specifications hosted at attacker-controlled URLs Supply-chain scenarios where third-party specs are consumed automatically CI pipelines that generate and then import or test generated Python clients # Patches https://github.com/microsoft/kiota/pull/7735 # Workarounds If you cannot upgrade immediately: Only generate from trusted, internally controlled OpenAPI specification sources. Disable or gate automatic generation from remote specs in CI/CD. Add validation/sanitization for x-ms-enum descriptions before generation. Review generated Python files for suspicious top-level statements near enum/model declarations. Run generation and validation in isolated environments without access to production secrets. # Remediation Upgrade to Kiota 1.29.1, 1.32.0, or later. Regenerate existing Python clients to replace previously generated vulnerable output. # Recommended validation after upgrade Regenerate from the same spec used in proof-of-concept testing Confirm malicious multi-line enum descriptions no longer produce executable top-level output

CVE-2026-59862 Affected Microsoft Kiota Versions

4 component(s)
Fixed Versions:
1.32.01.29.1
Product / Package Ecosystem Affected Versions Fixed Version
Microsoft.OpenAPI.Kiota
NuGet
≥ 1.30.0
< 1.32.0
1.32.0
Microsoft.OpenAPI.Kiota.Builder
NuGet
≥ 1.30.0
< 1.32.0
1.32.0
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-59862?
CVE-2026-59862 is a security vulnerability in Microsoft Kiota involving Code Generation Literal Injection in Kiota Python Generator under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Microsoft Kiota versions are affected?
Affected versions include releases prior to 1.32.0, 1.29.1 across affected packages: Microsoft.OpenAPI.Kiota, Microsoft.OpenAPI.Kiota.Builder, Microsoft.OpenApi.Kiota, Microsoft.OpenApi.Kiota.Builder.
What version fixes CVE-2026-59862?
Upgrading to 1.32.0, 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.32.0. Upgrade your dependency to 1.32.0 or later.
Is Microsoft.OpenAPI.Kiota.Builder affected?
Yes, Microsoft.OpenAPI.Kiota.Builder is affected in releases prior to 1.32.0. Upgrade your dependency to 1.32.0 or later.
What is the CVSS score of CVE-2026-59862?
CVE-2026-59862 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-59862?
CVE-2026-59862 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-59862?
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-7f3j-j7jj-r3vr",
  "modified" : "2026-08-17T14:53:11Z",
  "published" : "2026-07-24T15:45:40Z",
  "aliases" : [ "CVE-2026-59862" ],
  "summary" : "Microsoft Kiota: Code Generation Literal Injection in Kiota Python Generator",
  "details" : "Code Generation Literal Injection in Kiota Python Generator Leads to Arbitrary Code Execution at Import Time.\n\nThe Kiota Python code generator is vulnerable to a code generation literal injection issue when processing malicious or untrusted OpenAPI specifications. Specifically, attacker-controlled enum value descriptions from x-ms-enum.values[].description can flow into generated Python files without newline sanitization, allowing injected content to escape a comment context and execute at module scope when the generated module is imported.\n\nThis issue requires user interaction in the form of generating a client from a malicious specification and importing the generated code, which is a common development and CI workflow.\n\n# Impact\n\nA malicious OpenAPI specification can cause arbitrary Python code to be emitted into generated model files. The payload executes when the affected module is imported.\n\n## Potential impact includes\n\nCredential theft from developer or CI environments\nExfiltration of environment variables and secrets\nSource code disclosure\nPersistence via regenerated backdoored client output\nWho is impacted\nDevelopers generating Python SDKs from external or untrusted OpenAPI specs\nTeams with CI/CD automation that regenerates clients from remote specification URLs\nAny environment importing generated Python modules before manual review\nVulnerability details\nTwo gaps combine to enable exploitation:\n\n### Enum description cleanup gap\n\nIn KiotaBuilder.SetEnumOptions, enum option descriptions are assigned to Documentation.DescriptionTemplate without CleanupDescription on this path, allowing control characters such as newlines to propagate.\n\n### Python description sanitization gap\n\nPythonConventionService.RemoveInvalidDescriptionCharacters escapes backslashes and triple quotes but did not remove carriage return/newline characters, unlike some other language convention services.\n\n# Exploit path\n\nMalicious newline in x-ms-enum description is emitted through enum writing path.\nGenerated inline comment output is split by newline.\nSubsequent attacker-controlled line lands at module scope in generated .py file.\nImporting the module executes the injected code.\n\n# Attack vectors\n\nOpenAPI specifications hosted at attacker-controlled URLs\nSupply-chain scenarios where third-party specs are consumed automatically\nCI pipelines that generate and then import or test generated Python clients\n\n# Patches\n\nhttps://github.com/microsoft/kiota/pull/7735\n\n# Workarounds\n\nIf you cannot upgrade immediately:\n\nOnly generate from trusted, internally controlled OpenAPI specification sources.\nDisable or gate automatic generation from remote specs in CI/CD.\nAdd validation/sanitization for x-ms-enum descriptions before generation.\nReview generated Python files for suspicious top-level statements near enum/model declarations.\nRun generation and validation in isolated environments without access to production secrets.\n\n# Remediation\n\nUpgrade to Kiota 1.29.1, 1.32.0, or later.\n\nRegenerate existing Python clients to replace previously generated vulnerable output.\n\n# Recommended validation after upgrade\n\nRegenerate from the same spec used in proof-of-concept testing\nConfirm malicious multi-line enum descriptions no longer produce executable top-level output",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Microsoft.OpenAPI.Kiota"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.30.0"
      }, {
        "fixed" : "1.32.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Microsoft.OpenAPI.Kiota.Builder"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.30.0"
      }, {
        "fixed" : "1.32.0"
      } ]
    } ]
  }, {
    "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-7f3j-j7jj-r3vr"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-59862"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/microsoft/kiota"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/microsoft/kiota/releases/tag/v1.32.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-24T15:45:40Z",
    "nvd_published_at" : "2026-07-16T15:16:35Z"
  }
}