Summary
n8n contained a stored cross-site scripting vulnerability where crafted workflows could generate HTML binary data that the platform served inline without protective HTTP headers.
When a privileged user opened the attacker-controlled binary-data URL, the HTML executed with full same-origin JavaScript access, allowing theft of credentials, workflow data, and potential privilege escalation to admin.
Affected context
This vulnerability arises in n8n instances where authenticated users are allowed to create or modify workflows that emit binary data responses.
If such a workflow produced HTML content without assigning a filename, the /rest/binary-data endpoint returned that content inline on the n8n origin.
In affected versions, these responses lacked Content-Disposition and Content-Security-Policy headers, letting arbitrary HTML and JavaScript execute in the context of the n8n web application when a user followed the generated URL.
Exploit preconditions
- Attack surface: n8n web interface and
/rest/binary-dataHTTP endpoint. - Required access: An authenticated account with permission to create or modify workflows.
- Attacker capabilities: Ability to design a workflow that outputs HTML as a binary data object without specifying a filename, and to deliver the resulting binary-data URL to a more privileged user (e.g., via email, chat, or in-app communication).
- Victim interaction: A higher-privileged user (such as an admin or user with sensitive workflow access) must visit the attacker-controlled binary-data URL while logged into n8n.
- Why exploitation is possible: The endpoint serves attacker-controlled HTML inline on the same origin as the main application, without
Content-Dispositionto force download and without a restrictiveContent-Security-Policy, allowing untrusted JavaScript to execute with the victim's session context.
Why this happens
The core issue is a stored cross-site scripting flaw where application-generated, user-controlled HTML is treated as trusted content and rendered in the browser under the application's origin.
Binary data objects produced by workflows can contain arbitrary HTML and JavaScript, but the /rest/binary-data handler omitted defensive response headers and did not enforce a safe content delivery pattern.
This maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), because attacker-controlled content is delivered in a way that lets it execute as script within the trusted n8n origin, inheriting authentication and same-origin privileges.
Potential impact
- Hijacking of active n8n sessions belonging to higher-privileged users.
- Exfiltration of workflows, credentials, secrets, or other sensitive configuration data accessible to the victim.
- Unauthorized modification of existing workflows or creation of new malicious workflows.
- Privilege escalation from a low-privileged user to administrative privileges within n8n.
- Persistence of malicious automation within the platform, enabling ongoing data exfiltration or tampering.
General mitigation guidance
Long-term mitigation focuses on preventing untrusted HTML from executing in the application's origin and enforcing safer content delivery practices.
Useful defensive patterns include:
- Serving user-controlled binary or HTML-like content with
Content-Disposition: attachmentto encourage download instead of inline rendering. - Applying a restrictive
Content-Security-Policythat disallows inline script execution and limits script sources, so even if HTML is rendered, JavaScript execution is constrained. - Isolating untrusted HTML on a separate origin or sandboxed domain (e.g., separate host or subdomain) to break same-origin access to the main application.
- Normalizing binary-data handling so that workflows cannot implicitly produce active HTML/JS responses under the main application origin.
- Minimizing the privileges assigned to accounts that can create or modify workflows, applying least-privilege principles and role separation.
- Reviewing and limiting where user-controlled or workflow-controlled content can influence HTTP response headers or body content sent from sensitive endpoints.
How teams detect issues like this
Detection strategies can combine code-level checks, configuration review, and runtime monitoring:
- Static analysis and code review:
- Flag endpoints that return user-controlled or workflow-controlled content without explicit
Content-DispositionandContent-Security-Policyheaders. - Identify places where binary or text content from internal automation pipelines is sent directly as an HTTP response on the primary application origin.
- Review routing and controller logic around
/rest/binary-data(or similar endpoints) for missing output encoding and missing isolation. - Security testing:
- Perform application penetration tests focusing on workflows that generate binary data or HTML-like outputs.
- Use automated scanners to probe for reflected and stored XSS vectors involving binary and attachment-style endpoints.
- Runtime and policy enforcement:
- Employ web application firewalls or security gateways that can detect and alert on suspicious HTML or script patterns in responses from binary-data endpoints.
- Implement configuration policies requiring that endpoints with user-supplied content set restrictive security headers, enforced via automated CI/CD checks.

