Summary
Orval versions before 8.22.0 resolve external OpenAPI and Swagger references without sufficiently restricting their destinations. Processing an attacker-controlled API description may cause a developer or CI host to contact internal or attacker-selected services, read local files outside the intended input directory, or include untrusted schemas in generated clients.
Affected context
The issue occurs in Orval's external reference loading during OpenAPI v3 or Swagger v2 processing. Risk is present when a developer, build pipeline, or automated generation service processes an API specification that can be modified by an untrusted party, and when referenced resources are resolved without an allowlist or confinement to the specification's input directory.
Exploit preconditions
- Attack surface: Orval's external
$refresolution in the specification import and client-generation workflow - Required access: Ability to provide or influence an OpenAPI or Swagger description processed by Orval
- Trigger point: Loading remote or local external references during specification parsing
- Why exploitation is possible: Reference targets are resolved without adequate destination allowlisting or path confinement, allowing requests to selected services and access to absolute or out-of-tree local paths
Why this happens
The underlying bug is unrestricted external resource resolution. A document-processing component treats reference locations supplied by input as trusted paths or URLs instead of applying an explicit policy for permitted schemes, hosts, and filesystem boundaries.
This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because local references may escape the intended input directory. The behavior also relates to CWE-918: Server-Side Request Forgery for network retrieval and CWE-829: Inclusion of Functionality from Untrusted Control Sphere when untrusted schemas are incorporated into generated output.
Potential impact
- The developer or CI host may make requests to internal or attacker-controlled services
- Sensitive local files may be disclosed to the generation process or incorporated into output
- Generated clients may contain attacker-controlled schemas or types
- Build metadata, credentials, or network-service information could be exposed
- Downstream applications may inherit unsafe or misleading generated code
General mitigation guidance
Mitigation generally focuses on reducing trust in external references and enforcing explicit resource-resolution boundaries.
Common defensive patterns include:
- Allowing only approved URL schemes, hosts, and reference locations
- Confining local reference resolution to a designated input directory
- Rejecting absolute paths, parent-directory escapes, and unexpected redirects
- Separating specification retrieval from code generation and reviewing retrieved content
- Running generation in a least-privilege, network-restricted build environment
- Treating generated artifacts and remote schemas as untrusted until validated
- Applying strict schema and content validation before references are resolved or inlined
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis rules for filesystem access and HTTP requests driven by
$refvalues - Code review checks for missing URL allowlists, path canonicalization, and directory-boundary validation
- Tests covering absolute paths, parent-directory traversal, redirects, non-HTTP schemes, and internal destinations
- CI policies that isolate document-generation jobs from sensitive files and private network ranges
- Network monitoring for unexpected outbound requests during client generation
- Dependency and automated code-review tools that flag SSRF, path traversal, and untrusted resource inclusion patterns

