Summary
A SQL injection vulnerability in the n8n Data Table Get node allows an authenticated workflow editor to inject arbitrary SQL into database queries.
On PostgreSQL deployments this can enable multi-statement execution, including data modification or deletion; on the default SQLite backend, impact is more limited to manipulating single statements.
Affected context
The vulnerability occurs in n8n instances where:
- The Data Table Get node is available and used in workflows
- Users are allowed to create or modify workflows
- Workflow expressions can influence SQL-related parameters such as
orderByColumn - The instance uses a relational database backend (SQLite by default, PostgreSQL in many production setups)
Risk increases significantly in PostgreSQL deployments due to support for multi-statement execution and richer SQL features.
Exploit preconditions
- Attack surface: The n8n web interface / API for workflow creation and editing, specifically the configuration of the Data Table Get node.
- Required access: Authenticated account with permission to create or modify workflows that include the Data Table Get node.
- Trigger point: Execution of a workflow containing a Data Table Get node where
orderByColumn(or similar query-related fields) is set to an expression that incorporates attacker-controlled data. - Why exploitation is possible: User-controlled expressions are concatenated or interpolated into SQL queries without adequate parameterization or validation, allowing crafted input to alter the intended query structure.
Why this happens
This issue stems from constructing SQL queries using dynamic strings that directly embed user-controlled values from node expressions.
Instead of binding values through parameterized queries or restricting them to safe identifiers, the implementation allows arbitrary expression output to influence clauses such as ORDER BY. This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where untrusted input is not correctly sanitized before being included in a SQL statement, enabling attackers to change query logic or append additional commands.
Potential impact
- Unauthorized reading of additional records beyond what the workflow designer intended
- Modification or deletion of database records in PostgreSQL deployments
- Tampering with workflow-related or application data, affecting automation logic and business processes
- Escalation of impact to other integrated systems that depend on the integrity of n8n-managed data
- In some environments, pivoting to broader data exposure if the same database hosts other application schemas
General mitigation guidance
Effective mitigation focuses on eliminating unsafe query construction and tightening trust boundaries around workflow inputs:
- Replace string-concatenated SQL building with parameterized queries or query builders that separate SQL structure from values.
- Constrain query-related configuration fields (e.g., columns or table names) to validated, whitelist-based options instead of arbitrary expressions.
- Reduce trust in workflow input by treating all expression output as untrusted data, even if it originates from internal nodes.
- Apply least-privilege database permissions so the n8n database user can perform only the minimum required operations.
- Limit workflow creation and editing rights to users who are operationally trusted and have basic security awareness.
- Consider disabling high-risk nodes in environments where workflows can be edited by a broad user base.
How teams detect issues like this
Detection can combine code, configuration, and behavioral inspection:
- Static analysis / code review: Look for dynamic SQL string construction that interpolates node expressions or user-controlled variables, especially in ORDER BY, WHERE, or LIMIT clauses.
- Configuration review: Identify workflows containing Data Table Get nodes with
orderByColumnor similar fields set to expressions rather than fixed, validated values. - Database monitoring: Use query logging or database auditing to flag anomalous queries, such as those containing unexpected operators, stacked statements, or schema-manipulation commands.
- Policy enforcement: Introduce internal development standards or automated checks that prohibit direct string concatenation for SQL in node implementations and require parameterized access patterns.
- Automated security review tools or SAST scanners can be configured to detect patterns of unsafe SQL construction within workflow engine codebases.

