Jul 22, 2026·5 min read·5 visits
Unsandboxed iframe and sanitizer bypass in n8n's HTML preview allow low-privileged users to execute arbitrary JavaScript in the victim's session context, leading to session hijacking.
A critical DOM-based Cross-Site Scripting (XSS) vulnerability exists in n8n's workflow editor HTML preview component. By failing to include a sandbox attribute on the iframe used to display node execution output, n8n allowed rendered execution outputs to run arbitrary JavaScript within the same-origin context of the editor parent window. This vulnerability can be exploited by an attacker with low-privileged ('global:member') access to hijack an authenticated administrator's session and perform unauthorized API actions.
n8n is an extensible workflow automation platform that allows users to build complex integrations and data processing pipelines. A key feature of the n8n workflow editor is the ability to view the execution output of specific nodes in an HTML format directly within the user interface. This feature is intended to display rich representations of HTTP responses, parsed data, or custom code outputs.\n\nThe HTML preview functionality is implemented on the frontend to present content to the user in a styled layout. To prevent the rendered output's styling and structure from interfering with the parent application's layout, n8n developers embedded the output within an HTML iframe element. This design choice, however, introduced a significant security boundary that was not properly restricted.\n\nBecause the iframe is populated dynamically using the 'srcdoc' attribute, it inherits the origin of the parent page. Without proper sandboxing or strict execution controls, any active content within the iframe runs in the same origin as the n8n editor, creating an avenue for DOM-based Cross-Site Scripting (XSS).
The underlying vulnerability stems from the omission of the 'sandbox' attribute on the iframe container used to render the preview. In modern web browsers, iframes loaded via the 'srcdoc' attribute inherit the origin of their parent document unless they are explicitly restricted. This default browser behavior means that the iframe and the parent editor window share the same execution origin, enabling full DOM access across the boundary.\n\nWhile n8n attempted to neutralize malicious content by running user-supplied HTML through a client-side sanitizer, this defense proved insufficient. Client-side sanitizers are notoriously susceptible to parser-differential and mutation-based XSS (mXSS) bypasses. When a sanitizer fails to recognize a specific nested or malformed HTML construct, the browser's parser reconstructs the document into an active executable format during DOM insertion.\n\nOnce a payload successfully bypasses the sanitizer filter, it is written into the iframe's 'srcdoc' attribute. Because the iframe runs under the same-origin policy as the n8n interface, the script can seamlessly access the 'window.parent' object, bypassing any attempt to isolate the preview environment.
Analyzing the DOM structure reveals how the vulnerability manifests in the browser. In vulnerable versions of n8n, the preview panel renders the HTML content using a standard iframe tag without restriction:\n\nhtml\n<!-- Vulnerable Implementation -->\n<iframe srcdoc=\"<div>User-controlled content here</div>\"></iframe>\n\n\nTo remediate this, the iframe must be explicitly sandboxed to restrict script execution, form submission, and origin sharing. The patch introduces the 'sandbox' attribute to ensure that the iframe content is treated as having a unique, opaque origin, preventing it from interacting with the parent window:\n\nhtml\n<!-- Patched Implementation -->\n<iframe sandbox=\"allow-popups\" srcdoc=\"<div>User-controlled content here</div>\"></iframe>\n\n\nThe following diagram illustrates the interaction between the parent editor and the unsandboxed iframe:\n\nmermaid\ngraph LR\n Parent[\"n8n Editor Parent Window\"] -->|Injects output into srcdoc| Iframe[\"Unsandboxed Iframe\"]\n Iframe -->|Bypasses sanitizer| Script[\"Malicious Script Execution\"]\n Script -->|window.parent Access| Parent\n Parent -->|Steals session data| Attacker[\"Attacker Server\"]\n
To exploit this vulnerability, an attacker must first obtain 'global:member' privileges within the n8n application. This level of access allows the attacker to create or modify workflows, specifically configuring a node (such as an HTTP Request or Code node) that generates a custom execution output containing a crafted payload.\n\nOnce the malicious workflow is configured, the attacker triggers an execution or waits for a victim with administrative privileges to view the workflow run. When the victim opens the HTML preview panel for the affected node, the frontend retrieves the execution output, sanitizes it using the vulnerable client-side routine, and inserts it into the iframe.\n\nIf the payload leverages a parser-differential bypass, it executes within the iframe. Because the iframe is same-origin, the script accesses 'window.parent.localStorage' or cookies to retrieve the active session token. It then utilizes the 'fetch' API or 'navigator.sendBeacon' to transmit the credentials to an attacker-controlled listener, completing the session hijacking process.
The security consequences of CVE-2026-65597 are critical due to the privileged context in which n8n editors operate. Since n8n is an automation platform, the web interface typically has access to integrated database credentials, API keys, and third-party authentication tokens stored within the workspace.\n\nA successful session hijacking attack allows the adversary to impersonate the victim administrator entirely. The attacker can read sensitive workflow definitions, extract API credentials from the system configuration, or modify active workflows to execute arbitrary commands on the hosting server.\n\nThis vulnerability has been assigned a CVSS v4.0 score of 8.2 (High). The high impact on confidentiality and integrity, combined with the lack of system-level restrictions on same-origin iframe execution, makes it a severe vector for privilege escalation within the n8n ecosystem.
The primary remediation for CVE-2026-65597 is updating the n8n installation to a secure release. The vendors have backported the fix to multiple release branches to ensure coverage for various deployment environments.\n\n> [!IMPORTANT]\n> Users on the 1.x branch must upgrade to version 1.123.64 or higher. Users on the 2.x branch must upgrade to version 2.29.8 or 2.30.1 depending on their current release track.\n\nIf immediate patching is not feasible, organizations should restrict member-level access ('global:member') to trusted personnel only. Additionally, administrators should avoid inspecting HTML previews of executions derived from untrusted external sources, such as public webhooks or unverified HTTP responses, until the software is updated.
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:H/VI:L/VA:N/SC:H/SI:L/SA:N| Product | Affected Versions | Fixed Version |
|---|---|---|
n8n n8n-io | < 1.123.64 | 1.123.64 |
n8n n8n-io | 2.x < 2.29.8 | 2.29.8 |
n8n n8n-io | < 2.30.1 | 2.30.1 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-79 |
| Attack Vector | Network (AV:N) |
| CVSS Score | 8.2 (High) |
| Privileges Required | Low (PR:L) |
| User Interaction | Required (UI:A) |
| Exploit Status | Proof-of-Concept / Conceptual |
| CISA KEV Status | Not Listed |
The application does not neutralize or incorrectly neutralizes user-controlled input before it is placed in active content (HTML, JavaScript), allowing code execution.
A SQL Injection vulnerability exists in the n8n Snowflake node's executeQuery operation. The vulnerability is caused by improper neutralization of expressions interpolated directly into database query strings. When raw Snowflake queries are built using untrusted external data without parameterization, an attacker can execute arbitrary SQL commands on the subsequent Snowflake database instance.
Eclipse Jetty is subject to an uncontrolled resource consumption vulnerability in its HTTP connection handling component. When processing certain HTTP request sequences, such as those invoking the Expect: 100-Continue handshake under specific network constraints, the server fails to return allocated buffers to its central pool. Over time, this leads to buffer pool exhaustion and a complete denial of service via memory starvation.
CVE-2026-65595 is a high-severity privilege escalation vulnerability in the Token Exchange module of the n8n visual workflow automation platform. Due to an validation omission, the system unconditionally maps all Public API scopes to session tokens exchanged through trusted Identity Providers, entirely bypassing user-specific role checks.
A Stored DOM-based Cross-Site Scripting (XSS) vulnerability exists within the frontend Resource Locator component of n8n. The flaw stems from insecure usage of window.open() where the application evaluates the workflow-persisted parameter 'cachedResultUrl' without verifying its protocol scheme. Authenticated attackers with permissions to create or edit workflows can insert a 'javascript:' URI payload, leading to arbitrary code execution in the victim's browser context upon interaction.
A credential exposure vulnerability in n8n (CVE-2026-65599) transmits the complete PEM-formatted Google Service Account private key in the 'kid' (Key ID) parameter of outbound JWT headers during Google API authentication. Because JWT headers are encoded in plain Base64URL and not encrypted, any entity that intercepts, logs, or processes these outbound requests can immediately extract the plaintext private key. This enables unauthorized third parties to fully compromise the corresponding Google Cloud Platform (GCP) service account and access any authorized cloud resources.
CVE-2026-47300 is a high-severity Elevation of Privilege (EoP) vulnerability in Microsoft's ASP.NET Core framework, affecting the Negotiate Authentication Handler when configured to retrieve security groups and role mappings via an LDAP/Active Directory directory service. In cross-platform Linux and macOS environments where native Windows token group expansion is unavailable, an authenticated attacker with low-privileged network access can manipulate LDAP query structures or force connections to untrusted directory resources, resulting in unauthorized administrative role assignment.