Vulnerabilities in pkg:npm/@orpc/openapi

PACKAGE
Advisory Identifier: GHSA-7f6v-3gx7-27q8
Advisory Summary

CVE-2026-33331 is a HIGH (CVSS 8.2) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting @orpc/openapi libraries in the npm ecosystem. The issue involves orpc has stored xss in openapi reference plugin via unescaped json.stringify. Remediation is available by upgrading affected packages to version 1.13.9.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@orpc/openapi

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@orpc/openapi. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-7f6v-3gx7-27q8 CVE-2026-33331 HIGH oRPC has Stored XSS in OpenAPI Reference Plugin via unescaped JSON.stringify

CVE-2026-33331 at a Glance

CVE Identifier CVE-2026-33331
GHSA Identifier GHSA-7f6v-3gx7-27q8
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product @orpc/openapi
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-33331

To remediate this vulnerability, upgrade all affected @orpc/openapi dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@orpc/openapi fixed: 1.13.9
npm install @orpc/openapi@1.13.9
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @orpc/openapi

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-33331, inspect your project dependencies using npm:

npm ls @orpc/openapi

Analyze the terminal output to locate any version of @orpc/openapi in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.13.9), your application is affected.

Note: The npm ls @orpc/openapi command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In @orpc/openapi, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

A Stored Cross-Site Scripting (XSS) vulnerability exists in the OpenAPI documentation generation of orpc. If an attacker can control any field within the OpenAPI specification (such as info.description), they can break out of the JSON context and execute arbitrary JavaScript when a user views the generated API documentation. In the packages/openapi/src/plugins/openapi-reference.ts file, the renderDocsHtml() function takes an OpenAPI spec object and embeds it directly into the HTML response using a template literal: `<script id="spec" type="application/json">${JSON.stringify(spec)}</script>` The JSON.stringify() function does not escape HTML characters like < or >. Therefore, if an attacker provides a string containing </script><script>..., the browser will prematurely close the application/json script block and execute the subsequent malicious script block. Proof of Concept (PoC) 1. Create an API router with **orpc** and configure the OpenAPI plugin. 2. In the API specification, inject a malicious payload into a field like **description**: ``` { info: { title: "My API", version: "1.0.0", description: "</script><script>alert('XSS executed on ' + document.domain)</script>" } } ``` 3. Generate and serve the documentation HTML. 4. When a developer or user navigates to the API documentation URL, the browser parses the HTML, breaks out of the JSON block, and immediately executes the **alert()** payload. Impact If an application generates its OpenAPI specifications dynamically based on user-controlled inputs (or if a rogue developer modifies the spec), it leads to Stored XSS. When an administrator or developer views the API docs, the script executes in their browser, potentially leading to session hijacking or unauthorized API calls on their behalf. Remediation Do not use raw **JSON.stringify()** to embed data directly into HTML templates. Instead, safely serialize the JSON by escaping HTML-sensitive characters (like **<** and **>**) or use a secure HTML serialization library (such as **serialize-javascript** or **devalue**) before embedding it into the **<script>** tag. Disclosure & Credits If this report is helpful, I kindly request that you publish this as a formal GitHub Security Advisory and assign me credit for the discovery. Thank you for maintaining this project!

CVE-2026-33331 Affected @orpc/openapi Versions

1 component(s)
Fixed Versions:
1.13.9
Product / Package Ecosystem Affected Versions Fixed Version
@orpc/openapi
npm
< 1.13.9
1.13.9

References

Frequently Asked Questions

What is CVE-2026-33331?
CVE-2026-33331 is a security vulnerability in @orpc/openapi involving oRPC has Stored XSS in OpenAPI Reference Plugin via unescaped JSON.stringify under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which @orpc/openapi versions are affected?
Affected versions include releases prior to 1.13.9 across affected packages: @orpc/openapi.
What version fixes CVE-2026-33331?
Upgrading to 1.13.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @orpc/openapi affected?
Yes, @orpc/openapi is affected in releases prior to 1.13.9. Upgrade your dependency to 1.13.9 or later.
What is the CVSS score of CVE-2026-33331?
CVE-2026-33331 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N.
What CWE is associated with CVE-2026-33331?
CVE-2026-33331 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2026-33331?
Run the dependency tree command: 'npm ls @orpc/openapi'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7f6v-3gx7-27q8",
  "modified" : "2026-03-27T21:58:58Z",
  "published" : "2026-03-20T17:25:56Z",
  "aliases" : [ "CVE-2026-33331" ],
  "summary" : "oRPC has Stored XSS in OpenAPI Reference Plugin via unescaped JSON.stringify",
  "details" : "A Stored Cross-Site Scripting (XSS) vulnerability exists in the OpenAPI documentation generation of orpc. If an attacker can control any field within the OpenAPI specification (such as info.description), they can break out of the JSON context and execute arbitrary JavaScript when a user views the generated API documentation.\nIn the packages/openapi/src/plugins/openapi-reference.ts file, the renderDocsHtml() function takes an OpenAPI spec object and embeds it directly into the HTML response using a template literal:\n\n`<script id=\"spec\" type=\"application/json\">${JSON.stringify(spec)}</script>`\n\nThe JSON.stringify() function does not escape HTML characters like < or >. Therefore, if an attacker provides a string containing </script><script>..., the browser will prematurely close the application/json script block and execute the subsequent malicious script block.\n\nProof of Concept (PoC)\n\n1. Create an API router with **orpc** and configure the OpenAPI plugin.\n2. In the API specification, inject a malicious payload into a field like **description**:\n\n```\n{\ninfo: {\ntitle: \"My API\",\nversion: \"1.0.0\",\ndescription: \"</script><script>alert('XSS executed on ' + document.domain)</script>\"\n}\n}\n```\n\n3. Generate and serve the documentation HTML.\n4. When a developer or user navigates to the API documentation URL, the browser parses the HTML, breaks out of the JSON block, and immediately executes the **alert()** payload.\n\nImpact\n\nIf an application generates its OpenAPI specifications dynamically based on user-controlled inputs (or if a rogue developer modifies the spec), it leads to Stored XSS. When an administrator or developer views the API docs, the script executes in their browser, potentially leading to session hijacking or unauthorized API calls on their behalf.\n\nRemediation\n\nDo not use raw **JSON.stringify()** to embed data directly into HTML templates. Instead, safely serialize the JSON by escaping HTML-sensitive characters (like **<** and **>**) or use a secure HTML serialization library (such as **serialize-javascript** or **devalue**) before embedding it into the **<script>** tag.\n\nDisclosure & Credits\n\nIf this report is helpful, I kindly request that you publish this as a formal GitHub Security Advisory and assign me credit for the discovery. Thank you for maintaining this project!",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@orpc/openapi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.13.9"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.13.8"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/middleapi/orpc/security/advisories/GHSA-7f6v-3gx7-27q8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33331"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/middleapi/orpc/commit/4f0efa8a1d3fa8e8317a4b03cc3945a5dfd68add"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/middleapi/orpc"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/middleapi/orpc/releases/tag/v1.13.9"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-20T17:25:56Z",
    "nvd_published_at" : "2026-03-24T20:16:28Z"
  }
}