The vulnerability, CVE-2026-62681, is a code injection flaw in Orval, a tool that generates client code from OpenAPI specifications. The root cause is the failure to properly escape special characters (backticks, ${, and single quotes) in values taken from the OpenAPI specification before embedding them into JavaScript template literals and strings in the generated code. An attacker with control over the OpenAPI specification could insert malicious strings into fields like paths, servers, or schema default values. When Orval generates the client, these malicious strings become part of the code. When the generated client code is executed (e.g., by making an API call), the injected code runs, leading to Remote Code Execution (RCE).
The patch addresses this by consistently applying escaping mechanisms at the boundaries where spec-controlled data is inserted into generated code. The jsesc library is introduced to safely escape strings for embedding within JavaScript template literals (`...`) and regular strings. The analysis of the commit 8ef1bfdf3f9bcaf9dabfbe2e42887f1c0e159ab6 reveals several key functions that were modified to implement this escaping:
getRoute and getFullRoute in packages/core/src/getters/route.ts: These functions are responsible for constructing the request URL from the OpenAPI path and server definitions. Before the patch, they did not escape backticks or ${ sequences, making them the primary sinks for the template literal injection.
getKey and getRouteAsArray in packages/core/src/getters/keys.ts and route.ts: These functions handled string manipulation for generating keys and array-based routes. They were vulnerable to injection by not escaping single quotes, allowing an attacker to break out of a string literal.
generateZodValidationSchemaDefinition in packages/zod/src/index.ts: This function generates Zod validation schemas. It was vulnerable because it improperly handled default values and object property keys from the schema, allowing for template literal and object key injection.