Executive brief
Orval is a code generator that creates API clients from OpenAPI specifications. When configured to extract the base URL from the OpenAPI spec's `servers[].url` field, Orval fails to escape backticks and template expressions, allowing an attacker who controls the OpenAPI specification to inject and execute arbitrary JavaScript code in any application that uses the generated client. This affects teams integrating untrusted or attacker-influenced API specifications into their build pipeline.
Technical details
Orval generates HTTP client code with URL construction using JavaScript template literals. When the `output.baseUrl.getBaseUrlFromSpecification: true` option is enabled, the server URL from the OpenAPI specification's `servers[0].url` field is embedded directly into a template literal without escaping backticks or `${` sequences. An attacker who can influence the OpenAPI specification (via a malicious endpoint, compromised registry, or supply-chain attack) can inject a backtick followed by arbitrary JavaScript expressions, which closes the template literal and allows code injection. For example, a server URL like `` `http://api.x/` + (globalThis.X = require("fs").writeFileSync("/marker","pwned")) + `/v1/u` `` will execute the injected code when the generated client functions are called. The vulnerability requires the specific configuration option to be enabled, but no authentication is needed and the attack succeeds even with default OpenAPI validation. Patches are available in version 8.21.0 and later; the fix involves properly escaping the server URL before embedding it into the template literal or validating the URL structure.
Affected products
- orval-labs orval < 8.21.0
Timeline
- 2026-07-12: disclosed: Vulnerability initially published to GitHub Advisory Database
- 2026-08-19: advisory: Published to National Vulnerability Database (NVD)
- 2026-09-03: advisory: GitHub Advisory review completed and published
- 2026-09-03: patched: Patch released in Orval v8.21.0 (commit 8ef1bfd)