n8n Sandbox Escape Lets Workflow Editors Run OS Commands as the n8n Process
An authenticated workflow editor in n8n can execute arbitrary operating-system commands on the server due to a high-severity expression-sandbox escape. The vulnerability was discovered by Security Joes while probing a previous fix for CVE-2026-27577, and it affects versions <2.31.5 and >=2.32.0,<2.32.1. The exploit relies on two conditions: an arrow-function gap in VariablePolyfill.ts and a bypass in property checks involving Reflect.get(), allowing access to Node.js globals like process. n8n pa
Analysis
TL;DR
- An authenticated workflow editor in n8n can execute arbitrary operating-system commands on the server due to a high-severity expression-sandbox escape.
- The vulnerability was discovered by Security Joes while probing a previous fix for CVE-2026-27577, and it affects versions <2.31.5 and >=2.32.0,<2.32.1.
- The exploit relies on two conditions: an arrow-function gap in VariablePolyfill.ts and a bypass in property checks involving Reflect.get(), allowing access to Node.js globals like process.
- n8n patched the issue in versions 2.31.5 and 2.32.1 with a dedicated ArrowFunctionExpression handler and improved identifier rewriting, but interim mitigations (restricting access) are considered incomplete.
- Successful exploitation could expose N8N_ENCRYPTION_KEY, decrypt stored credentials, and provide lateral movement to connected databases, internal services, or cloud endpoints.
Why It Matters
This incident underscores the critical importance of rigorous sandboxing in automation platforms that allow user-defined expressions, especially when those expressions are executed with elevated privileges. For AI practitioners and security teams, it highlights how subtle implementation flaws—such as missing AST rewrites for concise arrow functions or inadequate property inspection—can lead to full remote code execution, even after prior fixes. The recurrence of similar escapes since 2025 suggests systemic challenges in securing expression evaluation layers, urging developers to adopt defense-in-depth strategies including comprehensive testing, least-privilege credential management, and continuous monitoring for anomalous process behavior.
Technical Details
- Vulnerability Scope: Affects n8n versions <2.31.5 and >=2.32.0,<2.32.1; patched in 2.31.5 and 2.32.1 under GHSA-gv7g-jm28-cr3m with CVSS 8.7 (High).
- Exploit Mechanism: Combines two flaws: (1) In version 2.31.4, VariablePolyfill.ts placed ArrowFunctionExpression in a no-op branch, allowing concise arrow bodies like () => process to resolve 'process' to the real Node.js global instead of the sandboxed context; (2) Property checks using Reflect.get() failed to intercept dynamic property access, enabling recovery of process.getBuiltinModule to load child_process and spawn OS commands.
- Prerequisites: Requires a valid account with workflow edit permissions; no user interaction needed beyond authentication. Execution occurs with the privileges of the n8n process.
- Impact: Full server compromise possible, including exposure of N8N_ENCRYPTION_KEY, decryption of stored credentials, and access to backend systems reachable from the n8n host.
- Fix Implementation: Updated abstract syntax tree rewriter now includes a dedicated ArrowFunctionExpression handler that routes bare identifiers in concise arrow bodies through the controlled data context, preventing leakage of Node.js globals.
Industry Insight
Organizations using n8n or similar workflow automation tools must prioritize immediate patching to vulnerable versions and conduct forensic reviews of recent workflows for obfuscated JavaScript or unexpected arrow functions. Given the history of repeated sandbox escapes in n8n, enterprises should enforce strict separation of duties—limiting workflow editing to highly trusted personnel—and implement runtime monitoring for suspicious child processes (e.g., shells, curl, wget) spawned by n8n or Node.js. Additionally, credential hygiene is paramount: rotate any potentially exposed secrets and consider isolating n8n instances with minimal network access to reduce blast radius in case of future vulnerabilities.
Disclaimer: The above content is generated by AI and is for reference only.