highJul 22, 2026

n8n Edit Image Node Format Injection Allows Arbitrary File Write

Shubham Kandhare
Security Engagement Manager, SecureLayer7

The n8n Edit Image node accepted a user-controlled output format string without validation and passed it directly to GraphicsMagick, letting any authenticated workflow user write files to arbitrary…

Packagen8n
Ecosystemnpm
Affected< 1.123.67
Fixed in1.123.67

The problem

The Edit Image node (n8n-nodes-base.editImage) exposes an output format option and forwards it, unvalidated, to the underlying GraphicsMagick/ImageMagick gm binary.

GraphicsMagick accepts output paths in FORMAT:filepath notation. With no allowlist in place, an attacker could inject a path-traversal component into the format field and cause the library to write the output image to any location the n8n process can reach on disk.

Proof of concept

A working proof-of-concept for this issue in n8n, with the exact payload below.

json
{
  "parameters": {
    "operation": "resize",
    "width": 100,
    "height": 100,
    "options": {
      "outputFormat": "png:../../tmp/evil"
    }
  },
  "type": "n8n-nodes-base.editImage",
  "typeVersion": 1
}

GraphicsMagick and ImageMagick both accept the FORMAT:path prefix syntax, where FORMAT controls the codec used to encode the output file. The gm Node.js wrapper passes the format value directly into the output path string it hands to the binary. Before the fix, n8n read outputFormat from the node parameters and wrote outputFormat + ':' + tmpFilePath with no validation, so any string that included a .. traversal sequence or an absolute path would redirect the write.

The patch in commit f69dfc6 introduces an allowlist of safe format strings (png, jpg, jpeg, gif, webp, tiff, bmp) and throws an error before invoking gm if the supplied value is not in that list. This maps to CWE-73: External Control of File Name or Path.

The fix

Upgrade to n8n 1.123.67, 2.31.5, or 2.32.1. If upgrading is not immediately possible, add n8n-nodes-base.editImage to the NODES_EXCLUDE environment variable to disable the node entirely, or restrict instance access to fully trusted users only.

Reported by csuermann (n8n security team).

References: [1][2][3][4][5][6]

Related research