CVE-2026-59862: CWE-94: Improper Control of Generation of Code ('Code Injection') in microsoft kiota
Kiota is an OpenAPI based HTTP Client code generator. Prior to 1.29.1 and 1.32.0, Kiota's Python generator let attacker-controlled enum value descriptions from x-ms-enum.values[].description flow through KiotaBuilder.SetEnumOptions into Documentation.DescriptionTemplate and PythonConventionService.RemoveInvalidDescriptionCharacters without newline sanitization, allowing generated inline comments to split and execute attacker-controlled Python code at module scope when generated modules were imported. This issue is fixed in version 1.29.1 and 1.32.0.
AI Analysis
Technical Summary
The Kiota Python generator improperly handles enum value descriptions from the x-ms-enum.values[].description field in OpenAPI specifications. Specifically, newline characters are not sanitized, allowing attacker-controlled input to break out of comment contexts and inject executable Python code at the module scope. This code executes upon import of the generated Python module. The vulnerability requires user interaction in generating and importing code from a malicious specification, commonly occurring in development or CI workflows. The root cause is twofold: a missing cleanup step for enum descriptions and incomplete sanitization of newline characters in Python code generation. Exploitation vectors include consuming malicious OpenAPI specs from attacker-controlled URLs or supply-chain scenarios. The vendor has released patches in Kiota versions 1.29.1, 1.32.0, and later to address this issue.
Potential Impact
Successful exploitation allows arbitrary Python code execution at import time of generated client modules. This can lead to credential theft, exfiltration of environment variables and secrets, source code disclosure, and persistent backdoors via regenerated client code. The impact primarily affects developers and CI/CD pipelines that generate and import Python SDKs from untrusted or malicious OpenAPI specifications.
Mitigation Recommendations
Upgrade Kiota to version 1.29.1, 1.32.0, or later to apply the official fix. Regenerate any previously generated Python clients to remove vulnerable code. If immediate upgrade is not possible, only generate clients from trusted, internally controlled OpenAPI specifications, disable or gate automatic generation from remote specs in CI/CD pipelines, validate and sanitize x-ms-enum descriptions before generation, and review generated Python files for suspicious top-level code near enum declarations. Run generation and validation in isolated environments without access to production secrets. Confirm after upgrade that malicious multi-line enum descriptions no longer produce executable top-level output.
CVE-2026-59862: CWE-94: Improper Control of Generation of Code ('Code Injection') in microsoft kiota
Description
Kiota is an OpenAPI based HTTP Client code generator. Prior to 1.29.1 and 1.32.0, Kiota's Python generator let attacker-controlled enum value descriptions from x-ms-enum.values[].description flow through KiotaBuilder.SetEnumOptions into Documentation.DescriptionTemplate and PythonConventionService.RemoveInvalidDescriptionCharacters without newline sanitization, allowing generated inline comments to split and execute attacker-controlled Python code at module scope when generated modules were imported. This issue is fixed in version 1.29.1 and 1.32.0.
CVSS v3.1
Score 7.5high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The Kiota Python generator improperly handles enum value descriptions from the x-ms-enum.values[].description field in OpenAPI specifications. Specifically, newline characters are not sanitized, allowing attacker-controlled input to break out of comment contexts and inject executable Python code at the module scope. This code executes upon import of the generated Python module. The vulnerability requires user interaction in generating and importing code from a malicious specification, commonly occurring in development or CI workflows. The root cause is twofold: a missing cleanup step for enum descriptions and incomplete sanitization of newline characters in Python code generation. Exploitation vectors include consuming malicious OpenAPI specs from attacker-controlled URLs or supply-chain scenarios. The vendor has released patches in Kiota versions 1.29.1, 1.32.0, and later to address this issue.
Potential Impact
Successful exploitation allows arbitrary Python code execution at import time of generated client modules. This can lead to credential theft, exfiltration of environment variables and secrets, source code disclosure, and persistent backdoors via regenerated client code. The impact primarily affects developers and CI/CD pipelines that generate and import Python SDKs from untrusted or malicious OpenAPI specifications.
Mitigation Recommendations
Upgrade Kiota to version 1.29.1, 1.32.0, or later to apply the official fix. Regenerate any previously generated Python clients to remove vulnerable code. If immediate upgrade is not possible, only generate clients from trusted, internally controlled OpenAPI specifications, disable or gate automatic generation from remote specs in CI/CD pipelines, validate and sanitize x-ms-enum descriptions before generation, and review generated Python files for suspicious top-level code near enum declarations. Run generation and validation in isolated environments without access to production secrets. Confirm after upgrade that malicious multi-line enum descriptions no longer produce executable top-level output.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-07-07T15:41:53.606Z
- Cvss Version
- 3.1
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a58ef3568715ace43306155
Added to database: 07/16/2026, 14:48:21 UTC
Last enriched: 08/17/2026, 16:25:07 UTC
Last updated: 08/30/2026, 22:52:12 UTC
Views: 96
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.