What is CVE-2026-25049 and why does it matter?
CVE-2026-25049 is a remote code execution (RCE) vulnerability that affects the expression evaluator component of n8n, an open‑source workflow automation platform. The flaw arises from an improper handling of JavaScript destructuring within the evaluator, which allows an attacker to inject arbitrary code that is executed with the privileges of the n8n process. Because n8n is frequently deployed in production environments with elevated permissions, exploitation of this vulnerability can lead to full system compromise, data exfiltration, and persistence mechanisms. The severity rating assigned by the National Vulnerability Database is critical, reflecting the potential impact on confidentiality, integrity, and availability.
n8n, vm2, isolated-vm, RCE, CVE-2026-25049, expression evaluator
Which components of n8n are affected by the vulnerability?
The vulnerability is confined to the expression evaluation engine that processes user‑supplied expressions in workflow nodes. n8n supports two sandboxing backends for this purpose: vm2 and isolated-vm. The flaw manifests when the evaluator is configured to use either backend without strict sandboxing options. In particular, the following modules are implicated:
packages/n8n-core/src/ExpressionEvaluator.ts– the core class that compiles and executes expressions.packages/n8n-core/src/ExpressionEvaluatorVm2.ts– the vm2‑based implementation.packages/n8n-core/src/ExpressionEvaluatorIsolatedVm.ts– the isolated‑vm implementation.
All other n8n modules, including node execution, credential handling, and API endpoints, remain unaffected directly by the flaw, but they can be leveraged by an attacker once code execution is achieved.
How does JavaScript destructuring abuse enable code execution?
JavaScript destructuring allows an object to be deconstructed into variables. In the context of n8n’s expression evaluator, user input is parsed and compiled into a function that is executed within a sandbox. The vulnerability arises when the evaluator fails to sanitize destructuring patterns that reference global objects or prototypes. An attacker can craft an expression such as:
({constructor: {prototype: {exec: function(){require('child_process').execSync('id')}}}})When this expression is evaluated, the destructuring pattern accesses the constructor property of the global object, which points to Function. The malicious exec function is then invoked, resulting in arbitrary shell command execution. Because the evaluator does not enforce a whitelist of allowed properties, the attack bypasses the sandbox entirely.
What is the current patch status for n8n?
As of the latest release notes, n8n version 1.0.0-rc.2 includes a comprehensive fix for CVE-2026-25049. The patch introduces the following changes:
- Strict validation of destructuring patterns to disallow access to
constructor,prototype, and other dangerous properties. - Enforcement of sandbox options for both vm2 and isolated‑vm, including
timeout,allowAsync, andsandboxisolation. - Removal of the default
evalusage in expression compilation. - Additional unit tests covering edge cases of destructuring abuse.
Users should upgrade to at least 1.0.0-rc.2 or later. If an upgrade is not immediately possible, the following mitigations can be applied.
How can I mitigate the vulnerability without upgrading n8n?
Mitigation can be achieved through a combination of configuration changes and runtime restrictions. The steps below provide a layered defense strategy.
1. Disable expression evaluation for untrusted users
Configure n8n to restrict expression evaluation to users with the admin role. This can be enforced by setting the environment variable N8N_DISABLE_EXPRESSION_EVALUATION to true for non‑admin contexts. In the workflow editor, expressions can be replaced with static values or pre‑validated inputs.
2. Switch to isolated‑vm with strict sandboxing
By default, n8n may use vm2. Switching to isolated‑vm provides a more robust isolation boundary. Set the following environment variables:
N8N_EXPRESSION_EVALUATOR=isolated-vm
N8N_ISOLATED_VM_TIMEOUT=1000
N8N_ISOLATED_VM_SANDBOX={}These settings enforce a 1‑second execution timeout and an empty sandbox, preventing access to the host environment.
3. Patch the expression evaluator manually
If an upgrade is not feasible, apply a local patch to ExpressionEvaluator.ts to reject dangerous destructuring patterns. Add the following guard before compiling the expression:
const dangerousProps = ['constructor', 'prototype', '__proto__'];
if (expression.includes('constructor') || expression.includes('prototype')) {
throw new Error('Expression contains disallowed properties');
}Deploy the patched file in the packages/n8n-core/src directory and restart the n8n service.
4. Enforce role‑based access control (RBAC)
Ensure that only users with the workflow editor role can create or modify nodes that accept expressions. Disable the Expression node type for standard users by editing the n8n.config.json file:
"nodeTypes": {
"Expression": {
"enabled": false
}
}5. Monitor for anomalous activity
Implement logging of expression evaluation events. Configure the n8n.log file to capture the following fields:
- Timestamp
- User ID
- Workflow ID
- Expression string
- Execution result (success/failure)
Set up alerts for repeated failures or execution of expressions containing suspicious patterns.
What additional authentication layers can be added to n8n?
Beyond the built‑in authentication, the following layers enhance security:
- OAuth2 with two‑factor authentication (2FA) – configure n8n to use an external OAuth2 provider that supports 2FA, such as Auth0 or Azure AD.
- API key rotation – enforce a policy that requires API keys to be rotated every 90 days. Use the
N8N_API_KEY_ROTATION_DAYSenvironment variable. - IP whitelisting – restrict access to the n8n web interface to known IP ranges by configuring a reverse proxy (NGINX or Traefik) with
allowanddenydirectives. - Rate limiting – apply rate limits on the API endpoints to mitigate brute‑force attempts. This can be achieved with middleware such as
express-rate-limitin the n8n server configuration.
How can I verify that the vulnerability has been mitigated?
Verification involves both static analysis and dynamic testing:
- Static code review – ensure that the patched
ExpressionEvaluator.tsfile contains the guard clauses and that noevalcalls remain. - Unit tests – run the n8n test suite with the
--coverageflag to confirm that expression evaluation paths are exercised. Look for a coverage percentage of at least 95% for the evaluator module. - Penetration testing – execute the following payload against a staging instance:
({constructor:{prototype:{exec:function(){require('child_process').execSync('echo vulnerable')}}}})Verify that the response is a syntax error or a rejection, and that no shell command is executed.
What are the long‑term best practices for securing n8n expression evaluation?
Adopting a defense‑in‑depth approach ensures resilience against future vulnerabilities:
- Maintain the latest n8n releases and apply security patches promptly.
- Use a dedicated sandboxing library with proven isolation guarantees, such as
isolated-vm, and keep its dependencies up to date. - Implement strict input validation for all user‑supplied expressions, rejecting any that contain disallowed patterns.
- Enforce least‑privilege execution by running n8n under a non‑root user with minimal filesystem permissions.
- Regularly audit logs for anomalous expression evaluation attempts and conduct periodic security reviews.
Protocol/Artifact Reference
For further technical details and source code references, consult the following artifacts:
- N8N Release Notes – 1.0.0-rc.2: https://github.com/n8n-io/n8n/releases/tag/v1.0.0-rc.2
- CVE-2026-25049 Advisory: https://nvd.nist.gov/vuln/detail/CVE-2026-25049
- ExpressionEvaluator Source: https://github.com/n8n-io/n8n/blob/main/packages/n8n-core/src/ExpressionEvaluator.ts
- vm2 Documentation: https://github.com/patriksimek/vm2
- isolated-vm Documentation: https://github.com/lucas-clemente/isolated-vm
- Security Best Practices for Node.js: https://nodejs.org/en/docs/guides/security-best-practices/
These references provide the necessary context for implementing the mitigation steps outlined above and for maintaining a secure n8n deployment in the face of evolving threats.





