Summary
Dagster's DuckDB, Snowflake, BigQuery, and DeltaLake I/O managers previously built SQL WHERE clauses by directly interpolating dynamic partition key values into queries without proper escaping or parameterization.
A user with permission to add dynamic partitions could craft a malicious partition key that injects arbitrary SQL, which would execute on the backing database using the I/O manager's credentials. Deployments that do not use dynamic partitions, or that rely only on static or time-window partitions, are not exposed to this risk.
Affected context
This vulnerability occurs in Dagster deployments that:
- Use dynamic partitions with the DuckDB, Snowflake, BigQuery, or DeltaLake I/O managers, and
- Allow users with the "Add Dynamic Partitions" permission to define new partition keys that propagate into query construction.
In this context, partition key values are included in SQL WHERE clauses as raw string fragments rather than as bound parameters. When these values originate from users or semi-trusted automation, the lack of defensive query construction creates space for SQL injection. Static or time-window partitions, which do not rely on user-supplied string keys in the same way, are not affected by this particular flaw.
Exploit preconditions
- Attack surface: SQL interfaces exposed via Dagster's I/O managers for DuckDB, Snowflake, BigQuery, and DeltaLake.
- Required access: Ability to add or manage dynamic partitions in Dagster (e.g., through the UI, APIs, or automation that uses Dagster's partitioning APIs).
- Trigger point: Execution of pipelines or jobs that:
- Use dynamic partitions, and
- Cause the vulnerable I/O managers to construct and execute SQL queries incorporating the malicious partition key into a WHERE clause.
- Why exploitation is possible: The I/O managers concatenate partition key values directly into SQL strings instead of using parameterized queries or properly escaped identifiers. This pattern allows attacker-controlled data to alter the structure of the SQL statement, enabling arbitrary SQL to be executed by the target database under the I/O manager's configured credentials.
Why this happens
The underlying bug is a classic SQL injection pattern as described by CWE-89: Improper Neutralization of Special Elements used in an SQL Command. The affected Dagster I/O managers dynamically build SQL WHERE clauses by string interpolation of partition key values. Rather than treating partition keys strictly as data (using bound parameters, typed values, or constrained identifiers), they are incorporated directly into the query text.
Because dynamic partition keys can be created by users with the appropriate Dagster permission, this path effectively trusts user-controlled input as if it were safe SQL. Special characters, quotes, or delimiter sequences in the partition key are not neutralized or rejected, so they can break out of the intended comparison expression and inject additional SQL statements or clauses. The problem is not specific to a particular database engine; it arises from the shared practice of constructing SQL statements by concatenating strings that contain unvalidated external input.
Potential impact
- Execution of arbitrary SQL statements against DuckDB, Snowflake, BigQuery, or DeltaLake using the I/O manager's database credentials.
- Unauthorized reading of sensitive tables or views that the I/O manager account can access, including cross-tenant or cross-project data within the same account scope.
- Unauthorized modification of data, including inserting, updating, or deleting records in target tables.
- Tampering with analytics or data pipelines by altering intermediate datasets, which can corrupt downstream reports or ML models.
- Creation or modification of database objects (tables, views, procedures) where the I/O manager account has sufficient privileges.
- Potential escalation of privileges inside the database environment if the account is over-privileged or can modify security-relevant metadata.
General mitigation guidance
Mitigation centers on treating partition keys strictly as data and never as raw query text:
- Use parameterized queries: Construct SQL statements with placeholders and bind partition key values as parameters supported by the database driver or ORM, rather than interpolating them into string templates.
- Constrain partition key formats: Introduce strict validation and normalization logic for dynamic partition keys (e.g., limiting to a restricted character set, maximum length, and expected patterns) before they influence query construction.
- Separate identifiers from data: When partition keys feed into identifiers (like table or partition names), use whitelisting or a mapping layer instead of direct substitution, ensuring only known-safe, pre-declared identifiers are used.
- Limit database privileges: Configure I/O manager credentials according to least privilege, granting only the minimal read/write permissions necessary for the pipeline so that injected SQL, if it occurs, has constrained impact.
- Harden partition management workflows: Restrict the "Add Dynamic Partitions" capability to trusted roles, and incorporate review or approval steps for partition creation in sensitive environments.
- Adopt secure-by-default helpers: Encapsulate query construction in shared library functions that enforce parameterization and input validation so that unsafe string concatenation is discouraged in new code.
How teams detect issues like this
Detection benefits from a combination of code-centric and runtime approaches:
- Static code analysis: Configure linters or security-focused static analysis tools to flag string-based SQL construction patterns, especially where variables like "partition", "key", or "where_clause" are concatenated into query strings used by database clients.
- Targeted code review: During review of I/O manager implementations or custom partition logic, look for:
- SQL composed with f-strings, string concatenation, or
.format()calls. - Any use of user-supplied or partition-related values directly inside SQL text.
- Lack of input validation or absence of database parameter binding APIs.
- Policy enforcement in CI/CD: Define repository policies that disallow non-parameterized SQL in critical data access layers, and enforce them via automated checks on pull requests.
- Database-level monitoring: Enable query logging and anomaly detection within DuckDB, Snowflake, BigQuery, and DeltaLake environments to identify unusual patterns, such as:
- Multi-statement queries from Dagster service accounts.
- Unexpected DDL or privileged operations from accounts typically used for ETL.
- Runtime security scanning: Use database or data-platform security tools to periodically scan for dangerous permissions assigned to ETL or orchestration service accounts, limiting the blast radius of any injected query.

