Summary
A path traversal vulnerability in n8n's MCP node-schema loader allows an authenticated user with global:member privileges to influence which schema module is loaded. By referencing a malicious file through a crafted node type, an attacker may achieve remote code execution in the n8n main process.
Affected context
The vulnerability occurs in n8n deployments that use the MCP node-schema loading workflow and derive schema module paths from node type values. Risk is present when an authenticated user with the required global:member privilege can supply or influence a node type string and the loader does not safely constrain the resulting filesystem path.
Exploit preconditions
- Attack surface: MCP node-schema loading in the n8n main process
- Required access: An authenticated account with global:member privileges
- Trigger point: Processing an attacker-influenced node type during schema module resolution
- Why exploitation is possible: The loader uses the supplied node type to construct a module path without adequately rejecting path-traversal sequences, allowing unintended local files to be referenced and loaded
Why this happens
The underlying issue is insufficient validation and canonicalization of an attacker-controlled path component. The loader treats a node type string as a trusted module-path fragment without enforcing that the resolved path remains within an intended schema directory. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, and loading a referenced JavaScript module can extend the impact to code execution.
Potential impact
- An attacker may execute arbitrary code in the n8n main process
- The n8n instance could be compromised or altered
- Credentials, workflow data, and other application secrets could be exposed
- The attacker could use the process context to access connected services
- Workflows or integrations could be modified for persistence or data theft
General mitigation guidance
Mitigation generally focuses on eliminating filesystem path decisions based directly on untrusted node type values.
Common defensive patterns include:
- Resolve schema modules through a fixed allowlist of known node types and module identifiers
- Canonicalize candidate paths and verify that they remain within an intended, restricted directory
- Reject traversal indicators, absolute paths, unexpected separators, and other invalid path forms before resolution
- Prefer registry-based module lookup over dynamic filesystem-derived imports
- Apply least-privilege permissions to the n8n process and limit access to sensitive files
- Reduce the privileges and filesystem visibility available to authenticated users
How teams detect issues like this
Detection approaches can include:
- Static analysis rules for filesystem paths or dynamic imports constructed from request, workflow, or node-type data
- Code review checks for missing path canonicalization, directory-boundary validation, or allowlisting
- Runtime monitoring for unexpected module loads and access to files outside approved schema directories
- Policy enforcement that restricts dynamic module loading to approved packages and locations
- Automated security review tools that flag user-controlled values passed to path resolution or import APIs

