Summary
A SQL injection vulnerability in the Time-Series Database (TSDB) component of OpenC3 COSMOS allows unsanitized user input to be embedded directly into SQL queries.
Under certain conditions, an attacker can manipulate TSDB lookups to execute arbitrary SQL commands, potentially altering or deleting time-series telemetry data.
Affected context
This vulnerability appears in OpenC3 COSMOS deployments using the Time-Series Database (TSDB) where the tsdb_lookup functionality is exposed through user-facing interfaces, APIs, or tools that pass user-supplied parameters to the backend.
It is relevant in environments where:
- TSDB queries are driven by request parameters or UI input,
- The underlying database user has permissions beyond strict read-only,
- COSMOS is reachable by multiple operators or integrated systems whose inputs cannot be fully trusted.
In such setups, unvalidated lookup parameters can flow into SQL statements constructed in cvt_model.rb.
Exploit preconditions
- Attack surface: Interfaces (web UI, API endpoints, automation hooks, or integrations) that invoke
tsdb_lookupwith user-controlled or externally influenced parameters. - Required access: Ability to send crafted requests that control the TSDB lookup parameter (e.g., authenticated operator account, compromised integration, or in some deployments possibly an unauthenticated caller if exposed).
- Trigger point: Execution of the vulnerable
tsdb_lookupcode path, where the user-controlled value is concatenated or interpolated into an SQL query string. - Why exploitation is possible: The function directly embeds user input into SQL without proper parameterization, escaping, or validation, allowing the attacker to break out of the intended query and append arbitrary SQL clauses.
Why this happens
The core issue is the construction of SQL queries using string concatenation or interpolation with untrusted input in cvt_model.rb's tsdb_lookup.
This pattern maps directly to CWE-89: SQL Injection, where user-controlled data becomes part of the SQL command structure instead of being treated strictly as data.
Because the database driver is not instructed to bind parameters separately, the database parses attacker-supplied fragments as executable SQL, enabling arbitrary modification or retrieval of records beyond the intended query semantics.
Potential impact
- Modification or deletion of time-series telemetry data and historical records.
- Unauthorized reading of additional tables or sensitive operational data stored in the same database.
- Corruption of datasets used for monitoring, analysis, or mission decision-making.
- Potential privilege escalation within the application if access-control logic depends on database-stored metadata.
- Disruption of operations that rely on accurate TSDB data, including debugging, anomaly detection, or audit trails.
General mitigation guidance
Effective mitigation focuses on removing the ability for user input to influence SQL syntax and reducing the blast radius of any remaining database access:
- Refactor TSDB queries to use parameterized statements or prepared queries provided by the database library or ORM, never constructing SQL via string concatenation.
- Introduce strict input validation and normalization on all TSDB lookup parameters, for example enforcing whitelists for identifiers, ranges, and allowed operators.
- Encapsulate query construction in a dedicated data-access layer that exposes high-level query methods instead of accepting raw SQL fragments or arbitrary user expressions.
- Apply least-privilege to the database account used by COSMOS TSDB so it has only the minimal required permissions (e.g., read-only where feasible, no schema-altering privileges).
- Consider separating critical telemetry data into isolated schemas or databases to limit cross-table impact if a query is abused.
How teams detect issues like this
Organizations can detect and monitor for vulnerabilities and abuse related to this pattern with several approaches:
- Static analysis: Configure rules to flag any SQL query construction involving string interpolation, concatenation, or direct insertion of request parameters in Ruby models and data-access code.
- Code review cues: During reviews, scrutinize any methods that assemble SQL strings, particularly around search, filtering, or lookup functions like
tsdb_lookup, ensuring they rely on binding parameters and whitelisted inputs. - Dynamic and runtime monitoring: Enable database logging (e.g., slow query and general query logs) and watch for anomalous patterns such as unexpected
OR 1=1, stacked statements, or destructive operations originating from TSDB-related endpoints. - Security testing: Incorporate automated DAST or integration tests that probe TSDB-related endpoints with typical injection patterns to ensure that queries are parameterized and that inputs are treated purely as data.

