Summary
A path traversal issue in n8n workflows that use the SSH node to transfer uploaded files can allow crafted file metadata to control where files are written on remote servers.
When file upload endpoints are unauthenticated and workflows do not validate file paths or metadata, an attacker may cause files to be stored in unintended locations on remote systems, potentially enabling remote code execution.
Affected context
This vulnerability affects n8n deployments that:
- Expose HTTP endpoints (e.g., webhook or form uploads) for file submission, and
- Use workflows that take uploaded files and pass their metadata directly into the SSH node for remote file transfer, and
- Do not validate or sanitize file path–related metadata (such as filenames, directories, or upload paths) before using it on remote systems.
It is most relevant where:
- Upload endpoints are publicly accessible or lack authentication, and
- The remote SSH targets have sensitive directories or executable paths that can be written to by the account used in the SSH node.
Exploit preconditions
- Attack surface: Public or internal n8n file upload endpoints that trigger workflows using the SSH node to place files on remote servers.
- Required access: Network access to the exposed upload endpoint; no n8n authentication is required if the endpoint is unauthenticated.
- Attacker knowledge: Awareness that such a workflow exists and knowledge (or discovery) of the upload endpoint URL.
- Trigger point: Submission of a crafted file upload that includes malicious path components in the filename or associated metadata consumed by the workflow.
- Why exploitation is possible: The workflow trusts user-controlled file metadata and passes it directly to the SSH node, which writes files on remote systems without enforcing a safe base directory or normalizing paths to prevent traversal.
Why this happens
The underlying issue is improper validation and sanitization of user-controlled path data before it is used to construct file destinations on remote systems.
In affected workflows, uploaded file metadata (often including filenames or paths) is treated as trustworthy and interpolated into SSH node parameters that determine where files are written.
Because the workflow logic does not constrain paths to a known-safe directory or strip traversal sequences, an attacker can inject ../ or absolute paths to escape intended locations.
This behavior aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where a system fails to restrict file operations to a safe subset of the filesystem, enabling path traversal and potentially arbitrary file write.
Potential impact
- Files may be written outside the intended upload directory on remote systems.
- Overwriting of existing files that the SSH account has permission to modify.
- Placement of web shells or executable scripts in web-accessible directories, enabling remote code execution.
- Modification of configuration files or service scripts, which may be executed on service restart or system boot.
- Escalation of access on remote systems if critical binaries or authorized-keys–style files can be overwritten.
General mitigation guidance
Effective mitigation focuses on enforcing strict control over file paths and reducing trust in upload metadata:
- Constrain all remote file writes to a fixed, server-side–defined directory and never accept full paths directly from user input.
- Normalize and validate filenames to remove path separators and traversal sequences before building remote paths.
- Implement allowlists for acceptable filename patterns or extensions; reject or rewrite anything outside these constraints.
- Introduce explicit validation nodes or custom code within workflows to check and sanitize file-related fields before passing them to the SSH node.
- Run SSH actions under least-privilege accounts with minimal filesystem write permissions and no access to sensitive or executable directories.
- Require authentication and, where possible, authorization checks for file upload endpoints to limit who can trigger these workflows.
How teams detect issues like this
Detection often involves reviewing workflow configurations and applying static checks to automation logic:
- Inspect n8n workflows that use file upload triggers followed by SSH nodes, especially where upload metadata flows directly into remote path fields.
- Use static analysis or configuration linting rules to flag patterns where user-controlled variables are interpolated into file paths or SSH upload destinations without validation.
- During code or workflow reviews, look for:
- Direct use of filename or path fields from HTTP requests in SSH node parameters.
- Absence of normalization or validation steps between file ingestion and remote write.
- Use of template expressions that reference raw upload metadata in path-related fields.
- Monitor logs on remote systems for unusual file write patterns (e.g., files appearing in configuration directories or web roots) originating from automation service accounts.
- Employ security scanning tools or CI checks that understand n8n workflow syntax to enforce policies around path handling and external file writes.

