Summary
n8n contains a stored cross-site scripting vulnerability in the Form node's completion page, where response text can be rendered as raw HTML without the intended sandboxing policy.
An authenticated member who can configure a form may cause attacker-controlled script to execute in the n8n origin when visitors submit the resulting public form.
Affected context
The issue occurs in n8n Form node workflows that use the completion page and allow an authenticated member to configure response behavior and response text. Risk increases when a public form is exposed to visitors and the response text remains populated while the response mode is configured through an expression to redirect.
Exploit preconditions
- Attack surface: The n8n Form node completion page
- Required access: Authenticated member-level access sufficient to configure the affected form
- Trigger point: A visitor submits a public form and receives the completion page
- Why exploitation is possible: The page may render responseText as raw HTML while the sandboxing Content-Security-Policy is not applied for the redirect response mode
Why this happens
The vulnerability results from inconsistent security-policy enforcement and unsanitized HTML rendering. The completion page applies its sandboxing Content-Security-Policy conditionally based on the response mode, while responseText is rendered as raw HTML regardless of that mode. This allows stored attacker-controlled markup and script to execute in the application's origin, mapping to CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Potential impact
- Malicious script could execute with the n8n origin
- A visitor's authenticated session could be targeted
- Attackers could perform actions available to the affected browser session
- Sensitive information accessible to the page could be exposed
- Forms and workflows could be abused to distribute malicious content
General mitigation guidance
Mitigation generally focuses on ensuring that all user-controlled completion content is treated as data rather than executable markup.
Common defensive patterns include:
- Applying context-appropriate output encoding or strict sanitization before rendering response text
- Prefering plain-text completion responses or trusted, narrowly defined templates
- Enforcing the strongest applicable Content-Security-Policy for every completion-page path, including redirect configurations
- Avoiding security decisions based solely on user-controlled or expression-derived response modes
- Restricting who may publish or modify public forms
- Limiting session privileges and administrative capabilities exposed to browser sessions
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying raw HTML insertion into completion or response pages
- Code review checks for conditional CSP enforcement and inconsistent handling across response modes
- Tests that submit forms with markup in response fields and verify that it is encoded or safely sanitized
- Policy enforcement requiring output encoding or approved sanitization libraries for browser-rendered content
- Monitoring for unexpected script-bearing form responses and unusual browser actions originating from public form pages
Automated security review tools may help identify unsafe DOM or server-side HTML rendering patterns.

