TRACE: Topology-Aware Contrastive Learning for Label-Efficient Intrusion Detection

TRACE proposes a topology-aware graph contrastive learning framework for label-efficient intrusion detection using only benign graphs.
TRACE is a topology-aware graph contrastive learning framework for label-efficient intrusion detection. It learns representations from benign system activity graphs only, capturing local interactions via message passing and graph-level structural deviations via topological representations, and computes anomaly scores directly in the projected embedding space. Experiments on StreamSpot, GraSec-IoT, and Unicorn Wget show TRACE significantly outperforms the benign-only GraphCL baseline in F1 on StreamSpot and Unicorn Wget, but underperforms on GraSec-IoT. Supervised models still lead on some datasets. The results indicate conditional advantages of topology-aware benign learning for label-scarce scenarios, though it is not superior to supervised or baseline methods in all graph settings.
In the field of intrusion detection, attack methods keep evolving, while confirmed attack labels are often scarce or incomplete. Traditional supervised learning relies on large amounts of labeled data and struggles to cope with this challenge. TRACE proposes a topology-aware graph contrastive learning framework specifically designed for label-efficient intrusion detection scenarios. It performs representation learning using only benign system activity graphs, combining message passing with topological representations to capture both local interactions and graph-level structural deviations, thereby learning discriminative embeddings without any attack labels.

Core Method: Topology-Aware Contrastive Learning
The core innovation of TRACE lies in combining topological representations with contrastive learning and computing anomaly scores directly in the projected embedding space. Specifically, the model first learns from benign system activity graphs, using a message passing mechanism to capture local interactions between nodes while capturing the overall structural characteristics of the graph through topological representations. These two types of information are fused in the embedding space optimized by the contrastive objective, so that normal and abnormal patterns naturally separate in that space.
Unlike common graph contrastive learning baselines that use only benign data (such as GraphCL), TRACE emphasizes the role of topological structure. It does not rely on any attack labels for representation learning; instead, it uses only a labeled validation set containing both benign and malicious graphs to calibrate the anomaly threshold. This design greatly reduces dependence on labeled data while retaining the potential to detect unknown attacks.
Graph Contrastive Learning is a class of self-supervised representation learning methods. Its core idea is to construct positive and negative sample pairs, pulling the representations of similar graphs (or nodes) closer and pushing those of dissimilar samples apart in the embedding space, thereby learning discriminative features without labels. Common graph contrastive learning baselines such as GraphCL typically use graph augmentation (e.g., node dropping, edge perturbation) to generate different views of the same graph as positive samples, with other graphs as negative samples. The key difference between TRACE and these baselines is that it does not rely on random augmentation but explicitly introduces topological representations (such as persistent homology, graph kernels, or structural descriptors) to characterize graph-level structural deviations, and fuses topological information with local interaction features obtained via message passing in the contrastive objective. This design enables the model to perceive both subtle changes in node neighborhoods and anomalous shifts in the overall graph structure, so that it can still distinguish normal from abnormal patterns when trained on benign data only.
Experimental Evaluation: Performance on Multiple Datasets
The researchers evaluated TRACE on three public datasets: StreamSpot, GraSec-IoT, and Unicorn Wget. Comparisons included a supervised graph neural network and a GraphCL baseline using only benign data. Experimental results show that TRACE achieved an F1 score of 0.923 on StreamSpot, 0.790 on GraSec-IoT, and 0.583 on Unicorn Wget.
Compared with GraphCL, TRACE shows significant improvements on StreamSpot (0.450) and Unicorn Wget (0.203), but is actually lower on GraSec-IoT (0.975). The supervised model leads on StreamSpot and GraSec-IoT, while TRACE achieves the highest F1 on Unicorn Wget. These mixed results indicate that topology-aware benign learning can improve detection performance in certain graph settings, but does not hold an advantage in all scenarios.
F1 score is the harmonic mean of precision and recall, calculated as F1 = 2 × (Precision × Recall) / (Precision + Recall). In anomaly detection tasks such as intrusion detection, since normal samples far outnumber attack samples, the class distribution is highly imbalanced, and using accuracy alone can easily overestimate model performance—a model can achieve very high accuracy simply by predicting all samples as normal. The F1 score considers both the ability to find attack samples (recall) and the ability to correctly identify them (precision), making it more suitable for evaluating detection performance in label-efficient scenarios. In this article, TRACE achieving an F1 of 0.923 on StreamSpot means it strikes a good balance between precision and recall; the significant fluctuations in F1 across datasets (e.g., 0.790 on GraSec-IoT versus GraphCL's 0.975) also suggest that F1 is sensitive to the dataset's attack patterns and graph structural characteristics, and needs to be interpreted in context.
Interpreting the Results: Strengths and Limitations
TRACE's advantages on StreamSpot and Unicorn Wget indicate that when local interactions and global topological deviations in the graph structure can effectively distinguish anomalies, contrastive learning using only benign data can match or even surpass some baselines. However, its poor performance on GraSec-IoT may stem from the characteristics of that dataset: attack patterns may be more subtle at the local interaction level, or changes in topological structure may not be significant enough, making it difficult to capture them through benign learning alone.
Furthermore, the supervised model's leading position on StreamSpot and GraSec-IoT shows that when sufficient labeled data is available, supervised methods remain competitive. TRACE's value lies in label-scarce scenarios, not in completely replacing supervised learning. The researchers also note that the mixed results highlight the conditional advantages of topology-aware benign learning, and that practical deployment requires selection based on specific graph characteristics.
StreamSpot, GraSec-IoT, and Unicorn Wget are public graph datasets commonly used in the intrusion detection field, representing different system activity graph scenarios. StreamSpot originates from streaming system call traces, where nodes and edges in the graph characterize interactions between entities such as processes and files, and attacks usually manifest as a small number of anomalous subgraphs; GraSec-IoT targets IoT environments, where the graph structure reflects communication and access relationships between devices, and attack patterns may be more subtly embedded in local interactions; Unicorn Wget is built from system audit logs, focusing on activity graphs related to the wget command. These datasets differ significantly in graph size, sparsity, attack types, and topological complexity, so the same method may vary greatly across datasets. Understanding the characteristics of these datasets helps explain the mixed results in which TRACE outperforms GraphCL on StreamSpot and Unicorn Wget but falls behind the baseline on GraSec-IoT.
Practical Implications and Future Directions
For security practitioners, TRACE offers an approach to building detection systems even when labeling costs are high. By leveraging the topological structure of system activity graphs and adopting a contrastive learning framework, it is possible to obtain usable anomaly detection capability without relying on attack labels. However, threshold calibration still requires a small amount of labeled data, which needs to be weighed in practice.
Future improvements may include: enhancing the sensitivity of topological representations to subtle structural changes, designing adaptive threshold calibration mechanisms to reduce dependence on validation sets, and exploring semi-supervised paradigms that combine topological contrastive learning with a small amount of supervised signal. These directions are expected to further improve the robustness and applicability of label-efficient intrusion detection.
One-line Summary
TRACE proposes a topology-aware graph contrastive learning framework that achieves label-efficient intrusion detection using only benign graphs.
Paragraph Summary
TRACE is a topology-aware graph contrastive learning framework for label-efficient intrusion detection. It performs representation learning using only benign system activity graphs, capturing local interactions through message passing and characterizing graph-level structural deviations with topological representations, and computes anomaly scores directly in the projected embedding space. Experiments were conducted on three datasets—StreamSpot, GraSec-IoT, and Unicorn Wget. TRACE's F1 scores on StreamSpot and Unicorn Wget are significantly higher than the GraphCL baseline using only benign data, but lower than the baseline on GraSec-IoT. Supervised models still lead on some datasets. The results show that topology-aware benign learning has conditional advantages and is suitable for label-scarce scenarios, but it does not outperform supervised or baseline methods in all graph settings.
Related articles

Prompt Engineering for Beginners: From Writing Prompts to Engineering Thinking
Starting from the essence and four functions of prompts, this article systematically explains the six-step process, four success criteria, learning value, and practical limitations of prompt engineering to help you build a complete understanding.

Anthropic Launches Nasdaq IPO: AI Giant's Listing and Risk Disclosures
Anthropic officially launches its Nasdaq IPO under ticker ANT, with market valuation expected to potentially exceed SpaceX's record. The prospectus devotes nearly 100 pages to AI risks, while first-half revenue grew over 14x but net losses widened sharply, reigniting the AI bubble debate.

Rust cURL Clone Uses 4,832 unsafe Blocks—Is the Memory Safety Myth Broken?
A Rust cURL clone uses 4,832 unsafe keywords, challenging Rust's memory safety narrative. We analyze what unsafe really means, compare Fil-C, and examine rewrite motives.