You wouldn’t wanna escape this security ni8mare: Exploiting n8n
n8n's public Form webhooks accepted JSON instead of multipart form data, letting an unauthenticated attacker fake a file upload and read arbitrary files, leading to credential theft and remote code execution. A separate flaw let authenticated users bypass the expression sandbox to run system commands.
Published on verlekarsachin.medium.com
For the past couple of days n8n has been officially reporting security flaws as shown in the table given below:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the form handler trusted the request's content type and merged attacker-supplied JSON into the file list without validation, while the expression sandbox relied on a blocklist that could be bypassed via process.mainModule.
Impact
An unauthenticated attacker could take over a self-hosted n8n instance, steal credentials and API keys, and execute commands; the second flaw required login but gave full server control.
What the attacker needed
Publicly reachable n8n form webhook; n8n version below 1.121.0; for second flaw: valid login and misconfigured env var
The fix
Upgrade n8n to version 1.121.0 or later, and avoid setting NODE_FUNCTION_ALLOW_BUILTIN to *.
How it was found
- Clone the exploit repository and start the provided Docker setup with the vulnerable n8n version.
- Access the public form endpoint to confirm it is reachable.
- Install the uv tool and run the exploit script against the form URL with a command to execute.
- For the second flaw, install n8n with the environment variable allowing all built-in modules.
- Create a workflow with a JavaScript Code node and paste a script that runs a system command.
- Execute the node to see command output, then use a reverse shell expression to connect back.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
n8n is a tool that automates tasks by connecting apps. A public form on it could be tricked into reading files on the server, and a logged-in user could run commands on the server by abusing a feature meant for small calculations.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.