/

CVE-2026-33331

Severity:

HIGH RISK

(8.2)

XSS in oRPC OpenAPI Documentation Generation

CVE-2026-33331

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Stored Cross-Site Scripting leading to arbitrary JavaScript execution in users' browsers

Severity:

HIGH RISK

(8.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A stored cross-site scripting (XSS) issue in oRPC's OpenAPI documentation generation allows attacker-controlled fields in the OpenAPI specification (for example, info.description) to be embedded unsafely into the generated docs.

When victims view the affected API documentation in a browser, the injected payload can execute arbitrary JavaScript in their context.

Affected context

The vulnerability occurs in environments where oRPC is used to generate interactive or rendered OpenAPI documentation and where parts of the OpenAPI spec can be influenced by external or semi-trusted input.

It is particularly relevant when metadata fields like info.description, title, tags, or operation descriptions are populated from user-provided content, external config sources, or dynamically generated values that are not strictly sanitized or escaped before being rendered in the browser.

Exploit preconditions

  • Attack surface: Web-based API documentation generated by oRPC.
  • Required access: Ability to control at least one field within the OpenAPI specification (e.g., info.description, endpoint descriptions, parameter descriptions).
  • Trigger point: A user (developer, operator, or customer) opens the generated API documentation in a browser that renders the compromised OpenAPI content.
  • Why exploitation is possible: The documentation generation process embeds OpenAPI fields into a JSON/HTML/JavaScript context without consistently applying proper escaping or encoding, allowing crafted content to break out of the expected data context and execute as script.

Why this happens

The underlying issue maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).

oRPC's documentation generator treats OpenAPI specification fields as benign text and injects them into a client-side context without sufficient output encoding for the specific sink (JSON-in-script, HTML, or template).

As a result, attacker-controlled values in fields like info.description can contain characters or sequences that terminate the intended context and introduce executable JavaScript code that runs when the documentation page is loaded.

Potential impact

  • Execution of arbitrary JavaScript in the context of the documentation viewer's browser.
  • Theft of sensitive information accessible from the documentation page (e.g., API keys or tokens exposed in local storage or UI).
  • Session hijacking or impersonation of logged-in users of the documentation portal.
  • Injection of malicious content that misleads developers about API behavior (e.g., spoofed endpoints or instructions).
  • Pivoting to further client-side attacks, such as redirecting users to phishing pages.

General mitigation guidance

Effective mitigation strategies focus on strict output encoding and reducing trust in OpenAPI metadata:

  • Encode all OpenAPI-derived fields according to their rendering sink (HTML-escape for DOM insertion, JSON-escape for embedding in script, attribute-escape for attributes).
  • Avoid directly inserting specification text into raw HTML or script contexts; use templating systems or components that handle escaping by default.
  • Treat OpenAPI metadata as untrusted input by default, applying a consistent sanitization layer for user-provided or externally sourced values.
  • Limit or validate rich formatting in documentation fields, preferring a restricted markup subset or plain text where feasible.
  • Isolate documentation pages with stricter browser controls where possible (e.g., restrictive Content Security Policy that disallows inline scripts and unsafe eval-style constructs).

How teams detect issues like this

Detection typically involves a combination of code-centric and behavior-centric approaches:

  • Static analysis: Scan the documentation generation code for string concatenation or template injection where OpenAPI fields are inserted into HTML or JavaScript without an explicit escaping or encoding step.
  • Template review: During code review, flag any template placeholders that directly render metadata fields (such as descriptions or titles) into script blocks or HTML without using safe helpers.
  • Dynamic testing: Use automated or manual security testing against the documentation interface by placing harmless XSS test payloads into OpenAPI fields and confirming they are rendered safely (escaped) in the UI.
  • Policy enforcement: Integrate linting or security rules into CI/CD that disallow unsafe patterns (e.g., inline script blocks consuming raw specification fields) and encourage use of centralized encoding utilities or components.

Sources

SourceLink
github.comgithub.com/middleapi/orpc/commit/4f0efa8a1d3fa8e8317a4b03cc3945a5dfd68add
github.comgithub.com/middleapi/orpc/releases/tag/v1.13.9
github.comgithub.com/middleapi/orpc/security/advisories/GHSA-7f6v-3gx7-27q8

Frequently asked

questions

Exploitability depends on who can modify the OpenAPI specification.

If only trusted maintainers can edit it, the risk is primarily insider or supply-chain based.

If external users or integrated systems can influence metadata fields without strict validation, the attack surface increases significantly.

Not necessarily.

The key requirement is control over one or more OpenAPI fields used in documentation.

This control could come from authenticated access to an admin interface, a compromised build pipeline, or any upstream source feeding into the spec, regardless of whether the victim viewing the docs is authenticated.

The most robust fix is to treat all OpenAPI metadata as untrusted and ensure that every place it is rendered passes through context-appropriate escaping or sanitization.

Centralizing this logic in reusable helpers or components helps ensure consistency and reduces the chance of reintroducing unsafe patterns.

Establish a secure-by-default documentation rendering pipeline where:

  • All user-controllable text is escaped by default.
  • Inline JavaScript is minimized or avoided.
  • Content Security Policy is used as a defense-in-depth measure.

Additionally, include XSS-specific checks in code review and CI pipelines, and regularly test documentation endpoints with security-focused integration tests.

Find out what's already
exploitable in your codebase.