WorksComputer Science
TRACE: Topological Representations for Anomaly detection through Contrastive Embeddings
Abstract
Intrusion detectors must recognize evolving malicious behavior even when confirmed attack labels are scarce or incomplete. We present TRACE, a topology-aware graph contrastive learning framework for label-efficient intrusion detection. TRACE learns from benign system-activity graphs by combining message-passing and topological representations, then assigns anomaly scores in the same projected embedding space optimized by the contrastive objective. This design captures both local interactions and graph-scale structural deviations without using attack labels during representation learning. A labeled validation set containing benign and malicious graphs is used only to calibrate the anomaly threshold. We evaluate TRACE on StreamSpot, GraSec-IoT, and Unicorn Wget against a supervised graph neural network and the benign-only GraphCL baseline. TRACE obtains F1 scores of 0.923, 0.790, and 0.583, respectively. Compared with GraphCL, this is higher on StreamSpot (0.450) and Unicorn Wget (0.203), but lower on GraSec-IoT (0.975). The supervised model leads on StreamSpot and GraSec-IoT, whereas TRACE has the highest F1 on Unicorn Wget. The mixed results show that topology-aware benign-only learning can improve detection in some graph settings but does not provide a uniform advantage.
Introduction
Modern IoT and enterprise systems generate large volumes of interactions among devices, hosts, services, processes, and files. Detecting intrusions in these environments is difficult because malicious behavior is rare, evolves over time, and is only partially represented in labeled datasets. Signature-based systems depend on known attack patterns, while conventional statistical detectors often rely on fixed assumptions about normal and abnormal behavior. Both can struggle when behavior changes or an attack does not match a predefined pattern [1, 2]. Machine learning (ML)-based intrusion detection is attractive because it can learn behavioral representations from data and use them to identify suspicious deviations [1].
The same adaptability, however, is limited when ML models require comprehensive attack labels. Confirmed malicious samples are expensive to obtain, attacks are much rarer than normal activity, and previously collected labels can become less representative as attacker behavior changes [2, 3]. A supervised detector may therefore learn a strong boundary for known attacks yet fail when deployment behavior differs from its labeled training set [2]. We consequently study a benign-only representation-learning setting: the detector learns the distribution of normal behavior and flags deviations as potential intrusions [3, 4]. This setting does not guarantee detection of every unseen attack, but it reduces dependence on labeled attacks and is relevant to resilient detection under incomplete or changing threat knowledge.
System activity is inherently relational, which makes graphs a natural representation for intrusion detection. A provenance graph records how system entities and events depend on or interact with one another. Its nodes can represent hosts, devices, services, processes, or files, and its edges can represent communication, access, or system events. A single event may appear harmless in isolation while its role in a larger interaction pattern reveals malicious behavior. For example, port scanning can generate one-to-many connections [5], lateral movement can create multi-step paths across hosts [6, 7], and coordinated attacks can concentrate activity around selected targets [8]. Graph-based detection can therefore evaluate events in context rather than treating each record independently [4, 9].
This relational context makes topology important because topology describes the pattern of connectivity and graph shape. Attacks that unfold through a system can leave paths, branches, mergers of connected components, or changes in connectivity across processes, files, services, and hosts [6, 7]. Such signatures summarize how entities are connected rather than only which entities or events occur. They may therefore distinguish graphs that have similar local attributes but different global organization. A topology-aware representation complements local message passing by preserving structural information across multiple scales, which is useful when deployment-time anomalies are expressed as changes in interaction structure.
Graph contrastive learning provides a way to learn these representations without attack labels. It creates augmented views of the same graph and trains a graph neural network (GNN) encoder to recognize that the views originate from the same graph. GraphCL demonstrated that this strategy can learn graph-level representations without supervised labels [10]. Yet standard GNN message passing primarily aggregates local neighborhoods. Benign and malicious graphs can share common local patterns while differing in security-relevant paths, branches, or connectivity. TopoGCL addresses this limitation by adding summaries of graph shape across multiple scales, making topology-aware contrastive learning a suitable starting point for graph intrusion detection [11].
Despite this promise, TopoGCL was designed mainly for unsupervised graph classification, not for anomaly scoring in an intrusion detection system [11]. Classification and intrusion detection have different goals. In graph classification, labeled examples can help the model learn class boundaries after representation learning. In intrusion detection, there are no labeled attack examples during representation learning. The detector must decide whether a new graph is abnormal by comparing it with the learned distribution. Because of this, the embedding space used for distance-based scoring directly controls detection quality.
To address this gap, we propose TRACE, a topology-aware graph contrastive learning method for intrusion detection. TRACE learns from augmented views of benign graphs, combines message-passing and topology-aware embeddings, and scores each test graph by its distance from benign training embeddings. Crucially, scoring occurs in the projected space optimized during contrastive training, avoiding a mismatch between the learned objective and the representation used for detection. The method requires neither attack labels during representation learning nor an additional classifier.
We evaluate TRACE on StreamSpot, GraSec-IoT, and Unicorn Wget [4, 12, 13]. StreamSpot contains heterogeneous system-activity graphs. GraSec-IoT contains communication and attack behavior from an Internet of Things setting. Unicorn Wget contains graph samples from a system-activity attack scenario. Together, these datasets test whether TRACE works across different graph construction settings and attack behaviors. We compare TRACE with a supervised GNN and GraphCL, a graph contrastive learning baseline.
In summary, this paper makes the following contributions:
We formulate graph intrusion detection as benign-only representation learning and anomaly scoring under limited attack-label availability.
We introduce TRACE, which combines message-passing and topological embeddings and performs detection in the contrastive space optimized during training.
We evaluate TRACE on three graph security datasets against supervised and benign-only baselines, finding higher F1 than GraphCL on StreamSpot and Unicorn Wget but lower F1 on GraSec-IoT.
Together, these contributions examine how topology-aware, benign-only anomaly detection can support resilient ML-driven security monitoring when labeled attacks are incomplete or may not represent deployment behavior. The implementation and experimental results are available at https://github.com/syd-kiwi/IDS_TopoGCL.
Related Work
Graph neural networks can support intrusion detection by modeling relationships among network and system entities. Pujol-Perich et al. [14] show that graph structure can make network intrusion detection more robust than models that classify flows independently. E-GraphSAGE [9] applies a GNN to flow-based intrusion detection in Internet of Things environments and uses both edge features and graph structure.
Recent surveys show that graph-based intrusion detection is a growing area, but that deployment, labeling, and robustness remain open challenges [15]. These works support the use of graphs for security monitoring. However, many graph-based intrusion detectors are supervised and depend on labeled non-malicious and malicious examples. In contrast, TRACE learns representations from non-malicious graphs.
Recent ARTMAN work places these technical choices in a broader trustworthy-ML context. Jung et al. [16] address continuous operation under concept drift by selecting among models using a small amount of newly labeled data. Kolicic et al. [17] emphasize interpretability and uncertainty awareness for online cybersecurity learning, while Miyamoto et al. [18] study feature-free Transformer-based traffic classification. More recently, Kawanaka et al. [19] examine whether an ML-based network intrusion detector bases its decisions on attack-relevant characteristics. Together, these studies highlight adaptation, limited labeling, and analyst-facing trust as distinct deployment requirements. TRACE addresses the complementary problem of benign-only graph representation learning; it does not provide online adaptation, calibrated uncertainty, or localized explanations.
Provenance and temporal graph methods are also closely related to our task. These methods use graph structure to describe how system activity changes over time. Jbeil [20] studies temporal graph learning for lateral movement detection in enterprise networks. MAGIC [21] uses masked graph representation learning to detect advanced persistent threats from provenance graphs. FLASH [22] and KAIROS [23] also use provenance graphs to support intrusion detection and investigation. These systems show that graph-structured representations are useful for security monitoring. Our work differs in focus. We study graph-level anomaly scoring for benign-only representation learning and focus on how topology-aware contrastive embeddings should be used for detection.
Graph contrastive learning is significant for this problem because it can learn useful graph embeddings without attack labels. GraphCL [10] learns graph-level representations by creating augmented views of the same graph and training an encoder to make their embeddings agree. This makes GraphCL an important baseline for our work. However, GraphCL does not explicitly model higher-order graph shape. This can be a limitation when non-malicious and malicious activity graphs share the same broad structure but differ in smaller structural details. Graph-JEPA offers another self-supervised approach to graph-level representation learning by predicting masked subgraph representations from a context subgraph, without contrastive negative pairs [24]. TRACE instead uses a topology-aware contrastive objective and nearest-neighbor anomaly scoring for intrusion detection. Evaluating predictive graph representations under the same benign-only learning protocol is a direction for future work.
TopoGCL [11] addresses this limitation by adding topological information to graph contrastive learning. It uses topological summaries to describe graph shape across multiple scales. This makes TopoGCL the closest methodological starting point to TRACE. However, TopoGCL was designed mainly for unsupervised graph classification, not anomaly scoring or intrusion detection. A graph classifier can use labeled examples after representation learning to separate classes. A model trained only on non-malicious graphs cannot rely on labeled attacks during representation learning. It must decide whether a test graph is abnormal by comparing it with non-malicious training graphs.
TRACE builds on graph contrastive learning and topology-aware graph learning, but it targets a different security setting. It adapts topology-aware contrastive learning for intrusion detection and scores test graphs by their distance from non-malicious training embeddings. The key difference is that TRACE scores graphs in the same projected embedding space shaped by the contrastive loss. This keeps representation learning and anomaly scoring consistent. The goal is not to introduce a new topological summary. Instead, TRACE uses topology-aware contrastive embeddings more directly for intrusion detection in intelligent systems.
Methodology
TRACE is an anomaly detection method for graph-based intrusion detection. It has four main steps. First, system activity is represented as a graph. Second, TRACE learns graph and topology embeddings from non-malicious training graphs using contrastive learning. Third, each validation or test graph is embedded in the same contrastive space used during training. Fourth, the detector assigns an anomaly score by measuring distance from non-malicious training embeddings. The subsections below follow this pipeline: problem setup, graph representation, contrastive training, anomaly scoring, and thresholding.
Let denote the th activity graph. Here, is the set of nodes, is the set of edges, and is the node feature matrix. Nodes can represent entities such as hosts, devices, services, processes, or files. Edges represent interactions such as communication, access, or system events.
Let be the training set, where means non-malicious and means malicious. During representation learning, TRACE uses only graphs from . Malicious graphs are not used to train the encoder or projection head. They are used only during validation for threshold selection and during testing for evaluation.
The goal is to learn an embedding function that maps each graph to a vector representation. At test time, graphs that are far from the non-malicious training distribution receive higher anomaly scores. This setting differs from supervised graph classification. A supervised graph neural network learns directly from both benign and malicious labels. TRACE instead learns normal behavior from benign graphs and detects graphs that do not match that learned normal pattern.
Operational Setting and Threat Model
TRACE is intended for monitoring environments in which system or network telemetry can be grouped into activity graphs but comprehensive attack labels are unavailable.
Provenance- and communication-graph systems demonstrate how interactions can support intrusion detection and investigation [4], [9], [23]. A graph summarizes the entities and interactions observed within the unit of analysis defined by a dataset, such as a system-activity trace or an IoT communication snapshot. The detector receives one complete graph at a time and returns a graph-level anomaly score and binary decision. In an operational workflow, this decision would identify activity graphs for further investigation; it does not by itself identify the responsible process, connection, or subgraph. The construction and duration of each graph therefore determine the granularity of both detection and response.
The learning setting separates representation learning from threshold calibration. The encoder and projection heads learn exclusively from graphs designated as benign, so their parameters are not optimized with attack-class labels. This assumption reflects the difficulty of obtaining representative attack labels and transferring closed-world ML evaluations to operational intrusion detection [2]. It also avoids requiring the training set to enumerate the attack behaviors that may later appear, consistent with prior self-supervised graph anomaly detection motivated by limited labels [3]. Nevertheless, the evaluation is not completely label-free: the operating threshold is selected with a validation set containing benign and malicious graphs. Thus, “benign-only” in this paper refers specifically to representation learning. Deployment without labeled attacks would require another calibration strategy, such as a quantile of benign validation scores, and that alternative is outside the present experimental study.
The central detection assumption is that malicious activity produces a measurable departure from the learned benign embedding distribution, as in graph-stream anomaly detection [4]. TRACE is particularly motivated by departures expressed through graph structure: new paths, branches, changes in connectivity, or altered relationships among entities. The graph channel represents attributed local neighborhoods and their pooled graph-level summary, while the topology channel preserves complementary information about connectivity across a filtration, following the motivation for topology-aware graph contrastive learning [11]. Their combination is designed to make structurally unusual activity distant from nearby benign examples. The method does not assume that a test graph belongs to a previously observed attack class, but it cannot guarantee detection of an unseen attack. An attack that closely reproduces benign attributes and topology may receive a low anomaly score.
The benign reference set is also a trust assumption. Substantial contamination by undetected attacks could cause malicious behavior to become part of the learned normal distribution, reducing its anomaly score at inference. Likewise, legitimate but previously unseen operational changes can be distant from the reference set and produce false alerts. These two failure modes reflect broader deployment and robustness challenges identified for graph-based intrusion detection [15]. They create a practical tension: a reference memory that is too static may not represent benign behavioral drift, whereas indiscriminate updating could absorb malicious or unverified behavior. The current study uses fixed training, validation, and test splits and does not implement online adaptation. Safe reference-memory updates, drift detection, and contamination-resistant learning remain deployment requirements rather than evaluated capabilities.

Figure 1. Overview of TRACE. The top row shows contrastive training. Activity graphs are augmented into graph and topology views, encoded, projected, and optimized with a contrastive objective. The bottom row shows inference. Each graph is scored by distance to the non-malicious reference memory and classified using a validation-selected threshold.
Within this scope, resilience means reducing dependence on a complete and permanently representative catalog of labeled attacks. TRACE supports this objective by learning a benign structural reference and treating deviations as candidates for investigation. Its topology-aware representation may remain informative when local event attributes vary but the organization of system interactions changes. At the same time, trustworthy use requires presenting the anomaly score as evidence for triage rather than proof of compromise. Thresholds must reflect the relative costs of missed attacks and false alerts, and analysts need access to the underlying telemetry before acting on a prediction.
This threat model does not include an attacker who deliberately manipulates training data, graph construction, features, or augmentations to evade the detector. Structural adversarial attacks against graph-based intrusion detectors constitute a distinct evaluation setting [25]. The experiments also do not evaluate poisoning, adaptive evasion, compromised telemetry, or certified robustness. Accordingly, our use of resilience concerns detection under limited labels and differences between learned benign behavior and deployment observations; it is not a claim of adversarial robustness. Explicit evaluation against adaptive attackers is an important direction for future work.
Graph and Topology Representations
TRACE uses two complementary views of each graph: a graph-structure view and a topology view.
The graph-structure view is learned with a graph neural network encoder. In our implementation, this encoder is a graph isomorphism network. The encoder performs message passing over the graph and pools node embeddings into one graph-level readout. We use sum, mean, and max pooling and concatenate the three pooled vectors. This produces a raw graph readout, denoted by .
The raw readout is then passed through a projection head. The projection head maps into a contrastive graph embedding, denoted by . This embedding is the graph-channel representation used by the contrastive loss.
The topology view captures graph shape more directly. For each graph, TRACE computes topological summaries from structural node scores such as degree and closeness. These summaries describe how connected components appear and merge as the graph is viewed through a filtration. The topological summaries are converted into fixed-length vectors and passed through a small multilayer perceptron. The output is a topology embedding, denoted by .
The final contrastive embedding for graph combines the graph-channel and topology-channel embeddings:
where denotes normalization and denotes vector concatenation. Eq. (1) defines the embedding used later for anomaly scoring. If only one channel is used in an ablation, then contains only that channel.
Contrastive Training
During training, TRACE creates two augmented views of each graph. These views preserve the main identity of the graph while changing small details. For the graph channel, we use graph augmentations such as node dropping, edge dropping, and feature masking. For the topology channel, we perturb the topology feature vector with masking and noise.
InfoNCE trains the representation by posing a matching problem within each batch. For every embedding from the first augmented view, the corresponding embedding of the same original graph in the second view is the positive match; embeddings of the other graphs are alternatives. The loss increases the positive pair’s similarity relative to all alternatives, with the temperature controlling how strongly it emphasizes the closest matches. Thus, the objective preserves graph identity under small augmentations while separating different benign activity patterns. Formally, for a batch of graphs, let and denote the embeddings of the two views. The one-direction InfoNCE loss is:
where is cosine similarity and is a temperature parameter. Eq. (2) makes embeddings from two views of the same graph closer and pushes embeddings from different graphs apart. In practice, we use the symmetric version by averaging and .
The full training loss combines the graph-channel contrastive loss and the topology-channel contrastive loss:
where is the graph-channel loss, is the topology-channel loss, and and control their weights. Eq. (3) trains TRACE to learn both local graph structure and higher-level topology from graphs.
Contrastive-Space Anomaly Scoring
After training, TRACE embeds every training graph using the trained model. Let be the set of benign training embeddings.
For a validation or test graph , TRACE computes its embedding using Eq. (1). It then compares with the training embeddings. The anomaly score is the average distance to the nearest embeddings:
Eq. (4) assigns a larger score to graphs that are farther from normal training graphs. These graphs are more likely to be anomalous.
The key design choice in TRACE is that anomaly scoring uses the same contrastive embedding space shaped during training. Some contrastive pipelines train a projection head but later score graphs using the raw encoder readout . This can create a mismatch because the contrastive objective directly optimizes the projected embedding, not the raw readout. TRACE avoids this mismatch by scoring graphs with , which is built from the contrastive embeddings. This keeps training and detection consistent.
Detection and Thresholding
The anomaly score is converted into a binary prediction using a threshold :
where means the graph is predicted as malicious and means it is predicted as non-malicious. Eq. (5) defines the final detection rule.
In our experiments, is selected on the validation set. The validation set contains both non-malicious and malicious graphs so that we can choose the threshold that gives the best validation F1 score. The selected threshold is then fixed and applied once to the test set. The encoder and projection head are still trained only on benign graphs. Malicious labels are used for threshold selection and evaluation, not for representation learning.
Evaluation
This section evaluates whether TRACE provides effective graph-level intrusion detection across datasets, baselines, and label-availability settings.
Research Questions
We evaluate three research questions:
RQ1: How does TRACE compare with supervised and benign-only graph baselines across intrusion detection datasets?
RQ2: Does topology-aware contrastive scoring improve over standard graph contrastive learning?
RQ3: How do the methods balance attack recall and alert precision?
Datasets
We evaluate graph-level intrusion detection on three datasets. Each dataset is converted into a set of graphs. Each graph has a benign or malicious label for validation and testing. During representation learning, benign-only methods use only benign training graphs.
StreamSpot: contains heterogeneous system-activity provenance graphs. These graphs represent relationships among system entities and events. StreamSpot is useful for testing whether a detector can identify malicious behavior in structured system activity [4].
GraSec-IoT: contains graph snapshots from an Internet of Things security setting. It includes communication behavior and attack activity in an IoT environment [12].
| Dataset | Model | Accuracy | Precision | Recall | F1 |
| StreamSpot | Supervised GNN | ||||
| StreamSpot | GraphCL | ||||
| StreamSpot | TRACE | ||||
| GraSec-IoT | Supervised GNN | ||||
| GraSec-IoT | GraphCL | ||||
| GraSec-IoT | TRACE | ||||
| Unicorn Wget | Supervised GNN | ||||
| Unicorn Wget | GraphCL | ||||
| Unicorn Wget | TRACE |
Table I. Intrusion detection performance across three graph-based security datasets. The supervised GNN uses labeled attacks during training. GraphCL and TRACE are benign-only representation learning methods.
This dataset tests whether the method works on IoT-style communication graphs.
Unicorn Wget: is a graph-based security dataset built from system activity collected from a Wget attack scenario. It provides graph samples rather than tabular flow records, so it fits our graph-level detection setting [13].
The datasets contain 600 StreamSpot graphs, 7,443 GraSec-IoT graphs, and 150 Unicorn Wget graphs. For TRACE, StreamSpot uses 360 benign training graphs, 40 validation graphs, and 160 test graphs. GraSec-IoT uses 342 benign training graphs, 152 validation graphs, and 44 test graphs. Unicorn Wget uses 90 benign training graphs, 10 validation graphs, and 40 test graphs. These split sizes remain constant across the reported random seeds. The methods use the same reported random seeds but different data partitions in the saved experiments. Consequently, the results compare the evaluated configurations rather than performance on identical graphs.
Baselines
We compare TRACE with one label-rich reference model and one benign-only representation learning baseline.
Supervised GNN. This supervised graph neural network is trained with labeled benign and malicious graphs. We treat it as a label-rich reference baseline. It is not directly comparable to benign-only representation learning methods because it uses attack labels during training, but it shows what performance is possible when labels are available.
GraphCL. This benign-only graph contrastive learning baseline learns graph embeddings from augmented graph views without using attack labels during representation learning [10]. It tests whether standard graph contrastive learning is sufficient for this task.
Experimental Setup
All methods use the same split logic for a given dataset and seed. StreamSpot and GraSec-IoT results aggregate seeds 42, 43, and 44; Unicorn Wget results aggregate seeds 42 through 46. The threshold is selected separately on the validation set for each benign-only run before being applied once to the corresponding test set.
The encoder is trained only on benign training graphs. Malicious graphs are used only for validation threshold selection and final testing. This prevents attack labels from being used during representation learning.
For TRACE, we use 12 training epochs, hidden dimension 64, embedding dimension 64, temperature 0.2, maximum 512 nodes per graph, node drop rate 0.10, edge drop rate 0.05, feature mask rate 0.10, topology mask rate 0.10, topology noise 0.10, and nearest neighbors for anomaly scoring. For the joint graph-topology model, we use and to weight the graph and topology contrastive losses. Baseline hyperparameters follow their saved experimental configurations rather than being assumed identical to TRACE.
Metrics
We report accuracy, precision, recall, and F1 score. Let TP be true positives, TN be true negatives, FP be false positives, and FN be false negatives. Precision is and measures how many predicted attacks are actually attacks. Recall is and measures how many attacks are detected. F1 score is the harmonic mean of precision and recall.
F1 is useful because intrusion detection needs both high precision and high recall. Precision is important because too many false alerts can make an intrusion detection system difficult to use in practice. Recall is important because missed attacks can leave a system exposed.
Results by Research Question
Table I reports intrusion detection performance across StreamSpot, GraSec-IoT, and Unicorn Wget. The supervised GNN uses labeled benign and malicious graphs during training. GraphCL and TRACE train their encoders using only benign graphs and use labeled validation data only for threshold selection.
RQ1: Comparison with supervised and benign-only baselines. The supervised GNN achieves the highest F1 on StreamSpot () and GraSec-IoT (), while TRACE achieves the highest F1 on Unicorn Wget ( versus for the supervised GNN). Among the benign-only methods, TRACE has higher F1 on StreamSpot ( versus ) and Unicorn Wget ( versus ), whereas GraphCL leads on GraSec-IoT ( versus ). Thus, TRACE is competitive in two benign-only comparisons but is neither uniformly superior to GraphCL nor a replacement for label-rich learning when representative attack labels are available.
RQ2: Comparison with standard graph contrastive learning. Topology-aware contrastive scoring does not improve over standard GraphCL uniformly. TRACE has higher F1 by 0.473 on StreamSpot and 0.380 on Unicorn Wget, but lower F1 by 0.185 on GraSec-IoT. This heterogeneity indicates that the value of degree- and closeness-based topological summaries depends on the dataset and graph construction. A plausible explanation is that topology adds complementary information when anomalous behavior changes connectivity at graph scale, while the standard graph representation is already sufficient for the GraSec-IoT split. Because the methods also differ in architecture and training configuration, these comparisons do not isolate topology as the sole causal factor.
RQ3: Precision–recall balance. On StreamSpot, TRACE combines recall of with precision of , whereas GraphCL has lower and much more variable recall () and precision (). On GraSec-IoT, GraphCL provides the stronger balance, with precision of and recall of ; TRACE retains high recall () but lower precision (). On Unicorn Wget, TRACE improves the benign-only balance, but both benign-only methods and the supervised GNN exhibit substantial weaknesses or variability. For resilient monitoring, the preferred operating point remains deployment-dependent: missed attacks favor recall, whereas analyst capacity and alert fatigue favor precision.
Overall, RQ1 shows that the supervised reference has the highest F1 on StreamSpot and GraSec-IoT, while TRACE leads on Unicorn Wget and is the stronger benign-only method on StreamSpot and Unicorn Wget. RQ2 shows that topology-aware scoring is dataset-dependent rather than uniformly beneficial. RQ3 shows a strong TRACE recall–precision balance on StreamSpot, a stronger GraphCL balance on GraSec-IoT, and challenging, variable behavior for all methods on Unicorn Wget.
Discussion and Limitations
The results answer the three research questions with a qualified conclusion. For RQ1, the supervised GNN has the highest F1 on StreamSpot and GraSec-IoT, while TRACE leads on Unicorn Wget; among the benign-only methods, TRACE is stronger on StreamSpot and Unicorn Wget and GraphCL is stronger on GraSec-IoT. For RQ2, topology-aware scoring is associated with higher F1 on two datasets and lower F1 on one, so the evaluation does not support a universal benefit. For RQ3, TRACE balances precision and recall well on StreamSpot, GraphCL does so on GraSec-IoT, and all methods show limitations or high variation on Unicorn Wget. These outcomes argue for dataset-dependent utility rather than overall superiority.
The supervised GNN’s advantage on StreamSpot and GraSec-IoT is fair and expected because it is optimized directly with both benign and malicious labels, while TRACE and GraphCL do not use attack labels during representation learning. When labeled training attacks resemble test attacks, supervision provides direct information for locating a decision boundary. On Unicorn Wget, however, the supervised GNN’s high accuracy is accompanied by low and variable recall and a lower F1 than TRACE. Accuracy alone therefore does not imply reliable attack coverage. The available results do not establish the cause; possible contributors include the smaller sample, graph construction, and the relationship between labeled training and test behavior. We avoid attributing the behavior to overfitting without further analysis. Matched ablations that remove the topology channel and compare scoring before and after projection are needed to establish the individual contributions of these choices.
Dataset construction provides a cautious explanation for the mixed topology-aware results. StreamSpot contains provenance graphs of heterogeneous system activity, GraSec-IoT represents IoT communication snapshots, and Unicorn Wget captures a specific system-activity scenario. These graph types can encode attacks at different structural scales. Degree- and closeness-based summaries may add complementary information for the two provenance-style settings, whereas GraphCL’s learned representation is more effective on the GraSec-IoT split. Confirming this interpretation would require attack-level structural analysis and matched ablations beyond the present study.
From an ARTMAN perspective, TRACE addresses one aspect of resilient and trustworthy ML-driven security: maintaining an anomaly-detection capability when comprehensive attack labels are unavailable. Learning a benign reference and scoring deviations reduces reliance on a fixed catalog of attacks. Prior ARTMAN studies show that continuous security operation also requires mechanisms for concept drift, uncertainty, and explanation [16, 17, 19]. The present evaluation does not establish those capabilities: its reference memory is fixed, its scores are not calibrated as predictive uncertainty, and its alerts are not localized. This is also not a claim of adversarial robustness. The evaluation measures ordinary detection performance under the reported splits; it does not test evasion, poisoning, adaptive attackers, or certified robustness.
Limitations and Threats to Validity
Several limitations constrain the conclusions. First, only three datasets and their existing graph constructions are evaluated, so the results may not generalize to other networks, organizations, attack families, or graph-generation procedures. Second, the comparison does not use a fully matched architecture and hyperparameter configuration across GraphCL and TRACE. TRACE, so it cannot attribute performance differences solely to topology. Third, labeled malicious validation graphs are used to select the F1-maximizing threshold. Although attack labels do not train the representation, this choice is not fully label-free and may be difficult to reproduce when deployment-time attacks are unavailable.
Fourth, balanced evaluation sets and F1-selected thresholds do not reproduce the low attack prevalence of many operational environments. Precision and alert volume may change under realistic class imbalance. Fifth, the supervised and benign-only methods have different access to labels, so the supervised GNN is a label-rich reference rather than a strictly matched baseline. Sixth, graph truncation, augmentations, hyperparameters, and the selected degree and closeness filtrations may affect performance; the present experiments do not establish which design component causes each dataset-level difference. Finally, TRACE detects anomalies at graph level and does not localize the nodes, edges, or subgraphs responsible for an alert, limiting analyst-facing explanation.
Future work should evaluate additional attack families and deployment shifts, select thresholds without labeled attacks, test under realistic class imbalance, and study sensitivity to graph construction and topology choices. Attack localization and structural explanations would make alerts more actionable. Robustness to adversarial manipulation, poisoning, and adaptive evasion also requires separate experiments before TRACE can be characterized as adversarially robust.
Conclusion
This paper studied topology-aware graph contrastive learning for benign-only graph-based intrusion detection. We introduced TRACE, a method that learns from benign activity graphs and scores test graphs by distance from benign training embeddings. TRACE combines graph-level message-passing representations with topology-aware structural information and performs anomaly scoring in the same contrastive embedding space used during training.
Across three graph-based security datasets, TRACE obtains F1 scores of 0.923 on StreamSpot, 0.790 on GraSec-IoT, and 0.583 on Unicorn Wget. It outperforms GraphCL on StreamSpot and Unicorn Wget but underperforms it on GraSec-IoT. The supervised GNN leads on StreamSpot and GraSec-IoT, whereas TRACE has the highest F1 on Unicorn Wget. These mixed results show that topology-aware contrastive anomaly scoring can strengthen benign-only detection in some graph settings but is not uniformly beneficial. The result supports continued study of topology-aware detection under incomplete attack labels, while the limited datasets, unmatched baseline configurations, and label-dependent threshold selection motivate broader and more controlled validation.
LLM Usage Statement
LLMs were used for editorial purposes in this manuscript, and all outputs were inspected by the authors to ensure accuracy and originality. Their use was limited to language editing and organization. The authors take responsibility for the manuscript’s correctness, originality, citations, and scientific claims. No experiments, experimental data, or numerical results were generated by these tools.
References
- [1]A. L. Buczak and E. Guven, “A survey of data mining and machine learning methods for cyber security intrusion detection,” Commun. Surveys Tuts., vol. 18, p. 1153–1176, Apr. 2016.DOI
- [2]R. Sommer and V. Paxson, “Outside the closed world: On using machine learning for network intrusion detection,” in 2010 IEEE Symposium on Security and Privacy, pp. 305–316, IEEE, 2010.DOI
- [3]E. Caville, W. W. Lo, S. Layeghy, and M. Portmann, “Anomal-E: A self-supervised network intrusion detection system based on graph neural networks,” Knowledge-Based Systems, vol. 258, p. 110030, 2022.DOI
- [4]E. A. Manzoor, S. M. Milajerdi, V. N. Venkatakrishnan, and L. Akoglu, “Fast memory-efficient anomaly detection in streaming heterogeneous graphs,” in Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD ’16, pp. 1035–1044, ACM, 2016.arxiv.org/abs/1602.04844
- [5]C. B. Lee, C. Roedel, and E. Silenok, “Detection and characterization of port scan attacks,” tech. rep., Department of Computer Science and Engineering, University of California, San Diego, 2003.
- [6]Y. Fang, C. Wang, Z. Fang, and C. Huang, “LMTracker: Lateral movement path detection based on heterogeneous graph embedding,” Neurocomputing, vol. 474, pp. 37–47, 2022.DOI
- [7]J. Zhou, J. Yao, X. Chen, S. Yu, Q. Xuan, and X. Yang, “Lateral movement detection via time-aware subgraph classification on authentication logs,” 2024.arxiv.org/abs/2411.10279
- [8]R. Abu Bakar, L. De Marinis, F. Cugini, and F. Paolucci, “FTG-Net-E: A hierarchical ensemble graph neural network for DDoS attack detection,” Computer Networks, vol. 250, p. 110508, 2024.
- [9]W. W. Lo, S. Layeghy, M. Sarhan, M. Gallagher, and M. Portmann, “E-graphsage: A graph neural network based intrusion detection system for iot,” in 2022 IEEE/IFIP Network Operations and Management Symposium (NOMS), pp. 1–9, IEEE, 2022.DOI
- [10]Y. You, T. Chen, Y. Sui, T. Chen, Z. Wang, and Y. Shen, “Graph contrastive learning with augmentations,” in Advances in Neural Information Processing Systems, vol. 33, pp. 5812–5823, 2020.arxiv.org/abs/2010.13902
- [11]Y. Chen, J. Frias, and Y. R. Gel, “TopoGCL: Topological graph contrastive learning,” in Proceedings of the AAAI Conference on Artificial Intelligence, vol. 38, pp. 11453–11461, 2024.arxiv.org/abs/2406.17251
- [12]D. Hamouche, R. Kadri, M.-L. Messai, and H. Seba, “(poster) a graph dataset for security enforcement in IoT networks: GRASEC-IoT,” in 2024 20th International Conference on Distributed Computing in Smart Systems and the Internet of Things (DCOSS-IoT), pp. 765–767, 2024.DOI
- [13]“Wget dataset.” https://dataverse.harvard.edu/dataverse/unicorn-wget. Accessed: 2022-09-17.
- [14]D. Pujol-Perich, J. Suárez-Varela, A. Cabellos-Aparicio, and P. Barlet-Ros, “Unveiling the potential of graph neural networks for robust intrusion detection,” arXiv preprint arXiv:2107.14756, 2021.
- [15]C. Wang, P. Zheng, J. Gui, C. Hua, and W. U. Hassan, “Are we there yet? unraveling the state-of-the-art graph network intrusion detection systems,” 2025.arxiv.org/abs/2503.20281
- [16]S. Jung, K. Furumoto, T. Takahashi, and Y. Shiraishi, “Model selection for continuous operation of automated vulnerability assessment system,” in Proceedings of the 2023 Workshop on Recent Advances in Resilient and Trustworthy ML Systems in Autonomous Networks, ARTMAN ’23, pp. 11–15, ACM, 2023.DOI
- [17]B. Kolic, A. Caron, V. Mavroudis, and C. Hicks, “Inherently interpretable and uncertainty-aware models for online learning in cybersecurity problems,” in 2024 Annual Computer Security Applications Conference Workshops (ACSAC Workshops), pp. 1–10, IEEE, 2024.
- [18]K. Miyamoto, C. Han, T. Ban, T. Takahashi, and J. Takeuchi, “Intrusion detection simplified: A feature-free approach to traffic classification using transformers,” in 2024 Annual Computer Security Applications Conference Workshops (ACSAC Workshops), pp. 20–29, IEEE, 2024.DOI
- [19]S. Kawanaka, K. Miyamoto, C. Han, T. Ban, T. Takahashi, and J. Takeuchi, “Towards explainable machine learning NIDS reflecting cyber-attack characteristics,” in Proceedings of the 2025 Workshop on Recent Advances in Resilient and Trustworthy Machine learning-driven Systems, ARTMAN ’25, pp. 34–44, ACM, 2025.
- [20]J. Khoury, D. Klisura, H. Zanddizari, G. De La Torre Parra, P. Najafırad, and E. Bou-Harb, “Jbeil: Temporal Graph-Based Inductive Learning to Infer Lateral Movement in Evolving Enterprise Networks,” in 2024 IEEE Symposium on Security and Privacy (SP), (Los Alamitos, CA, USA), pp. 3644–3660, IEEE Computer Society, May 2024.DOI
- [21]Z. Jia, Y. Xiong, Y. Nan, Y. Zhang, J. Zhao, and M. Wen, “MAGIC: Detecting advanced persistent threats via masked graph representation learning,” in 33rd USENIX Security Symposium (USENIX Security 24), (Philadelphia, PA), pp. 5197–5214, USENIX Association, Aug. 2024.arxiv.org/abs/2310.09831
- [22]M. Ur Rehman, H. Ahmadi, and W. Ul Hassan, “Flash: A comprehensive approach to intrusion detection via provenance graph representation learning,” in 2024 IEEE Symposium on Security and Privacy (SP), pp. 3552–3570, 2024.
- [23]Z. Cheng, Q. Lv, J. Liang, Y. Wang, D. Sun, T. Pasquier, and X. Han, “Kairos: Practical intrusion detection and investigation using whole-system provenance,” in 2024 IEEE Symposium on Security and Privacy (SP), pp. 3533–3551, IEEE, 2024.arxiv.org/abs/2308.05034
- [24]G. Skenderi, H. Li, J. Tang, and M. Cristani, “Graph-level representation learning with joint-embedding predictive architectures,” Transactions on Machine Learning Research, 2025.
- [25]A. Venturi, D. Stabili, and M. Marchetti, “Problem space structural adversarial attacks for network intrusion detection systems based on graph neural networks,” arXiv preprint arXiv:2403.11830, 2024.arxiv.org/abs/2403.11830