{"id":"CVE-2026-59861","aliases":["CVE-2026-59861","GHSA-xg2h-5xr2-29jw"],"related":[],"kind":"vulnerability","state":"published","title":"Kiota: Code Generation Literal Injection in Kiota Ruby Generator","summary":"Kiota is an OpenAPI based HTTP Client code generator. Prior to 1.29.1 and 1.32.0, Kiota's Ruby generator embedded OpenAPI default fields, property names, and other schema-derived strings through CodeMethodWriter.cs and SanitizeForQuotedLiteral() in Writers/StringExtensions.cs into Ruby double-quoted literals without escaping #, allowing attacker-controlled #{expr}, #$var, or #@var interpolation markers to inject arbitrary Ruby code into generated model classes. This issue is fixed in version 1.29.1 and 1.32.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Kiota is an OpenAPI based HTTP Client code generator. Prior to 1.29.1 and 1.32.0, Kiota's Ruby generator embedded OpenAPI default fields, property names, and other schema-derived strings through CodeMethodWriter.cs and SanitizeForQuotedLiteral() in Writers/StringExtensions.cs into Ruby double-quoted literals without escaping #, allowing attacker-controlled #{expr}, #$var, or #@var interpolation markers to inject arbitrary Ruby code into generated model classes. This issue is fixed in version 1.29.1 and 1.32.0.","source":"cvelist"},{"lang":"en","text":"Code Generation Literal Injection in Kiota Ruby Generator Leads to Arbitrary Code Execution\n\n# Impact\n\nThe Kiota Ruby code generator is vulnerable to a code generation literal injection attack. The generator embeds string values from OpenAPI default fields and property names directly into Ruby double-quoted string literals without properly escaping the # character. Since Ruby evaluates string interpolation expressions like #{expr}, #$var, and #@var within double-quoted strings at runtime, an attacker who controls an OpenAPI specification file can inject arbitrary Ruby code into generated model classes.\n\n# Who is impacted\n\nDevelopers using Kiota to generate Ruby API clients from external or untrusted OpenAPI specifications\nTeams with CI/CD pipelines configured to automatically regenerate client code from remote specs\nApplications that deploy generated Ruby code to production servers\n\n# Vulnerability details\n\nAffected component: CodeMethodWriter.cs\nRoot cause: The shared SanitizeForQuotedLiteral() function in Writers/StringExtensions.cs does not escape the # character\n\n# Attack vectors\n\nOpenAPI default fields in schema properties\nProperty wire-name hash keys in deserializer/serializer methods\nAny schema-derived string embedded in Ruby double-quoted literals\nSeverity: Critical when generated code reaches production; High for CI/CD environments with access to production secrets; Medium for public third-party specs; Low for developer-controlled specs.\n\n# Patches\n\nhttps://github.com/microsoft/kiota/pull/7746\n\n# Workarounds\n\nIf you cannot upgrade immediately:\n\n1. Audit and sanitize OpenAPI specifications: Review all OpenAPI specification files for any default values or property names containing the # character. Remove or replace any suspicious strings before code generation.\n1. Code review of generated files: Implement mandatory code review of all generated Ruby files before merging into any branch. Look for double-quoted strings containing #{, #$, or #@ patterns.\n1. Restrict specification sources: Only consume OpenAPI specifications from trusted internal sources. Avoid automatic code generation from external or third-party APIs until this patch is applied.\n1. Isolate generated code from production: Do not deploy generated Ruby models to production environments unless the specification source has been verified and reviewed.\n1. Manual escaping (temporary): If regeneration is not possible, manually inspect and edit generated files to escape any # characters in string literals (replace # with \\# in double-quoted strings).\n\n# Remediation\n\nUpgrade Kiota to 1.29.1, 1.32.0, or later.\nRegenerate/refresh existing generated clients as a precaution:\n\n```shell\nkiota update\n```\n\nRefreshing generated clients ensures previously generated vulnerable code is replaced with hardened output.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Kiota es un generador de código de cliente HTTP basado en OpenAPI. Antes de la versión 1.32.0, el generador Ruby de Kiota incrustaba campos predeterminados de OpenAPI, nombres de propiedades y otras cadenas derivadas del esquema a través de CodeMethodWriter.cs y SanitizeForQuotedLiteral() en Writers/StringExtensions.cs en literales de Ruby entre comillas dobles sin escapar #, permitiendo que los marcadores de interpolación #{expr}, #$var o #@var controlados por el atacante inyectaran código Ruby arbitrario en las clases de modelo generadas. Este problema se corrigió en la versión 1.32.0.","source":"nvd"}],"published":"2026-07-16T14:36:32.010Z","modified":"2026-10-24T21:10:00.130Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-94"],"affected":[{"ranges":[{"version":">= 1.30.0, < 1.31.1","status":"affected"},{"version":"< 1.29.1","status":"affected"}],"vendor":"microsoft","product":"kiota","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"1.30.0","status":"affected","fixed":"1.32.0"}],"ecosystem":"NuGet","package":"Microsoft.OpenAPI.Kiota","purl":"pkg:nuget/Microsoft.OpenAPI.Kiota","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"1.30.0","status":"affected","fixed":"1.32.0"}],"ecosystem":"NuGet","package":"Microsoft.OpenAPI.Kiota.Builder","purl":"pkg:nuget/Microsoft.OpenAPI.Kiota.Builder","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.29.1"}],"ecosystem":"NuGet","package":"Microsoft.OpenApi.Kiota","purl":"pkg:nuget/Microsoft.OpenApi.Kiota","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.29.1"}],"ecosystem":"NuGet","package":"Microsoft.OpenApi.Kiota.Builder","purl":"pkg:nuget/Microsoft.OpenApi.Kiota.Builder","source":"ghsa"}],"references":[{"url":"https://github.com/microsoft/kiota/security/advisories/GHSA-xg2h-5xr2-29jw","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/microsoft/kiota/pull/7746","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/microsoft/kiota/commit/fee1b648bb4394ba7ba72de9c0ce4f2a0bad0cb6","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/microsoft/kiota/releases/tag/v1.32.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59861","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/microsoft/kiota","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"total","date":"2026-07-17T03:56:35.781Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-59861","url":"https://www.cve.org/CVERecord?id=CVE-2026-59861","licence":"CVE Terms of Use","modified":"2026-08-17T15:02:02.208Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xg2h-5xr2-29jw","url":"https://github.com/advisories/GHSA-xg2h-5xr2-29jw","licence":"CC-BY-4.0","modified":"2026-08-17T15:00:07.956Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-59861","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59861","licence":"Public domain","modified":"2026-10-24T21:10:00.130Z"}],"updatedAt":"2026-11-25T22:59:28.389Z","epss":{"score":0.01452,"percentile":0.74176,"date":"2026-12-01T12:00:22.000Z"}}