n8n Prototype Pollution in XML Webhook Body Parser Leads to RCE
A prototype pollution vulnerability in n8n's XML webhook parser, exploitable by authenticated users, can lead to remote code execution on the n8n host.
A critical vulnerability exists within the n8n workflow automation platform, specifically affecting the parsing of XML request bodies in webhook handlers. This flaw stems from the use of the xml2js library, which is susceptible to prototype pollution attacks. An authenticated user possessing the capability to create or modify workflows can leverage this vulnerability by sending a specially crafted XML payload. Successful exploitation results in the pollution of the JavaScript object prototype. Attackers can chain this pollution with the Git node’s SSH operations to achieve arbitrary remote code execution (RCE) on the underlying n8n host. The vulnerability affects n8n versions prior to 1.123.32, versions 2.17.0 to 2.17.3, and versions 2.18.0 to 2.18.0.
Attack Chain
- An attacker authenticates to the n8n instance.
- The attacker crafts a malicious XML payload designed to exploit the prototype pollution vulnerability in the
xml2jslibrary. - The attacker creates or modifies a workflow containing a webhook node configured to receive XML data.
- The attacker sends the crafted XML payload to the webhook endpoint.
- The
xml2jslibrary parses the malicious XML, inadvertently polluting the JavaScript object prototype with attacker-controlled properties. - The attacker includes a Git node in the workflow.
- The polluted prototype modifies the behavior of the Git node’s SSH operations.
- When the workflow executes, the Git node’s SSH operation is hijacked due to the prototype pollution, leading to arbitrary code execution on the n8n host.
Impact
Successful exploitation allows a malicious actor to execute arbitrary code on the n8n server. This grants them complete control over the n8n instance and potentially the underlying infrastructure. The vulnerability impacts any n8n instance accessible to authenticated users who can create or modify workflows. The number of affected installations is unknown, but the potential impact is high due to the sensitive nature of workflows often managed by n8n, which can include access to other systems and data.
Recommendation
- Upgrade n8n to version 1.123.32, 2.17.4, 2.18.1, or later to patch the vulnerability as described in the overview.
- Deploy the Sigma rule “Detect n8n Prototype Pollution via Crafted XML Payload” to detect malicious XML payloads targeting the vulnerability. Enable webserver logs to activate this rule.
- Limit workflow creation and editing permissions to trusted users to mitigate the risk of exploitation, as described in the workaround.
Detection coverage 2
Detect n8n Prototype Pollution via Crafted XML Payload
criticalDetects suspicious XML payloads sent to n8n webhooks that attempt to exploit the prototype pollution vulnerability.
Detect n8n Git Node Command Execution via SSH
highDetects command execution via the n8n Git node potentially triggered by prototype pollution leading to RCE.
Detection queries are kept inside the platform. Get full rules →