/

CVE-2026-86076

Severity:

HIGH RISK

(8.8)

Code Injection (CWE-94) in n8n Expression Compiler AST

CVE-2026-86076

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Backend Code Execution and Editor JavaScript Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A flaw in n8n's expression compiler sanitizer allows a specially crafted class field named __sanitize to rebind the sanitizer and reach the JavaScript Function constructor. Depending on the execution path and available privileges, this may enable backend code execution and JavaScript execution in the editor preview.

Affected context

The issue occurs in n8n expression compilation, specifically in the PrototypeSanitizer AST hook within the workflow expression-sandboxing logic. It becomes risky when attacker-influenced expressions or class structures are compiled through the affected sanitizer and can define reserved member names that alter how sanitization is resolved. The practical exposure depends on who can create or modify workflows and which execution or preview paths are enabled.

Exploit preconditions

  • Attack surface: n8n workflow expressions and editor-preview evaluation
  • Required access: The ability to supply or modify expression content or related class structures processed by the compiler
  • Trigger point: Expression compilation or execution involving the affected sanitizer
  • Why exploitation is possible: Dynamic resolution through this allows a reserved class member named __sanitize to rebind the sanitizer and expose the Function constructor

Why this happens

The vulnerability results from an expression sanitizer that resolves through dynamically scoped this without rejecting reserved class member names. This permits attacker-controlled class structure to replace or influence the sanitizer callback, allowing compilation behavior to reach a dynamic code-construction primitive. The issue maps to CWE-94: Improper Control of Generation of Code, because untrusted input can influence the generation or execution of JavaScript code.

Potential impact

  • An attacker could execute arbitrary code in the n8n backend process
  • An attacker could execute JavaScript in an editor-preview context
  • Workflow credentials, stored data, or connected service access could be exposed
  • The n8n host or surrounding environment could be compromised, depending on process privileges
  • Workflows or automation data could be modified or abused

General mitigation guidance

Mitigation focuses on preventing attacker-controlled syntax from influencing sanitizer bindings or dynamic code-generation paths.

Common defensive patterns include:

  • Rejecting reserved and security-sensitive member names during parsing and AST validation
  • Resolving sanitizer functions through fixed lexical bindings rather than dynamically scoped this
  • Eliminating access to the Function constructor and comparable dynamic evaluation primitives
  • Applying allowlisted expression grammars and strict AST validation before compilation
  • Separating editor-preview execution from backend privileges and sensitive runtime capabilities
  • Running workflow processes with least privilege and restricting access to credentials and host resources

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static analysis rules identifying dynamic this resolution in sanitizers or security hooks
  • Searches for reachable use of Function, eval, or equivalent dynamic code-generation APIs
  • Code review checks for missing rejection of reserved class member names
  • Tests that compile adversarial AST structures and verify sanitizer bindings cannot be replaced
  • Policy enforcement requiring allowlisted expression grammars and isolated preview execution
  • Runtime monitoring for unexpected child processes, filesystem access, or outbound connections from n8n workers

Automated security review tools may help identify dynamic evaluation and unsafe AST-handling patterns, but should be supplemented with targeted sandbox tests.

Sources

SourceLink
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@1.123.76
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@2.37.7
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@2.38.2
github.comgithub.com/n8n-io/n8n/security/advisories/GHSA-hw8v-xxg5-vvvx

Frequently asked

questions

Exploitability depends on the n8n deployment and exposed workflow-management interfaces. An attacker generally needs a way to introduce or modify expression content that reaches the affected compiler.

Usually, access to create or edit workflows, expressions, or preview content is relevant. The exact requirement depends on authentication, sharing, and editor-access controls in the deployment.

Use fixed sanitizer bindings, reject reserved member names during AST validation, and prevent expressions from reaching dynamic code-generation primitives such as the Function constructor.

Maintain a narrow allowlisted expression language, test sanitizer boundaries with adversarial AST inputs, isolate preview execution, and apply least privilege to workflow runtime processes.

Find out what's already
exploitable in your codebase.