/

CVE-2026-96759

Severity:

CRITICAL RISK

(9.8)

Code Injection (CWE-94) in Orval TanStack Generators

CVE-2026-96759

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary JavaScript Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Orval versions before 8.29.0 do not properly escape the OpenAPI operationId when placing it into generated TanStack Query mutator-options metadata. A crafted specification may therefore inject JavaScript that executes when an affected generated hook is called, potentially compromising applications or development workflows.

Affected context

The vulnerability occurs in Orval-generated TanStack Query client code when an OpenAPI specification contains a specially crafted operationId. Risk is highest where specifications are accepted from untrusted sources, retrieved from third-party repositories, or incorporated into automated code-generation pipelines without review. The injected content may remain dormant until the corresponding generated hook is invoked.

Exploit preconditions

  • Attack surface: OpenAPI-to-TypeScript code generation and generated TanStack Query hooks
  • Required access: Ability to supply, modify, or influence an OpenAPI specification used by Orval
  • Trigger point: Invocation of a generated hook whose metadata contains the unsafely emitted operationId
  • Why exploitation is possible: The operationId is inserted into generated JavaScript without adequate escaping, allowing specification data to be interpreted as executable code

Why this happens

The underlying bug is a failure to treat an OpenAPI operationId as untrusted data when generating JavaScript source code. Instead of encoding the value as a safe string literal or applying context-appropriate escaping, the generator emits it into a metadata object in a way that can alter the resulting program. This behavior maps to CWE-94: Improper Control of Generation of Code, because attacker-influenced specification content crosses into generated executable code.

Potential impact

  • Arbitrary JavaScript may execute when affected generated hooks are called
  • Application data or credentials may be exposed
  • Browser-session actions may be performed in the context of the affected application
  • Build, test, or development environments could be compromised if generated code is executed there
  • Downstream consumers may receive compromised generated client code

General mitigation guidance

Mitigation generally focuses on preserving a strict boundary between specification data and generated source code.

Common defensive patterns include:

  • Encode operationId values as safe JavaScript string literals rather than concatenating raw text
  • Apply context-aware escaping to every specification field emitted into executable code
  • Validate operationId values against a conservative identifier policy before generation
  • Treat OpenAPI documents from external or mutable sources as untrusted input
  • Review generated code before execution and isolate generation workflows with minimal privileges
  • Prefer secure-by-default generator settings that reject or safely encode unexpected metadata
  • Limit credentials, filesystem access, and network permissions available to code-generation and test environments

How teams detect issues like this

Detection can combine source inspection, generated-artifact review, and pipeline controls:

  • Use static analysis to identify raw specification values concatenated into JavaScript or TypeScript source
  • Review generator code for missing string-literal encoding around operationId and related metadata fields
  • Compare generated output against expected syntax and flag unexpected executable constructs
  • Add policy checks that validate operationId values and reject unsafe characters or malformed identifiers
  • Scan pull requests and generated artifacts for specification-controlled code changes
  • Use automated code-review or security-analysis tools to identify code-generation injection patterns

Sources

SourceLink
github.comgithub.com/orval-labs/orval
github.comgithub.com/orval-labs/orval/blob/v8.28.1/packages/query/src/query-generator.ts#L784
github.comgithub.com/orval-labs/orval/commit/b28c53f3e0c06190e0f6ea136737e6316432448f
github.comgithub.com/orval-labs/orval/pull/4008
github.comgithub.com/orval-labs/orval/security/advisories/GHSA-vv88-cm6j-665j
vulncheck.comvulncheck.com/advisories/orval-before-8.29.0-code-injection-via-operationid

Frequently asked

questions

It can be exploitable through a remotely supplied or compromised OpenAPI specification, but execution generally requires that the specification be processed and the affected generated hook be invoked in a relevant environment.

An attacker must be able to influence the OpenAPI document, such as through an untrusted upload, a compromised dependency repository, or a writable API-specification pipeline.

Treat all specification fields as data and emit them using context-appropriate JavaScript string-literal encoding, with validation applied before code generation.

Use trusted specification sources, review generated artifacts, enforce identifier policies, run generation with least privilege, and add automated checks for unescaped values entering executable code.

Find out what's already
exploitable in your codebase.