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.

