Eval injection enables local code execution in Open Source Robotics Foundation Robot Operating System 2 (ROS 2)

Note: This data is for reference and cybersecurity research purposes only.CyStack advises users not to use this information for unlawful purposes.

What is CVE-2024-42002?

CVE-2024-42002 is a vulnerability classified as Improper Neutralization of Directives in Dynamically Evaluated Code and Improper Control of Generation of Code, affecting Robot Operating System 2 (ROS 2) (affected versions: Rolling Ridley, Lyrical Luth, and other affected versions). This vulnerability is rated High, with a CVSS score of 8.6. Current sources do not report this vulnerability as exploited.

Overview

Original source data

A code injection vulnerability has been discovered in the Robot Operating System 2 (ROS 2) 'ros2topic' command-line tool, affecting all ROS 2 distributions from Crystal Clemmys up to and including Lyrical Luth and Rolling Ridley. The vulnerability lies in the 'hz' verb, which reports the publishing rate of a topic and accepts a user-provided Python expression via the --filter option. This input is passed directly to the eval() function without sanitization, allowing a local user to craft and execute arbitrary code.

Affected products and scope

  • The default_status is recorded as unaffected, but the following distributions are explicitly marked affected:
  • Rolling Ridley
  • Lyrical Luth
  • Kilted Kaiju
  • Jazzy Jalisco
  • Iron Irwini
  • Humble Hawksbill
  • Galactic Geochelone
  • Foxy Fitzroy
  • Eloquent Elusor
  • Dashing Diademata
  • Crystal Clemmys
  • The affected component is the ros2topic package and command-line tool, especially the hz verb.
  • The record provides no specific fixed release. Do not infer that distributions outside this list are safe merely because they are not listed.

Technical details

Open Source Robotics Foundation Robot Operating System 2 (ROS 2) contains the flaw in the ros2topic command-line tool, specifically its hz verb. The verb accepts a user-provided Python expression through --filter and passes that expression directly to eval() without adequate neutralization or safety checks. An attacker must be able to run the tool locally on a system containing an affected component and control the filter expression; the supplied record characterizes the condition as local, requiring no privileges and no user interaction. The result is arbitrary code execution in the context of the ros2topic process, although the record does not fully establish the expression namespace, the process's effective permissions, or implementation differences across all distributions.

Exploitability

  • Reachability: Exploitation is local and requires running ros2 topic hz with a --filter value containing an attacker-controlled expression.
  • Authentication and interaction: The record states that privileges and user interaction are not required, but the attacker still needs the ability to execute the tool on the local system.
  • Complexity: The exploitation condition is low complexity because the input is passed directly to eval().
  • Status: The supplied record does not identify a public exploit or establish exploitation in the wild. Available enrichment records exploitation as none and automatable as no; those states do not prove that exploitation is impossible.

Technical impact

The flaw allows arbitrary Python code to run inside the local process executing ros2topic. If that process can read sensitive data, write files, start other processes, or access ROS 2 resources, those permissions could be used to affect confidentiality, integrity, or availability. The practical consequences depend on the account running the tool, the host configuration, and the host's network or ROS graph access. The record does not confirm a change to another system or security authority, nor does it confirm a remote exploitation path.

Business impact

Successful exploitation could expose, alter, or destroy data accessible to the account and process running ros2topic. On robotics development, operations, or monitoring hosts, this could lead to tool changes, disruption of topic analysis, or interference with related ROS 2 resources, depending on the account's permissions and the host's connectivity. The flaw does not by itself establish compromise of a remote ROS 2 system because the stated precondition is local execution. The record does not name a campaign, victim, or specific data breach.

Remediation

  1. Do not pass untrusted or unreviewed input to --filter for ros2 topic hz. If filtering is not required, omit the option.
  2. Until a released fix is confirmed, restrict the affected verb to trusted operators and pre-reviewed filter expressions.
  3. Track upstream ros2/ros2cli pull request #1001. It is a proposed fix, not evidence of a fixed release; the record and inspected upstream page do not confirm a specific release that resolves the issue.
  4. When upstream publishes a fix, match the exact distribution and ros2topic package on each system to the release boundary that is documented. Do not apply a fix from one branch to parallel branches without supporting evidence.
  5. After updating, test the hz behavior with valid filter expressions and verify that the running package comes from the fixed release.

Detection

  1. Inventory hosts and environments that contain ROS 2, identifying the distribution and the installed ros2topic package.
  2. For source or otherwise inspectable installations, verify the presence of ros2topic/ros2topic/verb/hz.py and the handling of the hz verb and --filter option.
  3. Review shell history, process accounting, or audit logs where available for ros2 topic hz invocations using --filter. This is a precautionary review, not a source-confirmed IOC.
  4. After suspicious use, review host telemetry for unexpected child processes, file changes, or resource access inconsistent with the ROS 2 task. This is supplementary because the record provides no specific indicator.
  5. Do not treat the absence of suspicious logs or behavior as proof of safety; combine telemetry review with package and distribution inventory and controls on --filter usage.
Sources (23)
Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.