/

CVE-2026-42087

Severity:

CRITICAL RISK

(9.6)

SQL Injection in OpenC3 COSMOS Time-Series Database (TSDB)

CVE-2026-42087

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Command Execution and Data Integrity Compromise

Severity:

CRITICAL RISK

(9.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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_lookup with 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_lookup code 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.

Sources

SourceLink
github.comgithub.com/OpenC3/cosmos/commit/9ba60c09c8836a37a2e4ea67ab35fe403e041415
github.comgithub.com/OpenC3/cosmos/releases/tag/v7.0.0-rc3
github.comgithub.com/OpenC3/cosmos/security/advisories/GHSA-v529-vhwc-wfc5

Frequently asked

questions

It can be, depending on how COSMOS is deployed. If TSDB lookup functionality is reachable over a network interface where an attacker can control query parameters, remote exploitation is feasible.

In many deployments, yes—attackers often need at least the same level of access as a user who can trigger TSDB lookups. However, if an instance exposes those endpoints without proper authentication or is integrated with untrusted systems, exploitation could occur without traditional user credentials.

The most robust fix is to replace all string-built SQL in TSDB-related code with parameterized queries or ORM query builders, combined with strict input validation and least-privilege database credentials.

Establish development standards that prohibit ad-hoc SQL string construction with user input, enforce use of parameter binding, add static analysis rules to block unsafe patterns in CI, and ensure regular security-focused code reviews of data-access layers.

Find out what's already
exploitable in your codebase.