/

CVE-2026-33660

Severity:

HIGH RISK

(8.8)

Code Injection via Inadequate SQL Sandbox in n8n Merge Node

CVE-2026-33660

Analyzed

Vulnerability type

Category:

Code Injection via Inadequate SQL Sandbox

CWE:

CWE-94, CWE-89

Impact:

Authenticated Remote Code Execution and Local File Disclosure

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

In affected versions of n8n, the Merge node's "Combine by SQL" mode uses an insufficiently restricted AlaSQL sandbox that allows authenticated workflow editors to execute dangerous SQL statements.

Under these conditions, an attacker who can create or modify workflows may read arbitrary local files from the n8n host and escalate to remote code execution, compromising the entire automation instance.

Affected context

This vulnerability occurs in n8n deployments that expose workflow creation or editing capabilities to users and make use of the Merge node in "Combine by SQL" mode.

The risk is present when:

  • Users can configure or modify the SQL expressions executed by the AlaSQL engine
  • The n8n instance runs with access to sensitive host files (e.g., configuration, credentials, environment variables)
  • The n8n application process has sufficient permissions that, if compromised, would impact other services or data

The vulnerability is not exposed to unauthenticated users by default, but any user with workflow-editing permissions becomes a powerful attacker within the instance.

Exploit preconditions

  • Attack surface: n8n web UI or API endpoints that allow creation or modification of workflows using the Merge node's "Combine by SQL" mode.
  • Required access: Authenticated account with permissions to create or edit workflows (including node configuration).
  • Trigger point: Execution of a workflow that includes a Merge node configured with attacker-controlled SQL in "Combine by SQL" mode.
  • Why exploitation is possible: The AlaSQL sandbox does not enforce strict limitations on the SQL dialect and permitted functions, allowing crafted statements to:
  • Access the local filesystem or environment
  • Escape the intended query-only behavior
  • Execute logic that ultimately results in arbitrary code execution in the n8n process context.

Why this happens

The core issue lies in relying on a sandboxed SQL engine (AlaSQL) for executing user-controlled SQL without adequately constraining what operations are allowed.

This maps to:

  • CWE-94: Improper Control of Generation of Code ('Code Injection') because user-supplied SQL can trigger execution paths equivalent to evaluating attacker-controlled code within the runtime.
  • CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in the sense that untrusted input is embedded into SQL statements executed by an engine that has capabilities beyond pure data querying.

Instead of limiting the language to safe, declarative operations on in-memory data sets, the sandbox permitted powerful statements and functions, effectively turning a data transformation feature into a code execution primitive tied to the host environment.

Potential impact

  • Disclosure of sensitive local files on the n8n host (e.g., configuration files, credentials, SSH keys, environment variables).
  • Execution of arbitrary commands or code with the privileges of the n8n process.
  • Complete compromise of the n8n instance, including stored credentials and connected integrations.
  • Pivoting to other internal systems reachable from the n8n host, using n8n's configured connections.
  • Tampering with workflows to introduce persistent malicious automation or data exfiltration.

General mitigation guidance

Long-term mitigation focuses on hardening how user-defined expressions and queries are executed inside workflow engines and eliminating unsafe code execution paths:

  • Constrain embedded languages: Treat SQL, JavaScript, or any embedded DSL as untrusted code. If user-defined expressions are needed, restrict them to a minimal, declarative subset without filesystem, process, or networking capabilities.
  • Use hardened interpreters: Prefer execution environments that are designed for sandboxing (e.g., interpreters without access to host APIs) and configure them with explicit allow-lists of permitted functions and operations.
  • Separate privileges: Run workflow engines and query evaluators under dedicated, least-privilege OS accounts with minimal file and network access so that even a sandbox breakout has limited blast radius.
  • Strict node capability design: For nodes that allow user-defined logic (SQL, code, expressions), design them around pre-defined parameters and templates rather than raw, free-form source strings, wherever possible.
  • Permission scoping: Limit who can define or edit nodes that execute user-supplied expressions, and consider role-based controls that distinguish between "safe" node configuration and "advanced/scripted" configuration.
  • Configuration hardening: Avoid storing long-lived secrets or highly sensitive files on the same host or within the same privilege domain as the workflow engine when possible; use secret managers and network-layer protections.

How teams detect issues like this

Effective detection combines code-level and configuration-level review with runtime monitoring:

  • Static analysis & code review:
  • Flag use of general-purpose interpreters (SQL engines, JS evaluators) where input is directly or indirectly controlled by users.
  • Search for calls into AlaSQL or similar APIs that are passed raw user-defined strings without strict validation or allow-listing.
  • Review node implementations that expose "script", "SQL", or "expression" fields to ensure they enforce safe subsets and do not provide host-level capabilities.
  • Policy and CI gates:
  • Enforce secure coding guidelines requiring explicit sandbox configuration or allow-listing for any embedded languages.
  • Integrate SAST or custom linters into CI that detect insecure sandbox or interpreter usage patterns.
  • Runtime monitoring:
  • Monitor the workflow engine for abnormal filesystem access patterns originating from workflow execution processes.
  • Log and analyze advanced node configurations (e.g., SQL modes) for high-risk usage patterns, such as access to non-workflow data.
  • Configuration audits:
  • Periodically review which users or API tokens can create or edit workflows, and whether high-risk nodes or modes are enabled.
  • Inspect existing workflows for use of powerful "SQL" or "code" features that may be exploitable.

Sources

SourceLink
github.comgithub.com/n8n-io/n8n/security/advisories/GHSA-58qr-rcgv-642v

Frequently asked

questions

Yes, but only by authenticated users who can create or modify workflows. An attacker who can access the n8n UI or API with sufficient permissions can exploit the vulnerable Merge node configuration over the network.

The attacker needs an account (or compromised API key) that has permission to create or edit workflows and configure the Merge node in "Combine by SQL" mode. No direct shell or filesystem access is required; the attack leverages the workflow itself.

Avoid executing user-controlled strings in powerful interpreters or engines unless they are strictly sandboxed and limited to a safe subset of operations. Prefer allow-listed operations, constrained schemas, and declarative configuration over arbitrary code or SQL execution.

Design the platform such that user customization is performed through structured configuration and pre-defined building blocks rather than free-form code or queries. Combine this with least-privilege runtime isolation, granular permission models for "advanced" nodes, secure-by-default sandboxing, and continuous security review of any feature that interprets user-supplied logic.

Find out what's already
exploitable in your codebase.