Listen to this Post
This vulnerability operates in self-hosted n8n instances where the Code node is configured to run in legacy JavaScript execution mode, which does not use task runners. Authenticated users with access to edit workflows can write and execute custom JavaScript code within the Code node. In legacy mode, this execution context is not isolated and shares the same process and privileges as the main n8n application. Consequently, attackers can invoke internal helper functions that are normally restricted to the n8n system itself. By calling these functions, malicious users can bypass intended security boundaries. Specifically, functions that interface with the file system can be accessed, allowing arbitrary file read and write operations on the host machine. The n8n process typically runs with sufficient permissions, so these actions are executed with high privileges. Although n8n version 1.2.1 introduced a default block on accessing the `.n8n` home directory, this restriction is limited. Without additional configuration, the entire filesystem remains exposed. The core issue is the lack of sandboxing or context separation for user-supplied code in the legacy execution environment. This enables privilege escalation from a workflow editor to a system-level actor. Exploitation requires valid user credentials and permissions to edit workflows, which may be common in collaborative environments. Once exploited, attackers can read sensitive system files, deploy malicious scripts, or alter application data. The vulnerability is critical due to the potential for full host compromise, especially in default configurations where no extra file access limits are set. Mitigation involves forcing code execution through task runners, which run scripts in isolated processes with restricted privileges.
Platform: n8n
Version: Pre-2.0.0 versions
Vulnerability: Internal function invocation
Severity: Critical
date: Not disclosed
Prediction: Patched in v2.0.0
What Undercode Say:
export N8N_RUNNERS_ENABLED=true export N8N_RESTRICT_FILE_ACCESS_TO=~/.n8n-files export N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES=true
// Example exploit code in Code node
const fs = require('fs');
const path = '/etc/passwd';
const data = fs.readFileSync(path, 'utf8');
$node.output().setItem({ file: data });
How Exploit:
Authenticated user edits workflow, adds Code node, injects JavaScript to call internal file system functions, reads or writes host files.
Protection from this CVE:
Upgrade to n8n version 2.0.0 or later, enable task runners via N8N_RUNNERS_ENABLED=true, restrict file access with N8N_RESTRICT_FILE_ACCESS_TO, block .n8n directory access, exclude Code node via NODES_EXCLUDE if untrusted users.
Impact:
Full host file system access, potential data theft, system compromise, privilege escalation.
🎯Let’s Practice Exploiting & Learn Patching For Free:
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

