Summary
n8n's Snowflake and legacy MySQL v1 nodes construct SQL queries by directly interpolating user-controlled identifiers such as table names, column names, and update keys into query strings without proper escaping.
Under certain workflow configurations, this allows an attacker who can influence these node parameters to perform SQL injection against the connected database, potentially leading to data exposure, tampering, or further compromise.
Affected context
This vulnerability arises in n8n workflows that use:
- The Snowflake node, or
- The legacy MySQL v1 node
In affected contexts, workflow authors or integrations allow user-supplied or otherwise untrusted data to flow into node parameters that determine:
- Table names
- Column names
- Update/where keys
Because these identifiers are concatenated directly into SQL query strings without proper identifier quoting or escaping, any environment where these node parameters are influenced by external input (e.g., HTTP triggers, webhooks, form submissions, or upstream automation) can become vulnerable.
Exploit preconditions
- Attack surface: The workflow execution path that uses the Snowflake or legacy MySQL v1 node.
- Required access: Ability to influence or configure node parameters such as table name, column name, or update keys. This can be through:
- Direct access to n8n workflow configuration, or
- Indirect control via external inputs bound to these parameters (e.g., incoming requests, API payloads, or other nodes).
- Trigger point: Execution of a workflow run where the vulnerable node builds and runs its SQL query using the attacker-controlled identifiers.
- Why exploitation is possible: The node constructs SQL statements by string concatenation with unvalidated and unescaped identifier fields, bypassing proper parameterization or identifier quoting, which allows crafted input to alter the intended structure of the SQL query.
Why this happens
The core bug is the construction of SQL queries via string concatenation with user-controlled identifiers, rather than treating those values as data.
While many libraries provide mechanisms for parameterizing values, identifiers like table names and column names require careful quoting or whitelisting. In this case, the Snowflake and legacy MySQL v1 nodes interpolate these identifier parameters directly into the SQL text without:
- Applying proper identifier quoting/escaping rules for the target database, or
- Restricting them to a controlled set of allowed values.
This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where untrusted input is embedded directly into SQL commands, enabling attackers to modify query semantics, access unintended data, or affect database state.
Potential impact
- Unauthorized reading of database records the workflow's DB user can access.
- Modification or deletion of data in the connected Snowflake or MySQL database.
- Creation or alteration of database objects (tables, views, users) if the DB account has elevated privileges.
- Circumvention of application-level access controls enforced via database logic.
- Potential execution of database-specific features (e.g., stored procedures) that could lead to broader system impact depending on configuration.
General mitigation guidance
Effective mitigation focuses on eliminating raw string interpolation for SQL construction and tightening trust boundaries on workflow inputs:
- Prefer parameterized queries for values wherever possible, even if identifiers require separate handling.
- For table and column names:
- Constrain them to a whitelisted set that is defined in configuration or code, not user input.
- Apply database-appropriate identifier quoting and validation, ensuring only expected characters (e.g., alphanumerics and underscores) are allowed.
- Encapsulate database operations behind higher-level abstractions (e.g., data access layers, ORM-like helpers) that expose only safe operations instead of raw SQL construction.
- Apply least privilege to database accounts used by n8n nodes so that, if injection occurs, the impact is limited to the minimal necessary tables and operations.
- Treat all external input into workflow nodes as untrusted and design workflows so that user-supplied data cannot directly control structural aspects of SQL statements.
How teams detect issues like this
Detection typically involves both code-level and configuration-level reviews:
- Static analysis / code scanning:
- Look for concatenation patterns in node implementations involving SQL keywords and variables (e.g.,
SELECT ... FROM+ tableName). - Flag any use of dynamic identifiers in query strings without centralized escaping utilities or whitelist checks.
- Configuration and workflow review:
- Inspect workflows using Snowflake or legacy MySQL v1 nodes where table/column names are bound to expressions or external inputs.
- Identify nodes where the same variable or expression controls both data values and structural SQL elements.
- Logging and anomaly detection:
- Enable detailed database query logging to spot unusual or malformed queries originating from n8n.
- Monitor for queries containing unexpected SQL keywords or multiple statements in contexts that should be simple operations.
- Policy enforcement:
- Establish internal guidelines or CI checks for custom nodes to forbid raw SQL string construction from untrusted inputs.
- Use automated review tools that can scan node code and workflow configurations for insecure SQL composition patterns.

