Summary
A command-injection-related file access flaw in the n8n Snowflake node allows authenticated users with usable Snowflake credentials to pass free-form query content, including client-side commands, directly to the Snowflake SDK. Under those conditions, an attacker may upload a local file from the n8n host or overwrite an existing file with a staged file.
Affected context
The vulnerability occurs in n8n workflows that use the Snowflake node to execute free-form queries through the Snowflake SDK. It becomes risky when an authenticated n8n user can invoke the node, has usable Snowflake credentials, and the SDK interprets client-side commands that can access the n8n host filesystem without n8n's normal file-access restrictions.
Exploit preconditions
- Attack surface: The n8n Snowflake node and its free-form Execute Query input
- Required access: An authenticated n8n user with permission to use the relevant workflow or node and usable Snowflake credentials
- Trigger point: Execution of Snowflake query content containing supported client-side file operations
- Why exploitation is possible: The node passes unrestricted query input directly to the Snowflake SDK, allowing SDK-level file behavior to bypass application-layer file-access controls
Why this happens
The underlying issue is insufficient restriction of user-controlled command-like input before it reaches a downstream SDK. The Snowflake node accepts free-form Execute Query content and forwards it without filtering or separating server-side SQL from client-side commands that can access local files. This behavior is consistent with CWE-78: Improper Neutralization of Special Elements used in an OS Command, because untrusted input can influence command or command-like execution semantics in a privileged application context.
Potential impact
- An attacker could read files accessible to the n8n process
- An attacker could upload local files from the n8n host
- An attacker could overwrite existing files with staged content
- Workflows, credentials, configuration, or application data could be exposed or altered
- File tampering could contribute to broader compromise depending on process privileges and deployment controls
General mitigation guidance
Mitigation generally focuses on reducing trust in free-form query input and preventing client-side command semantics from reaching the SDK.
Common defensive patterns include:
- Prefer structured query APIs or parameterized operations over unrestricted query text
- Separate server-side SQL execution from client-side command handling
- Disable or reject client-side file commands when they are not required
- Enforce explicit command and path allowlists at the application boundary
- Apply strict filesystem permissions and run n8n with a dedicated least-privilege identity
- Use isolated workspaces or sandboxes for any required file-transfer operations
- Limit Snowflake credential permissions and avoid sharing credentials across unrelated workflows
- Treat workflow authors and query inputs as untrusted unless their access is explicitly governed
How teams detect issues like this
Detection can combine static analysis, code review, and runtime policy controls:
- Search for nodes that forward free-form query text directly into database or SDK execution APIs
- Review whether client-side commands and file-transfer directives are parsed, filtered, or allowlisted
- Flag file operations whose paths originate from workflow inputs or user-controlled fields
- Monitor n8n executions and Snowflake client logs for unexpected file upload, download, or overwrite activity
- Enforce policies requiring structured database operations and rejecting unrestricted command-capable inputs
- Use automated code review or security scanning tools to identify dangerous data flows into command and SDK interfaces

