Summary
Datadog Vector v0.54.0 contains a SQL injection vulnerability in how the set_uri_query parameter is handled within the KeyPartitioner::partition function.
By crafting malicious SQL fragments in this parameter, an attacker may gain unauthorized access to sensitive database information when Vector constructs and executes queries.
Affected context
The vulnerability appears in deployments of Datadog Vector v0.54.0 where the KeyPartitioner::partition function is used to build or route SQL queries based on incoming parameters.
Environments that pass user-controlled or externally sourced values into set_uri_query without robust validation or parameterization are more exposed, particularly when Vector is configured to interact directly with relational databases.
Exploit preconditions
- Attack surface: Interfaces or data pipelines feeding
set_uri_queryinto Vector'sKeyPartitioner::partitionfunction. - Required access: Ability to influence or control the
set_uri_queryvalue (e.g., via upstream services, configuration, or API parameters). - Trigger point: Execution of SQL statements composed using the
set_uri_queryparameter, typically when Vector processes events or routes data involving database operations. - Why exploitation is possible: The
set_uri_queryvalue is incorporated into SQL statements without proper parameterization or escaping, enabling crafted input to alter query structure and behavior.
Why this happens
This issue arises from constructing SQL queries by concatenating or interpolating raw input from set_uri_query into the query string.
Instead of using prepared statements or query parameterization, the implementation appears to treat the parameter as trusted, allowing attacker-controlled data to become part of the executable SQL.
This pattern maps directly to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where untrusted input is mishandled in database queries.
Potential impact
- Access to sensitive database records that the application or service account can read.
- Extraction of authentication data, configuration details, or telemetry stored in the database.
- Modification or deletion of database data if the execution context has write permissions.
- Potential lateral movement through database-linked systems, depending on stored procedures or additional logic.
- Denial of service by injecting queries that lock tables, exhaust resources, or cause errors.
General mitigation guidance
Effective mitigation focuses on minimizing trust in query inputs and enforcing safe query construction patterns:
- Employ parameterized queries or prepared statements for all database interactions, ensuring that data values are never concatenated into SQL logic.
- Introduce strict validation and normalization of URI query parameters, including whitelisting of allowed keys and values.
- Apply clear separation between query structure and data, avoiding dynamic construction of SQL based on externally sourced parameters whenever possible.
- Constrain database privileges so that the account used by Vector has only the minimal permissions required (e.g., read-only for logging or metrics pipelines).
- Centralize query-building utilities or abstractions to enforce consistent, safe patterns across all database-related code paths.
How teams detect issues like this
Detection can leverage a mix of code-level analysis and runtime monitoring:
- Use static analysis or linters configured with rules to flag direct string concatenation or interpolation involving SQL statements and external inputs such as
set_uri_query. - During code review, look for any query-building logic in or around
KeyPartitioner::partitionthat does not rely on prepared statements or parameter binding. - Implement database query logging and monitoring to identify anomalous or unexpectedly complex queries, particularly those reflecting user-supplied parameters or URI query strings.
- Enforce security coding guidelines that require defensive patterns for query construction, with automated checks in CI pipelines to prevent regressions.

