/

CVE-2026-96757

Severity:

CRITICAL RISK

(9.8)

Code Injection (CWE-94) in Orval OpenAPI Generator Tool

CVE-2026-96757

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 generates JavaScript code from OpenAPI specifications without correctly escaping media-type keys placed inside single-quoted Content-Type literals. A crafted specification may therefore inject JavaScript that executes when generated fetch operations or mock resolvers are invoked.

Affected context

The vulnerability occurs in Orval code-generation workflows that process OpenAPI specifications containing attacker-controlled or insufficiently trusted media-type keys. Risk is concentrated in generated fetch clients and mock resolvers where those keys are emitted into JavaScript string literals without context-appropriate escaping.

Exploit preconditions

  • Attack surface: OpenAPI specification ingestion and JavaScript code generation
  • Required access: Ability to provide, modify, or influence an OpenAPI specification used by Orval
  • Trigger point: Invocation of a generated fetch operation or mock resolver
  • Why exploitation is possible: Crafted media-type keys are inserted into single-quoted JavaScript literals without adequate escaping, allowing generated source code to contain executable expressions

Why this happens

The underlying flaw is improper output encoding during source-code generation. Media-type values are treated as ordinary data but are emitted into JavaScript string literals without escaping characters that have syntax significance in that context. This behavior maps to CWE-94, Improper Control of Generation of Code, because untrusted specification content can alter the structure and behavior of generated JavaScript.

Potential impact

  • Generated code may execute attacker-controlled JavaScript
  • Build or test environments running generated clients may be compromised
  • Mock services could perform unintended actions when resolvers are invoked
  • Credentials, source code, or environment data may be exposed
  • Downstream applications may inherit malicious behavior through generated artifacts

General mitigation guidance

Mitigation generally focuses on treating OpenAPI specifications as untrusted

input and preserving a strict separation between data and generated code.

Common defensive patterns include:

  • Applying context-aware escaping whenever specification values enter JavaScript source
  • Using safe code-generation abstractions rather than manual string interpolation
  • Validating media-type keys against the expected syntax and rejecting unexpected characters
  • Reviewing generated artifacts before execution or distribution
  • Restricting who can modify specifications and separating generation from privileged environments
  • Running generation, tests, and mock services with least privilege and minimal secret access

How teams detect issues like this

Useful detection approaches include:

  • Static analysis for interpolated OpenAPI values inside JavaScript string literals
  • Code review checks for missing escaping at generator output boundaries
  • Specification validation policies that constrain media-type keys to valid formats
  • Tests using quotation marks, backslashes, and expression-like characters in media-type fields
  • Artifact review and CI policies that inspect generated source for unexpected executable syntax

Automated code review and security scanning tools may help identify unsafe

interpolation and missing output-encoding controls.

Sources

SourceLink
github.comgithub.com/orval-labs/orval
github.comgithub.com/orval-labs/orval/blob/v8.28.1/packages/fetch/src/index.ts#L584
github.comgithub.com/orval-labs/orval/commit/43af282d62dca0ef3140023741fb768f6a718adb
github.comgithub.com/orval-labs/orval/commit/a2d4af59f3b167dc8a7a65d15f51cdb89ebe2fe5
github.comgithub.com/orval-labs/orval/pull/4007
github.comgithub.com/orval-labs/orval/security/advisories/GHSA-4q3x-rqfw-3x8p
github.comgithub.com/orval-labs/orval/security/advisories/GHSA-rcpr-mq4m-jx9j
vulncheck.comvulncheck.com/advisories/orval-before-8.29.0-code-injection-via-unescaped-openapi-media-type

Frequently asked

questions

Generally, exploitation requires a crafted OpenAPI specification to be processed

and the resulting generated fetch operation or mock resolver to be invoked.

It is primarily a code-generation and artifact-trust issue rather than a

direct request-handling flaw.

An attacker must be able to influence the OpenAPI specification, the generation

pipeline, or an upstream source from which the specification is obtained.

The exact access requirement depends on how specifications are imported and

protected.

Treat specification values as untrusted data, validate them, and apply

context-aware escaping before emitting them into JavaScript source. Safe

generation APIs and avoidance of raw string interpolation further reduce risk.

Use schema and content validation, test generators with adversarial input,

review generated artifacts in CI, restrict specification write access, and

keep generation and runtime environments least privileged.

Find out what's already
exploitable in your codebase.