Code Generation Literal Injection in Kiota Ruby Generator Leads to Arbitrary Code Execution
The 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.
Developers using Kiota to generate Ruby API clients from external or untrusted OpenAPI specifications Teams with CI/CD pipelines configured to automatically regenerate client code from remote specs Applications that deploy generated Ruby code to production servers
Affected component: CodeMethodWriter.cs Root cause: The shared SanitizeForQuotedLiteral() function in Writers/StringExtensions.cs does not escape the # character
OpenAPI default fields in schema properties Property wire-name hash keys in deserializer/serializer methods Any schema-derived string embedded in Ruby double-quoted literals Severity: 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.
https://github.com/microsoft/kiota/pull/7746
If you cannot upgrade immediately:
1.32.01.32.01.32.01.32.0Exploitability
AV:NAC:LPR:NUI:NScope
S:UImpact
C:NI:NA:H7.5/CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H