The vulnerability is a stored Cross-Site Scripting (XSS) issue in the n8n Form Trigger node. The root cause lies in the sanitizeHtml function, which was inadequately configured to sanitize user-provided HTML. Specifically, it allowed wildcard attributes for <iframe>, <video>, and <source> tags. This allowed an attacker to craft a form containing malicious HTML, such as an <iframe> with a srcdoc attribute containing a script, or a <video> tag with an onerror event handler.
When a victim views this malicious form, the renderFormNode function is executed. This function processes the form's structure and for any HTML elements, it passes the content to the sanitizeHtml function. Due to the flaw in sanitizeHtml, the malicious script is not removed. The renderFormNode function then includes this unsanitized HTML in the final form page, which is rendered in the victim's browser. The script then executes, allowing the attacker to steal session cookies and other sensitive data, potentially leading to account takeover.
The patch addresses this by tightening the rules in sanitizeHtml, restricting the allowed attributes and URL schemes for the vulnerable tags to a safe subset, thus preventing the injection of malicious code.