{"id":"GHSA-2hx3-vp6r-mg3f","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 **\u003c 1.29.1** and **\u003e= 1.30.0, \u003c 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\u003e 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.","aliases":["CVE-2026-41134"],"modified":"2026-08-17T15:15:07.528047266Z","published":"2026-04-14T23:39:41Z","database_specific":{"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-04-14T23:39:41Z","nvd_published_at":"2026-04-22T21:17:09Z","cwe_ids":["CWE-94"]},"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"}],"affected":[{"package":{"name":"Microsoft.OpenApi.Kiota","ecosystem":"NuGet","purl":"pkg:nuget/Microsoft.OpenApi.Kiota"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"1.30.0"},{"fixed":"1.31.1"}]}],"versions":["1.30.0","1.31.0"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-2hx3-vp6r-mg3f/GHSA-2hx3-vp6r-mg3f.json"}},{"package":{"name":"Microsoft.OpenApi.Kiota.Builder","ecosystem":"NuGet","purl":"pkg:nuget/Microsoft.OpenApi.Kiota.Builder"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"1.30.0"},{"fixed":"1.31.1"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-2hx3-vp6r-mg3f/GHSA-2hx3-vp6r-mg3f.json"}},{"package":{"name":"Microsoft.OpenApi.Kiota","ecosystem":"NuGet","purl":"pkg:nuget/Microsoft.OpenApi.Kiota"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.29.1"}]}],"versions":["0.1.0-preview","0.1.1-preview","0.1.2-preview","0.1.3-preview","0.10.0-preview","0.11.0-preview","0.11.1-preview","0.2.0-preview","0.2.1-preview","0.3.0-preview","0.4.0-preview","0.5.0-preview","0.5.1-preview","0.6.0-preview","0.7.1-preview","0.8.3-preview","0.9.0-preview","1.0.0","1.0.1","1.1.0","1.1.1","1.1.2","1.1.3","1.10.0","1.10.1","1.11.0","1.11.1","1.12.0","1.13.0","1.14.0","1.15.0","1.16.0","1.17.0","1.18.0","1.19.0","1.19.1","1.2.0","1.2.1","1.20.0","1.21.0","1.22.0","1.22.1","1.22.2","1.22.3","1.23.0","1.24.0","1.24.1","1.24.2","1.24.3","1.25.1","1.26.0","1.26.1","1.27.0","1.28.0","1.29.0","1.3.0","1.4.0","1.5.0","1.5.1","1.6.1","1.7.0","1.8.0","1.8.1","1.8.2","1.9.0","1.9.1"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-2hx3-vp6r-mg3f/GHSA-2hx3-vp6r-mg3f.json"}},{"package":{"name":"Microsoft.OpenApi.Kiota.Builder","ecosystem":"NuGet","purl":"pkg:nuget/Microsoft.OpenApi.Kiota.Builder"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.29.1"}]}],"versions":["0.2.0-preview","0.3.0-preview","0.4.0-preview","0.5.0-preview","0.5.1-preview","0.6.0-preview","0.7.1-preview","1.0.0","1.0.1","1.1.0","1.1.1","1.1.2","1.1.3","1.10.0","1.10.1","1.11.0","1.11.1","1.12.0","1.13.0","1.14.0","1.15.0","1.16.0","1.17.0","1.18.0","1.19.0","1.19.1","1.2.0","1.2.1","1.20.0","1.21.0","1.22.0","1.22.1","1.22.2","1.22.3","1.23.0","1.3.0","1.4.0","1.5.0","1.5.1","1.6.1","1.7.0","1.8.0","1.8.1","1.8.2","1.9.0","1.9.1"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-2hx3-vp6r-mg3f/GHSA-2hx3-vp6r-mg3f.json"}}],"schema_version":"1.9.0","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"}]}