Skip to main content
Vulnerability Database/CVE-2026-108551

CVE-2026-108551: openapi-typescript-codegen RCE Vulnerability

CVE-2026-108551 is a code injection flaw in openapi-typescript-codegen that enables attackers to execute arbitrary JavaScript through malicious OpenAPI documents. This article covers technical details, affected versions, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-108551 Overview

CVE-2026-108551 is a code injection vulnerability [CWE-94] affecting openapi-typescript-codegen through version 0.31.0. The tool generates TypeScript clients from OpenAPI documents using Handlebars templates. Attackers who control an OpenAPI document can inject arbitrary JavaScript by supplying unescaped values interpolated into single-quoted string literals. Malicious single quotes placed in path keys, parameter names, servers[0].url, or info.version break out of the generated string context. The injected JavaScript executes when the generated client is imported or when service methods are called downstream.

Critical Impact

Arbitrary JavaScript execution in any application that generates and loads a client from an attacker-controlled OpenAPI specification.

Affected Products

  • openapi-typescript-codegen versions through 0.31.0
  • TypeScript/JavaScript clients generated from untrusted OpenAPI documents
  • Build pipelines and CI/CD systems that run openapi-typescript-codegen against third-party specifications

Discovery Timeline

  • 2026-10-10 - CVE-2026-108551 published to NVD
  • 2026-10-16 - Last updated in NVD database

Technical Details for CVE-2026-108551

Vulnerability Analysis

The vulnerability resides in the Handlebars templates that drive code generation. Templates such as src/templates/core/OpenAPI.hbs and src/templates/exportService.hbs interpolate OpenAPI document values directly into single-quoted JavaScript string literals. Handlebars escapes HTML entities by default but does not escape JavaScript string delimiters. A single quote (') inside an interpolated value therefore terminates the surrounding literal and allows arbitrary code to follow. The resulting generated .ts or .js file contains attacker-controlled JavaScript that executes when the module is imported or when a service method references the tainted constant.

Root Cause

The root cause is improper neutralization of special characters in a code generation context [CWE-94]. Handlebars {{expression}} output is suitable for HTML but unsafe when emitted into source code. The templates assume OpenAPI field values are benign strings and perform no JavaScript-aware escaping before writing them into single-quoted literals.

Attack Vector

An attacker supplies a crafted OpenAPI document to a victim who runs openapi-typescript-codegen. Injection sinks include path keys, parameter names, servers[0].url, and info.version. For example, an info.version value containing a single quote followed by arbitrary JavaScript closes the generated literal and appends executable code. When the generated client is subsequently imported into the victim application, the injected payload runs in the Node.js or browser process hosting the client.

See the VulnCheck Advisory for Code Injection and GitHub Issue #2809 Discussion for technical details and the vulnerable template sources at GitHub Template Source Code and GitHub Export Service Template.

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2026-108551

Indicators of Compromise

  • Generated TypeScript or JavaScript client files containing stray single quotes, concatenation operators, or JavaScript keywords inside what should be string literals.
  • OpenAPI documents with unusual characters (', ;, \n) in paths, parameter names, servers[].url, or info.version fields.
  • Unexpected outbound network connections or child process spawns originating from processes that import generated API clients.

Detection Strategies

  • Statically scan generated client source for syntactically anomalous string literals before committing or packaging.
  • Validate OpenAPI inputs against a strict schema that rejects control characters and quote characters in identifier-like fields.
  • Review build logs and dependency manifests for use of openapi-typescript-codegen at or below version 0.31.0.

Monitoring Recommendations

  • Monitor CI/CD runners for unexpected processes or network egress during code generation steps.
  • Alert on new or modified generated client files that deviate from established diffs or templates.
  • Track OpenAPI specification sources and flag ingestion from untrusted or newly introduced third-party providers.

How to Mitigate CVE-2026-108551

Immediate Actions Required

  • Treat all OpenAPI documents from external or untrusted sources as hostile input and do not run openapi-typescript-codegen against them.
  • Audit existing generated clients produced from third-party specifications for injected JavaScript before importing them.
  • Pin builds to run code generation in isolated, network-restricted environments to limit blast radius.

Patch Information

No fixed version is identified in the available advisory data. The upstream project is referenced at the GitHub Repository for Codegen and discussion continues in GitHub Issue #2809 Discussion. Consider migrating to an actively maintained OpenAPI client generator that performs JavaScript-aware escaping, or forking and patching the templates to escape single quotes and backslashes.

Workarounds

  • Pre-process input OpenAPI documents to reject or sanitize any values containing single quotes, backslashes, or newline characters in path keys, parameter names, servers[0].url, and info.version.
  • Modify the Handlebars templates to apply a custom helper that JSON-encodes string values before interpolation into source code literals.
  • Review and manually inspect generated client files in source control to catch injected payloads before deployment.
bash
# Example input validation step before invoking the generator
jq -e '
  (.info.version // "") as $v
  | (.servers[0].url // "") as $u
  | select(($v + $u + ([.paths | keys[]] | join(""))) | test("[\\\x27\\\\\\n\\r]") | not)
' openapi.json > validated.json

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.