Feb 4, 2026·6 min read·67 visits
Critical RCE in n8n versions < 2.4.8. The Python Code node's path validation logic fails when handling files that don't exist yet, allowing attackers to use symlinks to write files outside the sandbox. This leads to full host compromise.
A critical sandbox escape vulnerability in the n8n workflow automation platform allows authenticated users to execute arbitrary code on the host system. The flaw resides in the file path canonicalization logic of the Python Code node, specifically handling non-existent files. By exploiting a fallback mechanism that relies on string manipulation rather than filesystem validation, attackers can traverse directories via symlinks, effectively breaking out of the intended security boundaries. This turns a low-privilege workflow editor into a full system administrator.
Automation tools like n8n are the glue of the modern internet. They take data from point A, massage it, and shove it into point B. To make this truly powerful, n8n offers a Python Code node, effectively giving users a shell environment to run custom scripts. Ideally, this environment is a padded room—a sandbox where you can play with data but can't touch the sharp objects (the host filesystem).
However, building a perfect jail is notoriously difficult, especially when you allow users to interact with files. The security model relies on a simple promise: "You can play with files, but only inside this specific directory." It sounds simple enough. You check the path, make sure it starts with /sandbox/safe/, and let the script run. But filesystem paths are not simple strings; they are pointers to a physical reality that can be manipulated.
CVE-2026-25115 is the story of what happens when a developer trusts a string representation of a path more than the filesystem itself. It’s a classic tale of "it looked safe on paper," leading to a complete compromise of the host server. If you run n8n and allow untrusted users to create workflows, your server isn't yours anymore—it's theirs.
The vulnerability lies in a function called resolvePath in packages/core/src/execution-engine/node-execution-context/utils/file-system-helper-functions.ts. The purpose of this function is to take a user-provided path and return its canonical, absolute form. This is the gatekeeper. If the resolved path doesn't start with the allowed sandbox root, the operation is blocked.
Here is where the logic went sideways. The code correctly used fs.realpath() for files that existed. fs.realpath() is the gold standard because it asks the OS, "Hey, where does this inode actually live?" It resolves symlinks, .. segments, and returns the hard truth.
But what if the file doesn't exist yet? For example, if the script is trying to create a new output file? The original code caught the ENOENT (Error NO ENTry) exception and fell back to path.resolve(). This was the fatal mistake. path.resolve() is a library function that performs string manipulation. It doesn't look at the disk. It doesn't know that a folder in the path is actually a symlink pointing to /root. It just cleans up the string. The gatekeeper was checking a map drawn by the attacker, not the terrain itself.
Let's look at the specific lines that killed the security model. In the vulnerable version, the error handling explicitly downgraded the security check from a filesystem operation to a string operation.
// VULNERABLE CODE
async function resolvePath(path: PathLike): Promise<ResolvedFilePath> {
try {
// The safe way: ask the filesystem
return (await fsRealpath(path)) as ResolvedFilePath;
} catch (error: unknown) {
// If the file is missing (ENOENT)...
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
// THE BUG: Trusting the string representation
return resolve(path.toString()) as ResolvedFilePath;
}
throw error;
}
}When the patch landed in commit 5c69970acc7d37049deae67da861f92d2aaa9b03, the fix was obvious in hindsight. If the file doesn't exist, you can't resolve it, but you must resolve its parent directory. You cannot trust any part of the path that isn't anchored to the physical disk.
// PATCHED CODE
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
const dir = dirname(pathStr);
const file = basename(pathStr);
// The fix: Force resolution of the parent directory
const resolvedDir = await fsRealpath(dir);
return join(resolvedDir, file) as ResolvedFilePath;
}By forcing fsRealpath(dir), the application ensures that if dir involves a symlink escaping the sandbox, resolvedDir will reflect the true location (e.g., /etc/), causing the subsequent prefix check to fail.
To exploit this, we need to trick the application into thinking a file write is safe when it isn't. The strategy relies on the difference between the path string and the path reality. We will use the Python Code node to set up a trap.
Step 1: The Setup
First, we use valid Python code to create a symlink inside our allowed sandbox directory. The system allows this because we aren't leaving the sandbox yet.
os.symlink('/', '/sandbox/data/tunnel')
Now, /sandbox/data/tunnel points to the root of the filesystem.
Step 2: The Bait
We tell n8n we want to write a file to /sandbox/data/tunnel/tmp/pwned. The file doesn't exist, so fs.realpath throws ENOENT.
Step 3: The Switch
The vulnerable catch block executes path.resolve('/sandbox/data/tunnel/tmp/pwned'). Since path.resolve treats this as a string, it returns exactly what we gave it. The security check looks at the string: "Does it start with /sandbox/data? Yes." The gate opens.
Step 4: Execution
n8n performs the actual file write using the path /sandbox/data/tunnel/tmp/pwned. The operating system sees the symlink tunnel, resolves it to /, and writes the file to /tmp/pwned on the host. We have now achieved arbitrary file write. From here, overwriting .ssh/authorized_keys or a cron job for full RCE is trivial.
This is a CVSS 9.4 Critical vulnerability for a reason. n8n is often deployed with access to sensitive internal APIs, database credentials, and cloud keys. It sits at the center of an organization's automation infrastructure.
An attacker who exploits this doesn't just get to write a text file; they get the identity of the n8n process. In Docker environments, they might break out of the container next. In bare-metal installs, they own the server. They can steal all the credentials stored in n8n credential store, modify other workflows to exfiltrate data, or install persistent backdoors.
Because n8n is designed to execute code, the "Attack Complexity" is low. You don't need to bypass ASLR or craft heap sprays. You just need to write three lines of Python.
The remediation is straightforward: Update to version 2.4.8. The n8n team responded quickly and the patch effectively kills the symlink vector by verifying the parent directory of any new file.
If you cannot patch immediately, you are in a precarious position. The only effective mitigation is to disable the Python Code node entirely or restrict access to the workflow editor to only the most trusted personnel. Network segmentation won't save you here—the call is coming from inside the house.
For security researchers and developers, the lesson is clear: String manipulation is not security. If you are validating paths, you must ask the filesystem for the truth, the whole truth, and nothing but the truth.
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H| Product | Affected Versions | Fixed Version |
|---|---|---|
n8n n8n.io | < 2.4.8 | 2.4.8 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-693 |
| Attack Vector | Network (Authenticated) |
| CVSS Score | 9.4 (Critical) |
| Impact | Remote Code Execution (RCE) / Sandbox Escape |
| Patch Commit | 5c69970acc7d37049deae67da861f92d2aaa9b03 |
| Exploit Status | PoC Available (Theoretical) |
Protection Mechanism Failure
NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.
CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.
CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.
CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.
A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.
CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.