/

CVE-2026-42235

Severity:

CRITICAL RISK

(9.6)

XSS in n8n MCP OAuth Client Name Handling

CVE-2026-42235

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79, CWE-87

Impact:

Account Takeover and Workflow Manipulation via Stored XSS

Severity:

CRITICAL RISK

(9.6)

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) vulnerability in n8n's MCP OAuth client registration allows attacker-controlled script content to be injected via the client_name field and later rendered in a toast notification.

When a victim authorizes a malicious OAuth client and another user revokes it, the resulting notification can execute arbitrary JavaScript in the victim's authenticated browser session, enabling credential theft and workflow manipulation.

Affected context

This vulnerability arises in n8n's web-based user interface where MCP OAuth clients are created, authorized, and revoked.

The issue manifests specifically when:

  • An unauthenticated attacker can register an MCP OAuth client and control its client_name.
  • A victim user later authorizes this malicious client through the OAuth consent dialog.
  • A second user (or the same user, depending on configuration) revokes that client, triggering a toast notification.

The notification renders the attacker-controlled client_name without adequate sanitization or encoding, allowing script execution in the context of the authenticated n8n session.

Exploit preconditions

  • Attack surface: n8n web UI, specifically the MCP OAuth client registration, consent, and revocation flows.
  • Required access:
  • The attacker needs network access to the n8n instance to register an MCP OAuth client (no authentication required).
  • A victim with a valid n8n account must authorize the malicious OAuth client.
  • A second user with the ability to revoke the client must perform the revocation action.
  • Trigger point: The toast notification that appears when the OAuth client access is revoked, which displays the crafted client_name.
  • Why exploitation is possible: The client_name from the MCP OAuth client is treated as trusted content and rendered into the toast notification without appropriate HTML/JavaScript context-aware escaping or sanitization, enabling injected script to run in the victim's browser.

Why this happens

The root cause is improper neutralization of user-controlled data in a web UI context, mapped to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).

The MCP OAuth client_name field, which is fully attacker-controlled, is stored and later rendered into a toast notification without being encoded according to the rules of the HTML/DOM context in which it appears.

This lack of output encoding/sanitization allows the injected script to be interpreted by the browser as executable JavaScript.

Additionally, the workflow involves multiple users (one authorizing the OAuth client and another revoking it), which can obscure trust boundaries and lead to assumptions that any data displayed in notifications is safe, even when it originated from unauthenticated input.

Potential impact

  • Hijacking of authenticated n8n sessions via theft of session tokens or cookies.
  • Unauthorized access to workflow credentials, API keys, and connection secrets stored in n8n.
  • Manipulation, creation, or deletion of workflows and automations.
  • Privilege escalation if the victim user has elevated roles or administrative permissions.
  • Lateral movement by leveraging compromised workflows to access integrated third-party services.
  • Persistent compromise of automation pipelines, including data exfiltration or tampering.

General mitigation guidance

Effective mitigation typically focuses on treating all user-supplied or indirectly controlled data as untrusted and applying strict output encoding rules.

Common defensive patterns include:

  • Enforcing context-aware output encoding for all dynamic values rendered into HTML, attributes, or JavaScript contexts (e.g., using templating frameworks that auto-escape by default).
  • Sanitizing or restricting allowed characters in display fields such as client_name, limiting them to safe subsets where scripting cannot be expressed.
  • Adopting a "safe by default" UI layer where notifications, dialogs, and other components only accept pre-escaped, strongly typed data.
  • Clearly separating "data from UI" by preventing arbitrary markup from being injected into component templates.
  • Reducing trust zones by validating and normalizing values coming from unauthenticated or semi-trusted flows like OAuth registrations.
  • Applying least privilege principles for tokens and credentials exposed through the UI, limiting what an XSS attacker can access.

How teams detect issues like this

Detection strategies for this kind of XSS issue typically combine preventative and investigative approaches:

  • Static analysis: Configure rules or linters to flag direct insertion of user-controlled data into UI components, especially into HTML or JavaScript sinks, without use of approved escaping functions.
  • Code review: During reviews, pay special attention to UI elements that render data from external systems (e.g., OAuth clients), toast notifications, and other cross-cutting components; verify they use centralized, safe rendering helpers.
  • Security testing: Incorporate automated and manual XSS tests into CI/CD pipelines, including tests for stored XSS in notification systems and workflow logs.
  • Logging and monitoring: Track unusual registration of OAuth clients and patterns of repeated client creation with suspicious names, as these may indicate probing for XSS.
  • Policy enforcement: Use internal UI frameworks or component libraries with enforced escaping guarantees, and restrict direct DOM manipulation or insertion of raw HTML.

Sources

SourceLink
github.comgithub.com/n8n-io/n8n/security/advisories/GHSA-537j-gqpc-p7fq

Frequently asked

questions

The vulnerability is highly exploitable when users regularly authorize MCP OAuth clients, as an attacker only needs to register a malicious client and wait for a victim to authorize and a second user to revoke it. Once the toast notification appears, clicking the rendered link can execute attacker-supplied JavaScript in the victim's browser.

No. The attacker can be unauthenticated to register a malicious MCP OAuth client but relies on authenticated n8n users to complete the authorization and revocation steps. The actual XSS executes in an authenticated user's session, giving the attacker their effective privileges.

Apply strict, context-aware encoding to all user-controlled fields before rendering them into the UI and avoid injecting raw HTML or text directly into components. Centralize notification and message rendering through a small number of well-reviewed helpers that enforce escaping and disallow arbitrary markup or script execution.

Adopt secure-by-default UI frameworks, enforce auto-escaping in templates, and treat all data coming from external or unauthenticated interfaces as untrusted. Complement this with secure coding guidelines, automated XSS-focused tests, and mandatory code review checks for any new or modified user-facing components, especially notifications and cross-feature UI elements.

Find out what's already
exploitable in your codebase.