Summary
A SQL injection vulnerability in Snowflake CLI allows unsanitized user-controlled values to be inserted into multi-statement SQL queries.
If a malicious project configuration or command-line value reaches a CLI-driven workflow, an attacker may execute SQL using the victim's active Snowflake session and role.
Affected context
The vulnerability occurs in Snowflake CLI workflows that construct multi-statement SQL commands from user-controlled project configuration or command-line values. Risk is greater when CI/CD pipelines execute the CLI with elevated service-account roles or when automation accepts untrusted input without isolating or validating it.
Exploit preconditions
- Attack surface: Snowflake CLI command execution and CLI-wrapping automation
- Required access: Ability to modify or submit a project configuration, create a pull request processed by CI/CD, or provide input to an automation wrapper
- Trigger point: Construction and execution of a multi-statement SQL query
- Why exploitation is possible: Untrusted values are interpolated into SQL strings without sufficient validation or parameterization
- Privilege boundary: The resulting actions are limited by the privileges of the active Snowflake session and role
Why this happens
The underlying issue is improper input validation combined with unsafe SQL string construction. User-controlled values are incorporated directly into executable SQL rather than being treated strictly as data, allowing input to alter query structure or introduce additional statements. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Potential impact
- Unauthorized SQL statements may be executed
- Accessible data could be read, modified, or deleted
- Database objects or permissions may be changed
- CI/CD workflows could perform unintended actions under an elevated role
- Sensitive information may be exposed within the privileges of the active Snowflake session
General mitigation guidance
Mitigation generally focuses on preventing untrusted values from becoming executable SQL.
Common defensive patterns include:
- Use parameterized queries or structured query APIs instead of string interpolation
- Apply strict allowlists for identifiers, options, and other values that cannot be parameterized
- Validate inputs according to their expected type, length, format, and context
- Separate data values from SQL syntax and reject unexpected multi-statement input
- Avoid running repository-controlled configuration with highly privileged Snowflake roles
- Use narrowly scoped service accounts and separate roles for CI/CD tasks
- Treat pull requests, project files, and wrapper inputs as untrusted by default
- Keep security fixes applied through the organization's standard dependency-management process
How teams detect issues like this
Detection approaches may include:
- Static analysis for string interpolation, concatenation, or formatting used to build SQL commands
- Code review checks for multi-statement execution involving configuration or command-line values
- Tests that provide special characters, statement separators, and unexpected input types
- CI policy enforcement requiring parameterized query APIs and disallowing raw SQL construction from untrusted data
- Runtime monitoring for anomalous statements, object changes, or privilege use by CLI service accounts
- Automated code-review tools that flag common SQL injection patterns

