/

CVE-2026-27497

Severity:

HIGH RISK

(8.8)

SQL Injection Leading to Remote Code Execution

CVE-2026-27497

Analyzed

Vulnerability type

Category:

SQL Injection Leading to Remote Code Execution

CWE:

CWE-89, CWE-94

Impact:

Authenticated Remote Code Execution and Arbitrary File Write on the n8n Server

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 SQL query mode allows an authenticated workflow creator or editor to craft queries that lead to arbitrary code execution and arbitrary file writes on the n8n server.

This becomes risky in any deployment where users with workflow creation or modification rights are not fully trusted, effectively turning workflow configuration into a code execution primitive on the backend.

Affected context

This vulnerability arises in n8n instances where:

  • The Merge node is available and its SQL query mode is enabled in workflows.
  • Users are granted permissions to create or modify workflows, including adding or configuring Merge nodes.
  • The n8n server has access to underlying system resources (filesystem, OS, and potentially network) typical for its runtime.

The risk is pronounced in multi-tenant or shared environments where workflow authors are not strictly trusted or where internal accounts can be phished or taken over.

Exploit preconditions

  • Attack surface: n8n application interface or API used to create or update workflows that include the Merge node.
  • Required access: Valid authenticated account with permission to create or modify workflows (no need for direct system shell or DB access).
  • Trigger point: Execution of a maliciously configured workflow that uses the Merge node in SQL query mode.
  • Why exploitation is possible: The Merge node's SQL query mode fails to sufficiently constrain or sanitize query construction, enabling crafted inputs that break out of expected query logic and escalate to arbitrary code execution and file writes (CWE-89 and CWE-94).

Why this happens

The underlying issue maps to a combination of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') and CWE-94: Improper Control of Generation of Code ('Code Injection').

Within the Merge node's SQL query mode, user-controlled workflow configuration is effectively treated as trusted SQL and/or execution logic without robust parameterization or isolation. This allows a malicious workflow author to inject additional SQL or execution constructs that the backend interprets as legitimate instructions.

Conceptually, the bug class is:

  • Treating workflow configuration values as safe query/program fragments instead of data.
  • Allowing those fragments to influence control flow and low-level database or execution primitives.
  • Executing the resulting queries or code in the security context of the n8n server process, which typically has access to the filesystem and other sensitive resources.

Potential impact

  • An authenticated user may execute arbitrary code on the n8n server.
  • Attackers can write arbitrary files to the server's filesystem, potentially planting backdoors or modifying application behavior.
  • Compromise of all workflows, credentials, and secrets stored or accessible via the n8n instance.
  • Lateral movement into connected systems (databases, APIs, internal services) that n8n has permissions to access.
  • Full takeover of the n8n host if the process privileges and environment allow escalation.

General mitigation guidance

Effective mitigation centers on preventing user-controlled workflow configuration from becoming executable SQL or code:

  • Use strict parameterization for all database and query-building operations within workflow nodes; treat configuration values as data, never as query fragments.
  • Introduce clear separation between "data inputs" and "execution logic" in node configuration, disallowing arbitrary expressions in query strings where possible.
  • Restrict powerful node capabilities (such as SQL execution or file writes) behind permission scopes or role-based access control aligned to least privilege.
  • Enforce server-side validation of workflow definitions to detect and reject unsafe query patterns or dynamic code injection constructs.
  • Run the n8n server with reduced OS privileges, isolated service accounts, and minimal filesystem write access to limit blast radius.
  • Where feasible, sandbox execution contexts for nodes that interact with external databases or the filesystem so that injected logic cannot escape its boundary.

How teams detect issues like this

Detection typically involves reviewing both code and workflow configurations for unsafe patterns:

  • Static analysis and code review:
  • Flag any node implementation that concatenates user-supplied strings into SQL queries or other interpretable command/code formats.
  • Search for generic "query" fields that are passed directly to database or execution APIs without parameterization.
  • Examine file-writing utilities and ensure they cannot be fully controlled via workflow configuration without checks.
  • Workflow configuration review:
  • Periodically scan stored workflows for suspicious Merge node configurations, such as queries containing unexpected control keywords, system-specific functions, or file paths.
  • Implement policy-based checks in CI/CD or deployment pipelines when workflows are defined as code, rejecting risky query patterns.
  • Runtime monitoring:
  • Instrument logging for Merge node usage and correlate with anomalous database queries, file writes, or OS-level alerts.
  • Use host-based intrusion detection or EDR solutions to detect abnormal processes, file modifications, or command execution originating from the n8n process.

Automated SAST/IAST tools and configuration linters can assist by enforcing rules around query construction and privileged node usage.

Sources

SourceLink
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@1.123.22
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@2.10.1
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@2.9.3
github.comgithub.com/n8n-io/n8n/security/advisories/GHSA-wxx7-mcgf-j869

Frequently asked

questions

Yes, but only by authenticated users who can create or modify workflows. A remote attacker who obtains such an account (for example via credential theft or phishing) can exploit the vulnerability through the n8n UI or API.

The attacker needs an n8n account with permissions to create, edit, or configure workflows that use the Merge node. They do not require shell access to the server or direct database credentials; the attack is performed entirely via workflow configuration.

The most robust fix is to ensure that any workflow-driven SQL or code is strictly parameterized and never constructed by concatenating user-controlled strings. Additionally, high-impact node capabilities (SQL, file I/O, code-like expressions) should be tightly scoped, validated, and guarded by granular authorization.

Treat workflow configuration as untrusted input, apply the same secure coding standards used for web request parameters to node settings, and enforce defense-in-depth: parameterization, least privilege, sandboxing, and runtime monitoring. Regular security reviews of powerful nodes and automated checks for unsafe query or command construction help catch similar flaws early in development.

Find out what's already
exploitable in your codebase.