Summary
A high-severity SQL injection vulnerability in n8n's PostgresTrigger node allows authenticated users to influence SQL statements through channel, function, and trigger name parameters.
When the node connects to PostgreSQL using configured credentials, an attacker may inject arbitrary SQL and gain read or write access permitted by those credentials.
Affected context
The vulnerability occurs in n8n workflows that use the PostgresTrigger node and connect to a PostgreSQL database. It becomes risky when an authenticated user can configure or influence the node's identifier parameters, and those values are incorporated into SQL without adequate escaping or parameter-safe handling.
Exploit preconditions
- Attack surface: n8n workflow configuration through the PostgresTrigger node
- Required access: An authenticated n8n account with sufficient permissions to create or modify the relevant workflow or node configuration
- Trigger point: Processing channel, function, or trigger name values while constructing PostgreSQL statements
- Why exploitation is possible: User-controlled identifiers are interpolated into SQL without reliable escaping or structural validation
Why this happens
The underlying bug is improper neutralization of special elements in SQL commands. The PostgresTrigger node treats user-influenced identifier values as trusted SQL fragments rather than as constrained data, allowing input to alter the intended query structure.
This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'). Identifier handling requires particular care because standard value parameterization may not apply directly; safe designs must constrain permitted identifiers and construct statements through trusted mechanisms.
Potential impact
- An attacker may read data accessible to the configured PostgreSQL credential
- An attacker could modify or delete database records
- Sensitive application or workflow data may be exposed
- Database integrity and downstream automation could be disrupted
- The impact may extend to other systems if the database credential has excessive privileges
General mitigation guidance
Mitigation generally focuses on preventing user-controlled values from becoming executable SQL structure.
Common defensive patterns include:
- Using parameterized database APIs wherever values are involved
- Restricting identifier inputs to an explicit allowlist of expected names
- Constructing dynamic identifiers only through trusted, validated mappings
- Reducing the privileges of credentials used by workflow database connections
- Limiting which users can create, edit, or activate database-triggering workflows
- Separating workflow execution identities from administrative database accounts
- Applying defense-in-depth controls such as database monitoring and network access restrictions
How teams detect issues like this
Organizations can look for SQL injection risks through:
- Static analysis rules identifying string interpolation or concatenation in SQL construction
- Code review checks for user-controlled identifiers passed into database queries
- Tests using unexpected delimiters and SQL metacharacters in node parameters
- Runtime monitoring for unusual query patterns, schema access, or write activity
- Policy enforcement requiring parameterized queries or approved identifier-mapping helpers
- Automated security review tools that flag unsanitized database query construction

