# CVE-2026-59862: Microsoft Kiota code injection in Python generator

Source: https://junglewise.ai/threats/cve-2026-59862-microsoft-kiota-code-injection-in-python-generator  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-16. Updated: 2026-07-24  
License: CC BY 4.0 with a link back

CVE-2026-59862 · Severity: high · CVSS 7.5 · Published 2026-07-16

Microsoft Kiota is a tool used by developers to automatically generate software code (SDKs) from API specifications. A security flaw in the Python code generator allows a malicious API specification to inject hidden commands into the generated code. If a developer or automated system builds and then runs this generated code, it could lead to the theft of passwords, secret keys, or sensitive source code.

Technologies: [Microsoft Kiota](https://junglewise.ai/threats/technologies/kiota), [Microsoft Kiota.Builder](https://junglewise.ai/threats/technologies/kiota-builder), [Microsoft.OpenApi.Kiota](https://junglewise.ai/threats/technologies/microsoft-openapi-kiota), [Microsoft.OpenApi.Kiota.Builder](https://junglewise.ai/threats/technologies/microsoft-openapi-kiota-builder), [Microsoft.OpenApi.Kiota (NuGet)](https://junglewise.ai/threats/technologies/nuget-microsoft-openapi-kiota), [Microsoft.OpenApi.Kiota.Builder (NuGet)](https://junglewise.ai/threats/technologies/nuget-microsoft-openapi-kiota-builder). Vendors: [Microsoft](https://junglewise.ai/threats/vendors/microsoft), [NuGet](https://junglewise.ai/threats/vendors/nuget).

## Quick answers

**Is CVE-2026-59862 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-59862 being exploited in the wild.

**How severe is CVE-2026-59862?** High severity, with a CVSS score of 7.5, published 16 July 2026.

**Which products and versions are affected?** Microsoft Kiota < 1.32.0; Microsoft Kiota.Builder < 1.32.0; Microsoft.OpenApi.Kiota < 1.32.0; Microsoft.OpenApi.Kiota.Builder < 1.32.0; and 2 more.

**Is there a fix for CVE-2026-59862?** Yes. Microsoft.OpenApi.Kiota (NuGet): upgrade to 1.32.0 or later; Microsoft.OpenApi.Kiota.Builder (NuGet): upgrade to 1.32.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-59862 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-59862?** Check whether you run Microsoft Kiota, Microsoft Kiota.Builder, Microsoft.OpenApi.Kiota or one of the others listed at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- Microsoft.OpenApi.Kiota (NuGet): upgrade to 1.32.0 or later

  ```sh
  dotnet add package Microsoft.OpenApi.Kiota --version 1.32.0
  ```

- Microsoft.OpenApi.Kiota.Builder (NuGet): upgrade to 1.32.0 or later

  ```sh
  dotnet add package Microsoft.OpenApi.Kiota.Builder --version 1.32.0
  ```


## Technical details

A code generation literal injection vulnerability exists in the Kiota Python generator due to improper sanitization of enum value descriptions. Specifically, the 'x-ms-enum.values[].description' field in an OpenAPI specification can contain unsanitized newline characters that escape Python comment contexts. This occurs because 'KiotaBuilder.SetEnumOptions' fails to call 'CleanupDescription' and 'PythonConventionService.RemoveInvalidDescriptionCharacters' does not strip carriage return or newline characters. An attacker can provide a malicious specification that, when processed, generates Python files containing arbitrary code at the module scope. This code executes automatically when the generated module is imported in a developer's environment or CI/CD pipeline. The issue is fixed in version 1.32.0.

## Affected products

- Microsoft Microsoft.OpenAPI.Kiota < 1.32.0
- Microsoft Microsoft.OpenAPI.Kiota.Builder < 1.32.0

## Identifiers

- CVE-2026-59862
- GHSA-7f3j-j7jj-r3vr

## Timeline

- 2026-06-30: disclosed
- 2026-07-16: advisory: NVD publication date
- 2026-07-24: advisory: GitHub Advisory published

## References

- [https://api.github.com/users/baywet](https://api.github.com/users/baywet)
- [https://github.com/baywet](https://github.com/baywet)
- [https://api.github.com/users/baywet/gists%7B/gist_id%7D](https://api.github.com/users/baywet/gists%7B/gist_id%7D)
- [https://api.github.com/users/baywet/repos](https://api.github.com/users/baywet/repos)
- [https://avatars.githubusercontent.com/u/7905502?v=4](https://avatars.githubusercontent.com/u/7905502?v=4)
- [https://api.github.com/users/baywet/events%7B/privacy%7D](https://api.github.com/users/baywet/events%7B/privacy%7D)

## Related threats

- [Microsoft Kiota documentation-comment injection in Java and PHP](https://junglewise.ai/threats/cve-2026-105796-kiota-is-an-openapi-based-http-client-code-generator-from-0-5-0)
- [Kiota: Unsafe oauth_card_path references in Kiota-generated API plugin manifests](https://junglewise.ai/threats/cve-2026-105795-kiota-is-an-openapi-based-http-client-code-generator-from-1-25-1)
- [Microsoft Kiota path traversal in plugin manifest via percent-encoding bypass](https://junglewise.ai/threats/cve-2026-73851-microsoft-kiota-path-traversal-in-plugin-manifest-via-percent)
- [Microsoft Kiota SSRF and File Inclusion via OpenAPI external references](https://junglewise.ai/threats/cve-2026-59867-microsoft-kiota-ssrf-and-file-inclusion-via-openapi-external)
- [Microsoft Kiota path traversal and code injection in OpenAPI generation](https://junglewise.ai/threats/cve-2026-59866-microsoft-kiota-path-traversal-and-code-injection-in-openapi)
