Defense guide + static scanner for CVE-2026-108551 (openapi-typescript-codegen code injection).
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H<= 0.31.0Spec-derived values (path keys, parameter names, servers[0].url, info.version,
media types, response header names) are interpolated into single-quoted string
literals in generated TypeScript without escaping. A single quote in an
attacker-controlled OpenAPI document can break out of the literal and inject
JavaScript that runs at import time (via core/OpenAPI.ts) or when a generated
service method is called.
The victim is the developer or CI pipeline that generates or runs a client from an untrusted or attacker-influenced OpenAPI description. This is a supply-chain / developer-tooling issue, not a remotely reachable server bug.
poc/ contains a self-contained demonstration of import-time execution. A
crafted info.version breaks out of the single-quoted literal in
core/OpenAPI.ts and runs JavaScript when the generated client is imported.
The payload is deliberately harmless: it writes poc-executed.txt and prints a
message. It makes no network calls and accesses no secrets.
cd poc
powershell -ExecutionPolicy Bypass -File .\run-poc.ps1
Expected output includes:
[CVE-2026-108551] payload executed: poc-executed.txt written
[+] PoC CONFIRMED: attacker-controlled spec code ran at import time.
See poc/README.md for the mechanism, requirements, and safety
notes. Run it only in a disposable sandbox. The same injection class also affects
request paths, parameter names, media types, response header names, and
servers[0].url.
package.json and lockfiles for openapi-typescript-codegen and any
version <= 0.31.0.openapi, npx openapi-typescript-codegen, npm run generate, etc.).There is no fixed release yet. Options, in order of preference:
@hey-api/openapi-ts (upstream's own recommendation).npm ci/lockfiles immutable and monitor dependency changes (Dependabot,
Renovate, SBOM).Run the included static scanner over generated output before importing it:
python scripts/scan_generated.py .\generated
The scanner looks for unescaped quotes/metacharacters in generated url, BASE,
and VERSION literals. It never imports or executes the files.
Also monitor CI for:
python scripts/version_check.py 0.31.0
# AFFECTED -> migrate/remove
python scripts/scan_generated.py .\generated
# No suspicious unescaped literals found.
Rotate every secret available to the CI job or developer environment, rebuild from a clean checkout, audit generated clients and published packages for injected code, and review outbound traffic from the build runner.
data/cve.json — affected range and references.scripts/version_check.py — offline version checker.scripts/scan_generated.py — static, non-executing generated-code scanner.poc/malicious-openapi.json — crafted spec used by the educational PoC.poc/run-poc.ps1 / poc/run-poc.sh — reproducible, non-weaponized PoC harness.poc/README.md — PoC mechanism and safety notes.DISCLAIMER.md — authorized, educational use only.