tradr-project / tf_remapper_cpp

More efficient version of tf/tf_remap able to handle TFs at kHz with tens of subscribers.
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Potential vulnerability: topic names from ROS parameters #1

Open tandf opened 1 year ago

tandf commented 1 year ago

Hi,

We notice that you are using topic names from ROS parameter at the following locations: https://github.com/tradr-project/tf_remapper_cpp/blob/59eca1c1592ed38f6f042cd258d5f5fc5a6e683f/src/tf_remapper_node.cpp#L54 https://github.com/tradr-project/tf_remapper_cpp/blob/59eca1c1592ed38f6f042cd258d5f5fc5a6e683f/src/tf_remapper_node.cpp#L56 https://github.com/tradr-project/tf_remapper_cpp/blob/59eca1c1592ed38f6f042cd258d5f5fc5a6e683f/src/tf_remapper_node.cpp#L60 https://github.com/tradr-project/tf_remapper_cpp/blob/59eca1c1592ed38f6f042cd258d5f5fc5a6e683f/src/tf_remapper_node.cpp#L62 For security reasons detailed below, we strongly suggest avoiding the usage of strings from parameters as topic names.

Although parameters are usually set in parameter files, they can also be changed by nodes. Specifically, other nodes in the same ROS application can also change the parameters listed above before it’s used, either by accident or intentionally (i.e., by potential attackers). Such changes can lead to disruption of the remapper functionality, as the input or the output tf topic is changed. Moreover, if an attacker exists, she can even change the tf message content by first fool the remapper to publish to a wrong topic like /tf_fake, and then forwarding messages from /tf_fake to /tf after modifying the message contents. Downstream functionalities like navigation will be affected, and severe consequences such as crashes may happen. Because ROS is an OSS (open-source software) community, third-party nodes are widely used in ROS applications, usually without complete vetting of their behavior, which gives the opportunity to potentially malicious actors to inject malicious code (e.g, by submitting hypocrite commits like in other OSS systems [1]) to infiltrate the ROS applications that use it (or software supply chain attacks, one of the primary means for real-world attackers today [2]).

We understand that using parameters to set topic names brings flexibility. Still, for the purpose of security, we strongly suggest that you avoid such vulnerable programming patterns if possible. For example, to avoid the exposure of this specific vulnerability, you may consider alternatives like remapping, which is designed for configuring names when launching the nodes.

[1] Q. Wu and K. Lu, “On the feasibility of stealthily introducing vulnerabilities in open-source software via hypocrite commits,” 2021, https://linuxreviews.org/images/d/d9/OpenSourceInsecurity.pdf. [2] Supply chain attacks are the hacker’s new favourite weapon. and the threat is getting bigger. https://www.zdnet.com/article/supply-chain-attacks-are-the-hackers-new-favourite-weapon-and-the-threat-is-getting-bigger/.

peci1 commented 1 year ago

Thank you for the report. I understand the merit of the vulnerability, though I'm not convinced ROS1 nodes can change parameters during runtime in such a way that they affect the already running remapper. In my view, this can only happen during launch time, so the problem is not as big as you picture it.

If a system should be used in industrial conditions, I assume it is the responsibility of the programmer to make sure that only known and required parameters are set and unexpected parameters are not. And that is easy to check during launch time.

It would be probably possible to change this node to use the topic remapping functionality, but that would break API for existing code. Although this is not a core ROS package, I follow the same guarantees regarding API stability - i.e. not breaking API in a released ROS version. So it's technically impossible to resolve this issue in the currently released versions. When we'll be doing a ROS 2 port of this package (if it's needed at all in ROS 2), we'll consider this security issue and try to write the code in such a way that it doesn't rely on parameters.