/

CVE-2025-68271

Severity:

CRITICAL RISK

(10.0)

Eval Injection / Code Injection in OpenC3 COSMOS JSON-RPC

CVE-2025-68271

Awaiting Analysis

Vulnerability type

Category:

Eval Injection / Code Injection

CWE:

CWE-95

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(10.0)

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

OpenC3 COSMOS versions 5.0.0 through 6.10.1 contain a critical remote code execution vulnerability in the JSON-RPC API, where attacker-controlled strings are evaluated as Ruby code.

Because command strings are parsed via String#convert_to_value (which calls eval for array-like inputs) before authorization is enforced, an unauthenticated attacker can achieve arbitrary Ruby code execution even if the request is ultimately rejected with a 401.

Affected context

The issue occurs in OpenC3 COSMOS deployments that expose the JSON-RPC API and accept command-related requests using string forms of certain APIs.

When these APIs receive attacker-controlled parameters that look like array-like values, the framework uses String#convert_to_value, which in turn invokes eval to turn the string into a Ruby object.

Crucially, this parsing happens on the cmd code path before authorize() is called, so the unsafe evaluation can be reached even in environments that rely on authorization failures to prevent misuse.

Exploit preconditions

  • Attack surface: Network-accessible JSON-RPC endpoint of an OpenC3 COSMOS instance.
  • Required access: Ability to send JSON-RPC requests to the service; no valid credentials are required if the endpoint is reachable.
  • Trigger point: Issuing a JSON-RPC call that uses the string form of affected APIs and supplies specially crafted, array-like parameter text that will be passed into String#convert_to_value.
  • Why exploitation is possible: The convert_to_value helper uses eval() on untrusted, attacker-controlled strings for certain input shapes, and this evaluation occurs before authorization checks, allowing arbitrary Ruby expression execution regardless of a subsequent 401 response.

Why this happens

The vulnerability stems from using the Ruby eval function on untrusted input as part of parameter parsing in the JSON-RPC layer.

The helper String#convert_to_value interprets string inputs as Ruby literals and, for array-like values, evaluates them dynamically using eval() to create corresponding Ruby objects.

This behavior matches CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, where user input is embedded directly into code evaluated at runtime.

Because this evaluation occurs prior to the authorize() check in the cmd request flow, the design assumes that authorization will protect sensitive operations but actually performs dangerous evaluation before access control is applied, breaking the intended security boundary.

Potential impact

  • Remote execution of arbitrary Ruby code within the COSMOS server process.
  • Full compromise of the COSMOS application, including reading or modifying telemetry and command data.
  • Lateral movement within the hosting environment, depending on server privileges and network access.
  • Manipulation of commands sent to connected embedded systems, potentially affecting mission-critical behavior.
  • Exfiltration or corruption of configuration, logs, and mission data stored by COSMOS.

General mitigation guidance

Effective mitigation focuses on eliminating dynamic evaluation of untrusted input and restructuring request processing order:

  • Replace uses of eval in parameter parsing with safer alternatives such as explicit parsing of JSON, arrays, and hashes using strict, data-only decoders.
  • Treat all JSON-RPC parameters as plain data; avoid interpreting strings as executable code or Ruby literals.
  • Ensure authorization and authentication checks occur before any complex parsing or transformation that could execute logic derived from user input.
  • Constrain what parameter types and shapes are allowed per API method using explicit schemas or strong typing, rejecting requests that do not conform.
  • Run COSMOS with least-privilege OS accounts and minimal file-system and network permissions to reduce blast radius in case of similar bugs.
  • Segment network access so that JSON-RPC endpoints are not exposed broadly and are reachable only from trusted operator networks or VPNs.

How teams detect issues like this

Organizations can detect similar vulnerabilities and potential exploitation with a combination of code-centric and operational approaches:

  • Static analysis and code search:
  • Flag any use of eval, instance_eval, class_eval, or similar dynamic evaluation APIs, especially in request parsing or JSON-RPC handling.
  • Look for helper methods (such as convert_to_value) that transform strings into Ruby objects using dynamic evaluation or Kernel#send.
  • Enforce policies in code review that prohibit dynamic evaluation of request parameters and require clear justification for any remaining uses.
  • Code review practices:
  • Review request-processing pipelines to ensure authorization and authentication occur before business logic, parsing, or transformation that could invoke risky behavior.
  • Examine JSON-RPC endpoints for generic dispatch mechanisms that map user-controlled method names or parameters directly to Ruby method calls.
  • Runtime and log monitoring:
  • Monitor application logs and RPC traces for unusual or malformed array-like parameter strings, or repeated JSON-RPC calls that fail authorization but cause internal errors.
  • Use host-based monitoring to detect anomalous child process creation, file access, or outbound connections from the COSMOS server process.
  • Automated tooling:
  • Integrate SAST tools that understand Ruby patterns for code injection and flag uses of dynamic evaluation on user-controlled data.
  • Add CI checks that fail builds when new instances of dynamic evaluation APIs are introduced without explicit approval.

Sources

SourceLink
github.comgithub.com/OpenC3/cosmos/security/advisories/GHSA-w757-4qv9-mghp

Frequently asked

questions

The vulnerability is broadly exploitable wherever the JSON-RPC endpoint is reachable over the network. Because the unsafe evaluation happens before authorization, an attacker does not need valid credentials, only network access to the COSMOS instance.

No. The flaw is in the pre-authorization handling of JSON-RPC requests. An unauthenticated attacker can send specially crafted requests to trigger eval on their supplied parameter strings.

The most robust fix pattern is to eliminate all uses of eval (and similar dynamic code execution primitives) on user-supplied data, replace them with strict data parsing, and restructure request handlers so that authentication and authorization checks run before any processing that could execute logic derived from the request.

Teams can adopt secure coding guidelines that ban dynamic evaluation of request parameters, enforce this via automated checks in CI, and require design reviews for any component that interprets user input as more than simple data. Combining these process controls with code review checklists, static analysis rules focused on dynamic execution APIs, and regular threat modeling of API boundaries helps catch eval and code injection risks early in development.

Find out what's already
exploitable in your codebase.