Summary
An arbitrary file write vulnerability in n8n's Edit Image node allows an authenticated workflow user to provide an unvalidated image format value.
When the workflow runs, the underlying image library may write output files outside the node's intended working directory on the n8n instance.
Affected context
The vulnerability occurs in n8n deployments that:
- Expose the Edit Image node to authenticated users who can create or run workflows
- Pass user-controlled output format values to the underlying image-processing library
- Do not constrain generated output paths to the node's designated working directory
Risk depends on the permissions of the n8n process and the files accessible from its runtime environment.
Exploit preconditions
- Attack surface: The n8n Edit Image node and its image-output format parameter
- Required access: An authenticated account with permission to create or execute workflows
- Trigger point: Execution of a workflow containing the Edit Image node
- Why exploitation is possible: The supplied format value reaches the image library without adequate validation or confinement, allowing output to be written outside the intended directory
Why this happens
The underlying bug is insufficient validation of a value that influences file-output behavior. The Edit Image node forwards the output format parameter to an image-processing library without restricting it to an approved set of formats or ensuring that resulting writes remain within an expected directory.
This maps to CWE-434: Unrestricted Upload of File with Dangerous Type, because attacker-influenced file-generation behavior can produce files in locations not intended by the application. The insecure pattern is treating a workflow-controlled format or filename-related value as trusted when constructing output.
Potential impact
- An attacker may overwrite files accessible to the n8n process
- The n8n application configuration or workflow state could be modified
- Application availability could be disrupted through destructive file changes
- Sensitive data could be exposed or altered indirectly
- Arbitrary file writes could contribute to code execution if a writable location is later processed as executable content
General mitigation guidance
Mitigation generally focuses on constraining image-output behavior and reducing the trust placed in workflow parameters.
Common defensive patterns include:
- Allowing only a strict, predefined set of supported image formats
- Separating format selection from filesystem path construction
- Generating output names server-side rather than accepting path-like values
- Canonicalizing and validating paths, then enforcing confinement to a dedicated working directory
- Using a dedicated, minimally privileged service account for n8n
- Applying filesystem permissions, read-only mounts, and container isolation where practical
- Preventing workflows with sensitive file-writing capabilities from being available to untrusted users
- Treating image-processing libraries as untrusted-input boundaries and validating parameters before invocation
How teams detect issues like this
Detection approaches can include:
- Static analysis for image-library calls that receive workflow or request values without allowlist validation
- Code review checks for format, filename, and path parameters crossing into filesystem APIs
- Tests that verify generated files remain within an approved working directory
- Runtime monitoring for n8n processes creating or modifying files outside designated application paths
- Policy enforcement that restricts workflow authorship and execution permissions for file-writing nodes
- Automated security review tools that flag unrestricted file-generation and path-construction patterns

