Sep 10, 2026·6 min read·17 visits
An authenticated user can bypass the isolated-vm sandbox in n8n's legacy expression engine by poisoning the global JSON.stringify function, leading to arbitrary host command execution.
A critical sandbox escape vulnerability exists in the legacy expression engine of n8n. By leveraging Shared Builtin Tampering combined with Code-Printer Injection, an authenticated attacker can hijack the mutable global JSON.stringify function. This hijacking allows the attacker to inject arbitrary Node.js source code into internal execution contexts during code generation, escaping the isolated-vm sandbox and achieving full remote code execution on the host system.
The open-source workflow automation platform n8n relies on a dynamic expression engine to process, format, and execute inline scripts within node configurations. To protect the host operating system from untrusted execution, n8n historically evaluated these expressions inside sandboxed environments managed by the isolated-vm library. This system isolates JavaScript processes within constrained V8 runtime contexts separate from the primary Node.js process.
However, a design vulnerability exists in how the legacy expression engine formats and serializes code strings before passing them to the sandboxed runtime. The host-side bridge and Abstract Syntax Tree (AST) transpilation layers build executable source code by evaluating global JavaScript properties. This hybrid approach creates an insecure boundary where host-side routines interact with mutable, sandboxed properties.
This interaction exposes a significant attack vector known as Shared Builtin Tampering. If an attacker can manipulate core functions within the shared environment, they can intercept host-side code compilation. This interception enables the insertion of arbitrary instructions directly into the compilation pipeline, rendering the sandbox restrictions ineffective.
The vulnerability lies in n8n's reliance on the mutable, global JSON.stringify utility during two distinct code-generation stages: isolated-vm bridge execution and AST string-literal printing.
In the first stage, located in packages/@n8n/expression-runtime/src/bridge/isolated-vm-bridge.ts, the host-side runner compiles a wrapper code block. To configure the sandbox environment, this runner attempts to serialize timezone parameters using the global JSON.stringify command. Because JavaScript builtins are dynamically resolved on the current scope, an attacker can overwrite JSON.stringify with a malicious proxy function. When the bridge attempts to serialize the timezone metadata, the hijacked function executes instead, returning unescaped, arbitrary JavaScript code that is concatenated directly into the execution template.
In the second stage, located in packages/@n8n/tournament/src/ExpressionBuilder.ts, the expression transpiler leverages recast and ast-types to process AST structures. When the transpiler encounters a text or fallback string chunk, it generates standard Literal AST nodes using b.literal(). During the printing phase, the recast code printer calls JSON.stringify to format the AST literals. If the global JSON.stringify function has been overridden, the output printed by recast is corrupted with the attacker's payload. This dynamically transforms a safe string literal within the code representation into an active instruction block.
Because these processes execute before compilation inside the isolated-vm engine, the injected code is compiled and run with the full security context of the host process, resulting in a sandbox escape.
The vulnerability is remediated by capturing immutable references to JSON.stringify at module load time and modifying the AST literal printer to prevent dynamic global evaluations.
In the file packages/@n8n/expression-runtime/src/bridge/isolated-vm-bridge.ts, developers introduced a frozen reference to ensure serialization routines remain unaffected by subsequent prototype modifications:
// Captured at module load so values rendered into generated code stay stable
// even if the global is later replaced.
const safeStringify = JSON.stringify;This frozen reference replaces the dynamic resolution call within the bridge execution loop:
// The bridge now serializes options securely
const timezone = options?.timezone ? safeStringify(options.timezone) : 'undefined';To secure the AST serialization within the transpiler, n8n introduced a new helper, rawStringLiteral, in packages/@n8n/tournament/src/VariablePolyfill.ts:
const safeStringify = JSON.stringify;
export const rawStringLiteral = (value: string) => {
const literal = b.literal(value);
const raw = safeStringify(value)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');
// Attach extra properties to prevent recast from invoking the dynamic global during print
(literal as namedTypes.Literal & { extra?: { raw: string; rawValue: string } }).extra = {
raw,
rawValue: value,
};
return literal;
};This ensures that when recast compiles the AST, it reads the pre-serialized extra.raw property verbatim rather than looking up the global JSON.stringify function, completely closing the code-printing injection vector.
An exploit targeting CVE-2026-86083 requires authenticated access to create or edit workflows on an n8n instance configured to run the legacy expression engine.
Initially, the attacker inputs an expression containing code designed to pollute the global scope and redefine the core stringify method. The malicious definition intercepts values and returns raw, unescaped JavaScript instructions:
JSON.stringify = function(val) {
return `("UTC"); (function(){
const exec = process.mainModule.require('child_process').execSync;
exec('id');
})()`;
};When n8n rebuilds or compiles subsequent workflow expressions, the host environment processes the wrapper code in isolated-vm-bridge.ts. The bridge calls the poisoned JSON.stringify implementation, which injects the self-invoking function payload directly into the target code string.
Finally, when context.evalClosureSync executes the compiled template, the self-invoking payload breaks out of the wrapper environment, executing system commands on the underlying server outside the V8 sandbox.
The security impact of CVE-2026-86083 is classified as High, with a CVSS v4.0 base score of 7.7. Because successful exploitation results in full remote command execution, the confidentiality, integrity, and availability of the host operating system are fully compromised.
An attacker who achieves command execution can access all environment variables, local system configurations, and internal workflow databases. This data exposure compromises sensitive API tokens, database credentials, and service accounts utilized by the automation server.
Furthermore, the attacker can leverage the compromised host to perform lateral network reconnaissance, pivot to internal services, or establish persistence. The direct impact is limited to the system hosting the n8n application process, but the downstream compromise of connected infrastructure can be extensive.
To resolve the vulnerability, administrators must either upgrade to a patched version or change the expression engine configuration.
The primary mitigation is upgrading n8n to one of the following official secure releases:
If upgrading is not immediately possible, administrators can mitigate the vulnerability by disabling the legacy expression engine. Setting the following environment variable forces n8n to utilize the hardened V8 expression engine, which does not rely on mutable code-generation paths:
N8N_EXPRESSION_ENGINE=vmAdditionally, ensure the n8n process runs within a highly isolated environment, such as a dedicated, non-root Docker container, to minimize the impact of any potential sandbox escape.
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N| Product | Affected Versions | Fixed Version |
|---|---|---|
n8n n8n | < 1.123.76 | 1.123.76 |
n8n n8n | >= 2.0.0, < 2.37.7 | 2.37.7 |
n8n n8n | >= 2.38.0, < 2.38.2 | 2.38.2 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-94 |
| Attack Vector | Network |
| CVSS v4.0 Score | 7.7 |
| Exploit Status | PoC Available |
| KEV Status | Not Listed |
The application constructs code using user-controlled input without neutralizing or validating the input, leading to code execution.
CVE-2026-126298 (also tracked as GHSA-r53h-rw34-8h97) is an algorithmic complexity Denial of Service (DoS) vulnerability in the Natural Language Toolkit (NLTK) Python library affecting all versions prior to 3.10.4. The vulnerability resides in the nltk.tree.transforms.chomsky_normal_form function and its corresponding public method Tree.chomsky_normal_form(). When transforming a parse tree into Chomsky Normal Form using the default right-factoring strategy, the function repeatedly invokes list.pop(0) inside a loop iterating over all children of a node. In CPython, removing the initial element of a standard list requires an O(N) memory shift operation, causing the overall binarization algorithm to degrade to O(N^2) quadratic time complexity relative to the width of a node. Furthermore, converting horizontal node width into vertical tree depth bypasses initial parsing depth bounds, triggering subsequent stack exhaustion (RecursionError) when recursive methods traverse the mutated structure. Unauthenticated remote attackers who can submit bracketed tree strings to applications invoking this transformation can exhaust single-threaded CPU resources or induce unhandled application exceptions.
An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.