/

CVE-2026-59257

Severity:

HIGH RISK

(8.8)

SQL Injection (CWE-89) in n8n Legacy MySQL v1 Node

CVE-2026-59257

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution on Backend Database

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

A SQL injection flaw in n8n's legacy MySQL v1 node lets expression-evaluated values be concatenated directly into raw SQL queries without parameter binding.

When workflows use executeQuery with attacker-controlled expression inputs behind externally-reachable triggers, an attacker can run arbitrary SQL under the configured MySQL credentials.

Affected context

This vulnerability appears in n8n workflows that use the legacy MySQL v1 node's executeQuery operation with dynamic expressions (e.g., {{ $json.someField }}).

Risk increases when:

  • The workflow is wired to an externally-reachable trigger such as a Webhook node, and
  • User-supplied request data flows into those expressions.

Under these conditions, the expression output is inserted into the SQL string without parameterization, enabling input-driven modification of the final query.

Exploit preconditions

  • Attack surface: Any n8n workflow exposing an external trigger (e.g., Webhook) that feeds data into MySQL v1 executeQuery expressions.
  • Required access: Ability to send crafted requests to the exposed trigger endpoint or otherwise influence expression-sourced values used in queries.
  • Trigger point: Evaluation of {{ ... }} expressions followed by construction and execution of the raw SQL string by the MySQL v1 node.
  • Why exploitation is possible: The node builds SQL via string concatenation instead of using parameterized queries, so attacker-controlled expression output is treated as part of the executable SQL statement.

Why this happens

The underlying bug is the direct interpolation of evaluated expression values into query strings in the legacy MySQL v1 node.

Instead of binding values through placeholders and parameterized queries, the implementation relies on manual string assembly, allowing data to alter the query's structure.

This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where untrusted input is not safely separated from SQL syntax.

Potential impact

  • An attacker may read sensitive data from tables accessible to the configured MySQL account.
  • An attacker could modify or delete records, leading to data corruption or loss.
  • Workflows and application logic can be impacted by unauthorized changes to configuration or state tables.
  • Depending on database privileges, the attacker may create new accounts or escalate influence within the database environment.

General mitigation guidance

Effective mitigation focuses on removing string-based query construction and reducing trust in expression-sourced data.

Defensive patterns include:

  • Using parameterized queries or prepared statements for all dynamic SQL, ensuring values are bound rather than concatenated.
  • Designing workflows so that external input is validated and constrained to expected formats before being used in database operations.
  • Separating query structure from data by defining fixed SQL templates and allowing only controlled, whitelisted parameters to vary.
  • Assigning least-privilege credentials to the MySQL connection so that even if a query is abused, its impact is limited.
  • Avoiding legacy database nodes that do not enforce secure-by-default query construction patterns.

How teams detect issues like this

Detection typically involves a mix of code and workflow review along with automated checks:

  • Static analysis or workflow linting rules that flag concatenation of {{ ... }} expression outputs into raw SQL strings.
  • Review of n8n workflows for use of the legacy MySQL v1 node and examination of executeQuery operations that accept external input.
  • Policy-based controls that restrict the use of non-parameterized query patterns and enforce parameter binding for all database operations.
  • Logging and monitoring of unusual or overly complex SQL statements originating from workflow executions, coupled with anomaly detection on query patterns.

Sources

SourceLink
github.comgithub.com/n8n-io/n8n/security/advisories/GHSA-hwmj-qg4v-cvg9
vulncheck.comvulncheck.com/advisories/n8n-sql-injection-in-mysql-v1-executequery-operation-via-expression-interpolation

Frequently asked

questions

Yes, when the affected workflow is exposed via triggers like Webhook nodes or similar externally-reachable inputs. If no external input reaches the expressions used in queries, the practical attack surface is reduced.

An attacker needs the ability to provide data to the workflow's trigger or any other mechanism that populates expression-sourced values used by the MySQL v1 executeQuery operation. They do not require direct access to the database itself.

The safest pattern is to rely on parameterized queries or prepared statements for all database interactions, ensuring that data is bound as parameters, not concatenated. Additionally, design queries as fixed templates and restrict variable parts to validated, typed parameters.

Treat any expression-driven database interaction as untrusted by default, enforce strict input validation, and standardize on secure database access components that use parameter binding. Incorporating workflow reviews, automated linting, and least-privilege database credentials into your development process helps prevent similar injection flaws.

Find out what's already
exploitable in your codebase.