openapi-typescript-codegen through 0.31.0: Code Injection Through Handlebars Templates

CVE-2026-108551 concerns openapi-typescript-codegen, a Node.js library that generates TypeScript or JavaScript clients from OpenAPI descriptions. The issue is caused by spec-derived values being inserted into single-quoted JavaScript strings without adequate escaping. An attacker who can control or influence an OpenAPI document may therefore cause JavaScript injection in generated client code. The official record describes the affected range as versions through 0.31.0, while the project repository states that the package has been unmaintained, deprecated in npm, and that users should migrate to @hey-api/openapi-ts. The record also contains a date inconsistency: its cna.datePublic is September 4, 2026, but its publication metadata and advisory date are October 10, 2026. No fixed version is identified in the supplied sources. [1] [2] [3] [4]
Quick facts
- Severity
- The official record assigns a CVSS 4.0 score of 9.3, rated Critical. It also records a CVSS 3.1 score of 9.8. These scores describe potential severity, not observed exploitation. [1]
- Affected versions
- The official affected range is openapi-typescript-codegen version 0 through 0.31.0, with the default status marked unaffected outside the stated range. The supplied sources do not identify a fixed release. [1] [4]
- Weakness
- The vulnerability is classified as CWE-94, Improper Control of Generation of Code (Code Injection). [1] [4]
- Attack input
- The issue requires an attacker-controlled or attacker-influenced OpenAPI value, including path keys, parameter names, the first server URL, or the API version. The project issue also identifies media types and response header names as affected spec-derived fields. [1] [2]
- Execution timing
- Injected code associated with service paths or parameter names may execute when an affected generated method is called. Values used in the generated OpenAPI configuration, such as the server URL or version, may execute when the generated client configuration is imported. [2] [5]
- Project status
- The repository describes the project as unmaintained, says its npm versions will be deprecated, and recommends migration to @hey-api/openapi-ts. [3]
What happened
Several Handlebars templates interpolate values originating in an OpenAPI document directly into generated JavaScript or TypeScript. In the service template, request paths and object-property names are emitted inside single-quoted strings. In the core configuration template, the server URL and API version are emitted the same way. If an inserted value contains a quote and additional JavaScript syntax, the generated source can be altered rather than treated as data. [2] [6] [5]
This is a code-generation vulnerability: the dangerous input is not necessarily supplied directly to the running application. The relevant trust boundary is the OpenAPI document consumed by the generator, including a document retrieved remotely or modified before a local or CI regeneration step. [1] [2]
Impact and prerequisites
The reported impact is arbitrary JavaScript execution in environments that generate or subsequently import the affected client. The issue report distinguishes method-call execution through request paths or parameter names from import-time execution through the generated OpenAPI configuration. Depending on where generation and execution occur, consequences could include compromise of a developer workstation, build runner, CI job, or application process. [2] [5]
An attacker must be able to control or influence an OpenAPI value processed by the generator, and the resulting generated code must then be imported or executed. The CVSS record models a network-reachable, unauthenticated scenario, but that score does not remove the practical prerequisite of getting a malicious or modified specification into the generation workflow. [1] [2]
Affected versions and defensive next steps
The official range covers openapi-typescript-codegen through 0.31.0. The supplied materials do not provide a patched release or a vendor-tested workaround. Organizations should inventory direct and transitive uses of the npm package, identify whether generated clients are built from untrusted or remotely fetched specifications, and review recent generation events and generated-code changes. [1] [4]
General operational considerations, not vendor-provided workarounds or tested fixes, include pinning trusted OpenAPI inputs, reviewing specification changes before generation, isolating code generation in restricted build environments, and preventing generated artifacts from being executed automatically without review. Migration should be evaluated because the repository itself recommends moving to @hey-api/openapi-ts, but the supplied sources do not establish that migration alone fixes this CVE. [3]
Disclosure and research context
The official record credits George Chen as the finder and points to GitHub issue #2809. That issue was opened on September 4, 2026 and reported the vulnerable template behavior across the supported HTTP client modes. It states that a fix was ready and would be submitted, but the supplied evidence does not show a merged fix, released version, or completed vendor advisory remediation. [1] [2]
Public discussion
No relevant X post with retrievable content was found in this research pass. This does not establish that no discussion exists.
Questions and answers
Am I affected?
You should treat the installation as potentially affected if you use openapi-typescript-codegen version 0.31.0 or earlier and generate clients from OpenAPI documents that could be attacker-controlled or modified by an untrusted party. Exposure is more significant when generated code is automatically imported in CI, developer environments, or production workflows. [1] [2]
What should I do now?
Inventory package versions and generation sources, restrict specifications to trusted and reviewed inputs, inspect generated-code changes, and isolate generation jobs. Also assess the project’s recommended migration path, while recognizing that the supplied sources do not confirm a fixed replacement for this specific issue. [2] [3]
Is a fix available?
No fixed version is identified in the supplied record or retrieved primary-source text. The issue report says the researcher had a fix ready, but that is not evidence of a merged patch or released remediation. [1] [2]
What is known about exploitation?
The supplied evidence confirms a code-injection condition and describes plausible execution paths, but it does not confirm exploitation in the wild, a public exploit, or an affected organization. Treat exploitation status as unknown. [1] [2]
Does the CVSS score mean every installation is remotely exploitable?
No. The score represents a standardized severity assessment. In practice, exploitation still depends on an attacker influencing an OpenAPI document and the resulting generated code being imported or executed in a reachable workflow. [1] [2]
What remains uncertain
- No relevant x.com or twitter.com post with retrievable content and a verified visible author was identified in the supplied material.
- No fixed release, merged remediation commit, vendor workaround, or confirmed exploitation report is included in the supplied sources.
- The official record’s September 4, 2026 cna.datePublic conflicts with its October 10, 2026 publication metadata and advisory date.
Research sources
- Official CVE record CVE-2026-108551
- Code injection via unescaped spec-derived strings in generated clients (RCE from an untrusted OpenAPI spec)
- GitHub - ferdikoomen/openapi-typescript-codegen: NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification · GitHub
- openapi-typescript-codegen through 0.31.0 Code Injection via Handlebars Templates | Advisories | VulnCheck
- github.com
- github.com
Description
openapi-typescript-codegen through 0.31.0 contains a code injection vulnerability that allows attackers controlling an OpenAPI document to inject JavaScript by supplying unescaped values interpolated into single-quoted string literals. Attackers can embed a single quote in path keys, parameter names, servers[0].url, or info.version to execute arbitrary JavaScript when generated clients are imported or service methods called.
Severity (CVSS)
| Base score | 9.3 |
|---|---|
| Severity | Critical |
| Version | CVSS 4.0 |
| Vector | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| Provided by | CNA |
Weaknesses
- CWE-94 — Improper Control of Generation of Code ('Code Injection')
Affected products
| Vendor | Product | Versions |
|---|---|---|
| ferdikoomen | openapi-typescript-codegen | 0 to <=0.31.0 [affected] |
References
- https://github.com/ferdikoomen/openapi-typescript-codegen/issues/2809 (issue-tracking)
- https://github.com/ferdikoomen/openapi-typescript-codegen (product)
- https://github.com/ferdikoomen/openapi-typescript-codegen/blob/v0.31.0/src/templates/exportService.hbs#L89-L110 (technical-description)
- https://github.com/ferdikoomen/openapi-typescript-codegen/blob/v0.31.0/src/templates/core/OpenAPI.hbs#L20-L23 (technical-description)
- https://www.vulncheck.com/advisories/openapi-typescript-codegen-through-0.31.0-code-injection-via-handlebars-templates (third-party-advisory)
Assess this vulnerability
Compare your deployed product and version with the source record. Review vendor references for fixes and workarounds. A CVSS score describes technical severity; it does not establish that your systems are affected or that exploitation has occurred.
Browse all CVE security advisories · Symaro cybersecurity services
Generated from the official CVE List on 12 Oct 2026 10:15 UTC.