highCVSS 7.1Vulnerability

GHSA-2q42-4q24-7rgv

### Summary The `@typespec/openapi3` emitter retains the value of a `@versioned` enum member and interpolates it into the output filename as `{version}` without sanitizing path separators or traversal components. The completed path reaches the compiler's `emitFile()`, which creates the parent directory and writes the file without verifying containment under `emitterOutputDir`. A crafted declarative `.tsp` input can therefore create or overwrite an OpenAPI-formatted `.yaml` or `.json` file outside the configured output tree, subject to the compiler process's filesystem permissions. No executable TypeSpec extension or attacker-controlled JavaScript is required. ### Affected version Confirmed on: - `@typespec/compiler` `1.15.0` - `@typespec/openapi3` `1.15.0` - `@typespec/http` `1.15.0` - `@typespec/versioning` `0.85.0` - release tag commit `f30cd352f93997e04c75d48c7ace6947a1d5d07a` The critical `openapi.ts` and `emitter-utils.ts` blobs are unchanged on main commit `365ec52b50b82cd9e1e037de4c6fcd5de7e32e90` as checked on 2026-08-19. No patched version was identified. ### Root cause The value originates at `packages/openapi3/src/openapi.ts:592-608`: ```ts serviceRecord.versions.push({ service, version: snapshot.version!.value, document: document[0], diagnostics: document[1], }); ``` It is interpolated without path validation at `openapi.ts:629-641`: ```ts return interpolatePath(options.outputFile, { "openapi-version": specVersion, "service-name-if-multiple": multipleService ? getNamespaceFullName(service.type) : undefined, "service-name": getNamespaceFullName(service.type), "file-type": fileType, version, }); ``` The path reaches `emitFile()` at `openapi.ts:392-401`. The sink at `packages/compiler/src/core/emitter-utils.ts:29-39` performs no output-root containment check: ```ts const outputFolder = getDirectoryPath(options.path); await program.host.mkdirp(outputFolder); return await program.host.writeFile(options.path, content); ``` `reso

Properties

ghsa_id
GHSA-2q42-4q24-7rgv
severity
high
summary
OpenAPI3 version value escapes `emitterOutputDir` and overwrites YAML/JSON outside the output tree
cvss_score
7.1
cve_id
GHSA-2q42-4q24-7rgv
cvss_vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H
is_ghsa_only
true
ghsa_published
2026-09-08T21:31:09Z
source_url
https://github.com/advisories/GHSA-2q42-4q24-7rgv
ghsa_updated
2026-09-08T21:31:10Z

Related Entities (7)

VULNERABLE_TO (2)

[Software]npm/@typespec/openapi3
[Software]npm/@typespec/compiler

AFFECTS (2)

[Software]npm/@typespec/compiler
[Software]npm/@typespec/openapi3

HAS_WEAKNESS (2)

[Weakness]Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
[Weakness]External Control of File Name or Path

REPORTED_BY (1)

[Source]GitHub Advisory Database

Explore deeper with Ninja Signal's threat intelligence graph

GHSA-2q42-4q24-7rgv (CVSS 7.1) — Ninja Signal Threat Intelligence | Ninja Signal