Securing Swarms: Cross-Domain Adaptation for ROS2-based CPS Anomaly Detection

Julia Boone, Fatemeh Afghah

Abstract

Cyber-Physical Systems (CPS), particularly robotic swarms, face significant security challenges due to their multi-layered architecture and the high cost of data labeling. This paper introduces a novel framework that leverages adversarial domain adaptation and contrastive learning to transfer knowledge from labeled network traffic to unlabeled, multi-layer robotic environments. By aligning latent representations across domains, the proposed model achieves high detection accuracy on ROS2-based systems, effectively bridging the gap between traditional IT security and specialized robotic middleware.

Introduction

Modern autonomous drone swarms and ground vehicle fleets are complex Cyber-Physical Systems (CPS) that integrate network communication, operating systems (OS), and specialized middleware like the Robot Operating System 2 (ROS2). Traditional Intrusion Detection Systems (IDS) often fail in these environments for two primary reasons:

  1. Data Silos: Most IDS focus exclusively on network traffic, missing attacks that target internal ROS2 nodes or OS processes (e.g., node crashing).
  2. The Labeling Bottleneck: The diversity of robotic configurations makes manual labeling of datasets for every new system prohibitively expensive and slow.

This research addresses these issues by "adapting" models trained on well-documented network datasets to complex, unlabeled robotic environments, ensuring robust security without the need for extensive manual intervention.

Methodology

The proposed architecture utilizes a cross-domain anomaly detection approach designed to extract domain-invariant features from disparate sources.

Dual Feature Encoders and Sequence Generation

The system employs separate 1D-CNN encoders for source (network-only) and target (multi-layer CPS) data. The target encoder specifically uses residual blocks to better capture the nuances of unstructured robotic data. To capture the temporal dynamics of attacks, data flows are treated as multivariate time series rather than isolated points.

Adversarial Domain Adaptation

A core component is the domain discriminator equipped with a Gradient Reversal Layer (GRL). This setup forces the encoders to learn features that are indistinguishable between the standard network domain and the robot's internal layers, effectively identifying the "essence" of an attack regardless of the underlying infrastructure.

Contrastive Learning and Clustering

The model uses Triplet Loss to refine the latent space. In the source domain, labels guide the clustering of benign vs. attack samples. In the unlabeled target domain, temporal proximity serves as a proxy for labels, assuming that samples close in time share the same state. Additionally, a Dunn Index-based Center Loss penalizes the model if latent clusters are not tight and well-separated. Final detection is performed via K-means clustering on these learned representations.

Overview of the training and anomaly detection architecture

Experimental Evaluation

The framework was evaluated using two distinct datasets to test cross-domain performance:

  • WUSTL-2021 (Source): A labeled Industrial IoT dataset containing network-only traffic with common attacks like DoS, Reconnaissance, and Backdoors.
  • ROSPaCe (Target): A state-of-the-art multi-layer dataset for ROS2 systems, including synchronized data from network, OS, and ROS layers, featuring robotic-specific attacks like "Node Crashing" and "ROS2 Reconnaissance."

Results and Discussion

The proposed model demonstrated significant performance gains over traditional unsupervised methods. It achieved an accuracy of 98.98% on the source dataset and 87.87% on the unlabeled target dataset.

Performance comparison against baseline models

As shown in the results, baseline models like DSVDD and GMM suffered significant performance degradation when applied to the complex, mixed data of the ROSPaCe dataset, with accuracies often dropping below 21%. In contrast, the domain adaptation approach maintained high precision and recall, proving that multi-layer visibility is crucial for CPS security. The results highlight that attacks crashing a ROS2 node might look like normal traffic at the network level but are glaringly obvious when OS and middleware metrics are included.

Conclusion

This research proves that unlabeled robotic data can be effectively secured by transferring knowledge from standard network datasets. By aligning latent spaces, the model "inherits" the ability to distinguish abnormal behavior in complex environments. Future work will focus on moving from binary anomaly detection to multi-class attack classification and optimizing the model for real-time performance on resource-constrained edge devices like small drones.

Summary updated

Abstract

Cyber-physical systems (CPS) are being increasingly utilized for critical applications. CPS combines sensing and computing elements, often having multi-layer designs with networking, computational, and physical interfaces, which provide them with enhanced capabilities for a variety of application scenarios. However, the combination of physical and computational elements also makes CPS more vulnerable to attacks compared to network-only systems, and the resulting impacts of CPS attacks can be substantial. Intelligent intrusion detection systems (IDS) are an effective mechanism by which CPS can be secured, but the majority of current solutions often train and validate on network traffic-only datasets, ignoring the distinct attacks that may occur on other system layers. In order to address this, we develop an adaptable CPS anomaly detection model that can detect attacks within CPS without the need for previously labeled data. To achieve this, we utilize domain adaptation techniques that allow us to transfer known attack knowledge from a network traffic-only environment to a CPS environment. We validate our approach using a state-of-the-art CPS intrusion dataset that combines network, operating system (OS), and Robot Operating System (ROS) data. Through this dataset, we are able to demonstrate the effectiveness of our model across network traffic-only and CPS environments with distinct attack types and its ability to outperform other anomaly detection methods.
BibTeX
@misc{boone2025securing,
  author = {Julia Boone and Fatemeh Afghah},
  title = {{Securing Swarms: Cross-Domain Adaptation for ROS2-based CPS Anomaly Detection}},
  year = {2025},
  eprint = {2508.15865},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.15865},
}
Figure