n8n Unauthenticated Arbitrary File Read to RCE Full Chain — CVE-2026-21858 + CVE-2025-68613
by Chocapikk (exploit); vulnerability discovered by Dor Attias (Cyera) · 2026-07-05
- Severity
- Critical
- CVE
- CVE-2026-21858, CVE-2025-68613
- Category
- web
- Affected product
- n8n workflow automation platform
- Affected versions
- <= 1.65.0 (arbitrary file read, CVE-2026-21858); >= 0.211.0 (expression injection RCE, CVE-2025-68613); fixed in 1.121.0 / 1.120.4+ respectively
- Disclosed
- 2026-07-05
- Patch status
- patched
Tags
References
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-06 |
| Author / Researcher | Chocapikk (exploit); vulnerability discovered by Dor Attias (Cyera) |
| CVE / Advisory | CVE-2026-21858, CVE-2025-68613 |
| Category | web |
| Severity | Critical |
| CVSS Score | 10.0 (CVE-2026-21858, AFR) / 9.9 (CVE-2025-68613, RCE) |
| Status | Weaponized |
| Tags | n8n, arbitrary-file-read, jwt-forgery, sandbox-bypass, expression-injection, rce, workflow-automation |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | n8n workflow automation platform |
| Versions Affected | <= 1.65.0 (arbitrary file read, CVE-2026-21858); >= 0.211.0 (expression injection RCE, CVE-2025-68613); fixed in 1.121.0 / 1.120.4+ respectively |
| Language / Platform | Python 3 (uv run, requests, pyjwt), Docker lab environment |
| Authentication Required | No (initial file-read step is unauthenticated) |
| Network Access Required | Yes |
Summary
This PoC chains two n8n vulnerabilities into full unauthenticated remote code execution. First, CVE-2026-21858 is a Content-Type confusion bug in n8n’s binary file handling: sending Content-Type: application/json instead of multipart/form-data to a form endpoint lets an attacker control the filepath argument passed into n8n’s file-copy helper, yielding arbitrary file read. The exploit uses this to read /proc/self/environ (to find $HOME), then $HOME/.n8n/config (to get the instance’s encryptionKey) and $HOME/.n8n/database.sqlite (to get the admin user’s password hash). It derives the JWT signing secret from the encryption key and forges a valid admin session cookie without ever authenticating. With admin access, it creates a workflow using an n8n expression that reaches this.process.mainModule.require — an expression-injection sandbox escape (CVE-2025-68613) — to run arbitrary shell commands via child_process.execSync. The exploit is not a universal “pwn any n8n” tool: it requires a publicly reachable form workflow with a file-upload field and a Respond-to-Webhook node configured to return the file’s binary content in the HTTP response, a pattern the author found present in a number of public community workflow repositories.
Vulnerability Details
Root Cause
CVE-2026-21858: the pre-patch form file-handling code trusted an attacker-supplied filepath field taken from JSON body data instead of enforcing genuine multipart/form-data uploads, so context.nodeHelpers.copyBinaryFile(file.filepath, ...) would copy and return the contents of any file path supplied by the client. CVE-2025-68613: n8n’s expression evaluator exposes this.process.mainModule.require inside workflow expressions on default installs, letting an expression require("child_process") and execute arbitrary commands, bypassing the intended sandbox restrictions on the Code Node.
Attack Vector
- Locate a public n8n form workflow with a file-upload field whose “Respond to Webhook” node returns the uploaded file’s content as binary in the HTTP response.
- Submit a request with
Content-Type: application/jsonand a craftedfilepath(e.g./proc/self/environ) instead of an actual multipart upload, triggering the Content-Type confusion bug to read arbitrary files. - Read
/proc/self/environto locate$HOME, then read$HOME/.n8n/configfor theencryptionKeyand$HOME/.n8n/database.sqlitefor the admin user’s credential hash. - Derive the JWT signing secret from the encryption key (
sha256(encryption_key[::2])) and forge a validn8n-authadmin session cookie. - Using the forged admin session, create/execute a workflow containing an expression payload that calls
this.process.mainModule.require("child_process").execSync(cmd), achieving remote code execution as the n8n process user.
Impact
Full unauthenticated compromise of a vulnerable n8n instance: arbitrary file disclosure, forged administrative access, and ultimately arbitrary OS command execution as the n8n service account (observed as root in the author’s Docker lab).
Environment / Lab Setup
Target: n8n (Docker), vulnerable form workflow with file-upload + Respond-to-Webhook binary node
Attacker: Python 3, uv (or pip install requests pyjwt), Docker + docker-compose for the bundled lab
Bundled lab: docker-compose.yml / Dockerfile / init/setup.sh stand up a pre-configured vulnerable n8n instance with the exploitable form workflow and demo admin credentials.
Proof of Concept
PoC Script
See
exploit.pyin this folder (lab bootstrap:Dockerfile,docker-compose.yml,init/setup.sh,pyproject.toml).
| |
The script automates the full chain end-to-end: it reads the environment and SQLite database via the Content-Type confusion bug, forges an admin JWT/session cookie from the recovered encryption key, then deploys and triggers a malicious workflow expression to execute attacker-supplied commands and return their output.
Detection & Indicators of Compromise
Signs of compromise:
- HTTP requests to
/form/<slug>with JSON bodies containingfilepath-like fields instead of actual file uploads - New or modified n8n workflows containing
={{ ... require("child_process") ... }}-style expressions - Unexpected reads of
.n8n/configor.n8n/database.sqlitereflected in application logs, or unexplained admin logins with no corresponding legitimate authentication event
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade n8n to 1.121.0+ (fixes CVE-2026-21858) and 1.120.4+ (fixes CVE-2025-68613) |
| Interim mitigation | Do not expose public forms with file-upload + binary Respond-to-Webhook nodes without authentication; restrict/disable expression evaluation features where not required; rotate the instance encryptionKey and all credentials after any suspected exposure |
References
Notes
Mirrored from https://github.com/Fomovet/cve-2026-21858 on 2026-07-05. The exploit script credits Chocapikk’s original research/exploit (https://github.com/Chocapikk/CVE-2026-21858); this mirror packages that work together with a Docker lab and detailed attack-chain documentation.
| |