diff --git a/advisories/github-reviewed/2026/07/GHSA-7f3j-j7jj-r3vr/GHSA-7f3j-j7jj-r3vr.json b/advisories/github-reviewed/2026/07/GHSA-7f3j-j7jj-r3vr/GHSA-7f3j-j7jj-r3vr.json index 8b968855b5f..b0d0181aabd 100644 --- a/advisories/github-reviewed/2026/07/GHSA-7f3j-j7jj-r3vr/GHSA-7f3j-j7jj-r3vr.json +++ b/advisories/github-reviewed/2026/07/GHSA-7f3j-j7jj-r3vr/GHSA-7f3j-j7jj-r3vr.json @@ -7,7 +7,7 @@ "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", + "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.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", @@ -56,7 +56,7 @@ { "package": { "ecosystem": "NuGet", - "name": "Microsoft.OpenApi.Kiota" + "name": "Microsoft.OpenAPI.Kiota.Builder" }, "ranges": [ { @@ -75,7 +75,7 @@ { "package": { "ecosystem": "NuGet", - "name": "Microsoft.OpenApi.Kiota.Builder" + "name": "Microsoft.OpenAPI.Kiota" }, "ranges": [ {