3. Dataset and Methodology
3.1. The SWaT Testbed and Network Logs
The Secure Water Treatment (SWaT) testbed, developed and maintained by the iTrust Centre for Research in Cyber Security at Singapore University of Technology and Design [
22,
23], is a scaled operational water-treatment plant designed for ICS security research. The plant implements a sequential six-stage purification process: raw-water intake (P1), chemical pretreatment (P2), ultrafiltration (P3), UV dechlorination (P4), reverse osmosis (P5), and permeate storage and backwash (P6). Each stage is governed by a dedicated Programmable Logic Controller (PLC) with Human–Machine Interfaces (HMIs) providing operator supervision and a central Supervisory Control and Data Acquisition (SCADA) workstation connected to a Historian for data logging. Level 1 communication follows a star topology between the SCADA workstation and the six stage PLCs; Level 0 consists of ring networks linking PLCs to their sensors and actuators.
Figure 2 reproduces the testbed layout.
The SWaT dataset was generated over 11 days of continuous 24/7 operation. The first seven days capture normal operation from an empty plant state through to steady state; the remaining four days superimpose 36 predefined, manually executed cyber-physical attacks against various sensors and actuators. Two primary data modalities are recorded. The physical-process modality provides sensor and actuator readings logged by the Historian at one-second granularity (51 variables). The network-traffic modality captures the packet-level communications between the SCADA workstation and the PLCs, preserving Modbus/TCP function codes, transaction identifiers, endpoint addresses, and timing metadata. In both modalities, the binary column Tag provides the ground-truth label: 0 for normal, 1 for attack.
Scope of this paper: we focus exclusively on the network-traffic modality. This choice is motivated by two considerations. First, most prior
rigorous SWaT IDS work evaluates the physical-process modality [
25,
26,
27], leaving the network-traffic modality comparatively understudied. Second, network traffic captures the
attack vector (the malicious commands traversing the OT network) in contrast to the
attack effect (the anomalous physical behaviour induced by those commands). A detector that operates at the network layer can, in principle, raise an alarm before physical consequences materialise.
3.2. Preprocessing Pipeline
Our preprocessing pipeline, summarised in
Figure 3, transforms the raw network logs into a per-file Parquet feature store suitable for downstream model training and evaluation. The pipeline is content-addressed: each preprocessing configuration yields a short hash (md5 over the serialised configuration) that names the output directory so that two experiments with identical preprocessing reuse a single cache.
Diverse file selection: the selection strategy greedily picks one file per distinct attack_id before filling the remaining budget with additional attack-containing files; normal-only files are sampled uniformly. With a budget of attack files plus normal files (e.g., , for a 15-file sample matching the conference study, or , for a 30-file sample), the procedure guarantees maximum attack-type coverage given the budget.
Feature engineering. Each selected file is streamed in 100,000-row chunks. The raw columns fall into three groups:
Base numerical (four variables): Modbus_Function_Code, Modbus_Transaction_ID, service, s_port;
Time-derived (five variables, engineered from date + time): cyclical encodings of hour and day-of-week as pairs, and between consecutive records;
Rolling statistics over service and s_port. For each window size with , we compute the rolling mean and rolling standard deviation strictly within each source file and strictly causally, using the pandas rolling(w, min_periods = 1) aggregation: the rolling value at row t is computed from rows . No future row is ever consulted, and no rolling window ever crosses a source-file boundary, eliminating the rolling-window temporal-leakage risk. The window sizes were chosen on operational rationale rather than via tuning on test data: captures the immediate Modbus poll-response burst, captures roughly half a typical SCADA polling cycle on this testbed, and captures a multi-cycle context that smooths over single-cycle noise. We deliberately did not perform a held-out-data sensitivity sweep on the choice of W (which would itself be a form of test-set leakage on a small sample).
All numerical features are scaled with
StandardScaler, whose statistics (per-column mean and standard deviation) are fit in a streaming
partial_fit pass across all selected files (not only a subset, correcting a shortcut present in [
28]). We note that the scaler is fitted on the union of all selected files before the train/validation/test split is computed, so the scaler’s mean and standard deviation incorporate rows that subsequently become validation or test partitions. This is a known but limited form of preprocessing leakage: the scaler statistics are univariate and are dominated by the ≥70% normal-traffic rows that are present in every partition, so we expect the practical impact on per-fold AUROC to be small. A leakage-aware variant that re-fits the scaler on each LOO fold’s training partition is part of the streaming-loader future-work item discussed in
Section 8. The remaining twelve categorical columns (
orig,
type,
i/f_name,
i/f_dir,
src,
dst,
proto,
appi_name,
proxy_src_ip,
Modbus_Function_Description,
SCADA_Tag,
Modbus_Value) are encoded via the hashing trick [
21], each yielding a 32-dimensional sparse embedding that is subsequently densified. Hashing is stateless, so the categorical-encoding step introduces no leakage. The final feature vector therefore has dimension
giving
for single-window configurations and
for multi-window
. Rows with
NaT timestamps or invalid
Tag values are dropped; each surviving row is annotated with its source filename and resolved
attack_id, producing a Parquet schema of
(timestamp, tag, attack_id, source_file, features…).
3.3. Evaluation Protocols
We implement three protocols as first-class code paths. Each produces a disjoint (train, validation, test) partition of the Parquet-cached rows.
Table 1 summarises their respective leakage properties.
Stratified random matches the protocol used in the conference paper [
28] and is the de facto standard in the broader supervised-IDS literature. Rows are partitioned uniformly at random with class stratification. This protocol permits rows of the same attack event to occupy both training and test partitions, and it is reported here only as a reproduction baseline.
Attack-held-out. The unique attack_id values present in the sample (15 for our 15-file sample; 17 for the 30-file sample) are assigned disjointly: attacks to validation, to test, the remainder to training (we use , by default). Normal rows (those with attack_id = 0) are ordered by timestamp and split into proportional earliest–middle–latest thirds to preserve a temporal prior without interfering with class disjointness. Because each SWaT attack is a single, non-repeating event, this protocol eliminates same-event leakage entirely at the cost of concentrating class distributions in each split.
Leave-one-attack-out. For each where K is the number of distinct attack_id values in the sample, we construct a separate train/val/test partition in which attack a forms the test positive set (combined with the latest 15% of normal rows), while the other attacks are stratified-randomly split 85/15 between training and validation (combined with the remaining normal rows). The protocol therefore yields K independent training runs per model; per-attack test metrics are aggregated to produce per-attack difficulty estimates and across-attack summary statistics. LOO is strictly stronger than attack-held-out: every attack in turn acts as an unseen test, removing any bias introduced by a specific held-out choice.
Implementation remarks. All three protocols yield pandas
DataFrame objects that preserve the
(timestamp, tag, attack_id, source_file) metadata columns alongside the
d-dimensional feature matrix. A shared adapter converts a partition to the (
X,
y) NumPy tensors expected by the model API described in
Section 4. All splits are parametrised by a single
seed for reproducibility.
4. Models
We evaluate five model families, which were deliberately chosen to span supervised and unsupervised paradigms, and flat and sequential feature representations. All models ingest the same tabular representation described in
Section 3.2; sequential models additionally construct a sliding window over consecutive rows within a single source file so that each sequence is a contiguous run of network events. Per-model hyperparameters are listed in
Table 2; default values are reported here and were kept fixed across protocols and sample sizes to avoid introducing a test-time tuning confound.
4.1. Gradient-Boosted Trees (XGBoost)
XGBoost [
49] serves as the strong tabular baseline, matching the configuration used in our conference paper [
28]. The classifier is trained with the
hist tree method on the GPU with up to 500 boosting rounds,
max_depth ,
learning_rate ,
row and column subsampling, and early stopping on validation AUROC with a patience of 50. When the positive class is sparse, we set
scale_pos_weight on the training split. No explicit sequence information is supplied; temporal context enters only through the rolling-window features computed in preprocessing.
4.2. Hybrid 1D-CNN and MLP
To preserve continuity with the conference paper, we port the hybrid CNN–MLP architecture to PyTorch 2.4.1, keeping the layer topology unchanged. The input vector
is treated as a single-channel one-dimensional signal and passed through two blocks of
Conv1d–
ReLU–
MaxPool1d–
Dropout with 64 and 32 filters, a kernel size of 3, and a dropout of
; the flattened representation is fed into a three-layer MLP (
) with a dropout of
before the output unit. The model is trained with
BCEWithLogitsLoss, a learning rate of
, a batch size of 4096, and early stopping on validation AUROC with a patience of 5. Although tabular XGBoost usually outperforms this architecture on the flat representation, we retain it as a direct comparability anchor with our prior result and as evidence that the protocol gap we report in
Section 6 is not an artefact of a single model family.
4.3. Bidirectional LSTM
The first of the two sequential models is a supervised bidirectional LSTM [
50,
51]. The network stacks two bidirectional LSTM layers with a hidden size of 128 per direction and an inter-layer dropout of
, which is followed by a linear head over the final timestep. Input sequences of length
rows are built by a sliding window over the feature matrix; the label assigned to each sequence is the label of its final row, so the model must decide attack versus normal on the current event given its immediate past and near future. Training uses Adam with a learning rate of
, a batch size of 512 (reduced from 1024 in preliminary runs to avoid CUDA out-of-memory on the 30-file leave-one-attack-out configuration; see
Section 8), and the same AUROC-based early stopping policy. Because the Bi-LSTM consumes future context within the window, it is strictly an
offline detector; we make this choice explicit rather than implicit.
4.4. LSTM Autoencoder
The second sequential model is an unsupervised LSTM autoencoder, which is motivated by the long line of reconstruction-based anomaly detectors for multivariate sensor streams [
25,
26,
36]. The encoder is a two-layer LSTM with a hidden size of 64; the final hidden state is tiled
T times and passed through a second two-layer LSTM decoder, which is followed by a linear projection back to input dimensionality. The model is trained with mean-squared-error reconstruction loss on the subset of windows in which
every timestep is labelled normal, so that no attack signal leaks into the training objective. At inference time, each window receives a reconstruction MSE; we convert MSE to an anomaly probability by the logistic transform
where
is the 95
th percentile of reconstruction errors on all-normal validation windows and
is their standard deviation. Hyperparameters are identical to those of the Bi-LSTM except for hidden size and the 95-th-percentile threshold.
Two practical properties of this model matter for the evaluation that follows. First, because training uses no attack labels, detection quality is necessarily threshold-sensitive; we therefore report both the threshold-independent AUROC and the threshold-tuned F
1 to disentangle ranking ability from operating-point choice. Second, reconstruction scoring favours attacks that induce large physical or protocol excursions over attacks whose signature resembles a plausible continuation of the normal process, which is a bimodality we examine in
Section 6.2.
4.5. Temporal Convolutional Network (TCN)
The fourth supervised model is a Temporal Convolutional Network (TCN), which is included as a representative modern-architecture sequence baseline alongside the recurrent Bi-LSTM. We choose TCN over a Transformer encoder for the same role: TCN is closer in spirit to the existing CNN-MLP and Bi-LSTM (dilated causal 1D convolutions), trains stably without architecture-specific tuning, and matches the receptive field of the Bi-LSTM () with deterministic memory cost. The architecture stacks five residual TCN blocks with a kernel size of 3, channel widths of 32, and dilations , yielding receptive field . Each block applies two padded causal convolutions with ReLU activations, a dropout of , and a 1 × 1 residual projection. The final timestep’s channel vector is passed through a linear head to produce the binary logit. Training uses Adam with a learning rate of , a batch size of 128, and the same early-stopping policy as the other neural models. As with the Bi-LSTM, the TCN consumes only the past timesteps for the current decision and is therefore deployment realistic for streaming inference (unlike the Bi-LSTM, which is offline by design).
4.6. Stacked Ensemble
The final model is a stacked ensemble [
52] over the heterogeneous base learners. Concretely, each base model produces per-row attack probabilities
on validation data; a logistic-regression meta-learner is fitted on the stacked vector
against validation labels with
regularisation (
) and up to 1000 iterations. Two design considerations are worth recording explicitly.
The first is the handling of sign inversion. Under attack-held-out evaluation, a supervised base learner may invert on held-out attacks, that is, produce an AUROC reliably below ; this is not a symptom of poor learning but of the held-out attack occupying a region of feature space opposite to the training attacks along the relevant decision direction. We therefore also report a simpler ensemble rule, sign-adjusted averaging: for each held-out attack, we flip the probabilities of any member whose per-attack AUROC is below before averaging. This rule uses the held-out labels only to diagnose inversion, not to pick an operating point, and it is useful as an upper bound on what a meta-learner could achieve if it had attack-level labels.
The second is the choice of
validation stage for the meta-learner. Under strict attack-held-out evaluation, the meta-learner must be fitted on validation predictions produced on attacks that are themselves disjoint from both the training attacks of its members and the final held-out test attack. We enforce this by forming the validation split from the training-attack portion of the data, not from a temporal tail of the held-out attack, so the ensemble never sees the test attack in any form during meta-fitting. The alternative—fitting the meta-learner on predictions for the held-out attack—would constitute the precise evaluation leakage we critique in
Section 2.3.
6. Results
We report results in three layers, of increasing strictness.
Section 6.1 reproduces the conference-paper protocol (random stratified) on our unified pipeline as a baseline and then contrasts it with attack-held-out and leave-one-attack-out.
Section 6.2 drills into the leave-one-attack-out evaluation, the most rigorous and most informative protocol, and presents the per-attack detectability map for all four trained models (XGBoost, LSTM-Autoencoder, Bi-LSTM, and TCN).
Section 6.3 reports stacked-ensemble results that recover signal from the supervised models that, individually, score below random under attack-held-out evaluation.
Two orthogonal axes. Before reporting the numbers, we emphasise that the two methodological axes the paper examines—(i) supervised vs. unsupervised training, and (ii) evaluation under random stratified split vs. attack-held-out/leave-one-attack-out—are independent. Each
cell has a different failure mode.
Supervised +
random memorises within-attack signatures, scores AUROC > 0.85 (
Table 4), gives no guarantee on novel attacks.
Supervised +
attack-held-out scores below-random on the held-out attacks whose signatures are absent from training (XGBoost LOO mean
,
Section 6.2).
Unsupervised +
random catches deviations from reconstructed-normal regardless of attack identity, but the random split inflates apparent precision by exposing within-attack rows to validation thresholds.
Unsupervised +
attack-held-out detects out-of-envelope attacks (LSTM-AE on attacks 23/25/26/28/29) and misses in-envelope attacks (LSTM-AE on attacks 19/20).
6.1. Protocol Comparison
Table 4 summarises the mean test AUROC for each (model, protocol) combination on the 30-file sample. Three observations are immediate.
First, the random-split column is consistent with the high AUROC values reported across the SWaT network-traffic literature (XGBoost
, CNN–MLP
), which under that protocol partly reflect repeated exposure to within-attack rows in both training and test. Second, the attack-held-out column on a single 4-attack test partition drops every supervised model to AUROC below random, suggesting that the supervised models have learnt attack-specific signatures that not only fail to transfer but actively mislead on at least the held-out attacks in this partition. Third, the LOO mean over 16 distinct held-out attacks confirms that this is not an artefact of one unfortunate attack choice: XGBoost’s LOO mean of
aggregates across attacks whose individual AUROC ranges from
to
(
Section 6.2) with 12 of 16 folds at AUROC values below
; the LSTM-Autoencoder’s LOO mean of
similarly spans
to
with 7 of 16 folds above
and three below
.
The gap between the random column and the LOO column—on the order of AUROC for XGBoost—quantifies the cost of evaluating ICS network IDS under leakage-prone protocols. To our knowledge, no prior work on the SWaT network modality has reported this gap.
6.2. Leave-One-Attack-Out Analysis
The leave-one-attack-out cross-validation removes the dependence of summary statistics on a particular held-out choice.
Table 5 first reports the composition of each LOO test partition: every fold’s test set consists of all rows of the held-out attack joined with the temporally last
of normal rows (≈1.65 million rows). The class imbalance varies substantially across folds because the attacks themselves differ in duration; attack 28 produces
attack rows (a
ratio with normal rows) while attack 26 produces only
(
). Attack 14, whose temporal-tail test partition contains only
attack rows, with the AUROC estimate at
is dominated by per-row label noise, and including it inflates the LSTM-Autoencoder mean from
to
without scientific information gain. We therefore restrict the LOO summary in
Table 6,
Table 7 and
Table 8 to the 16 folds with
.
Table 6 and
Figure 4 report the per-attack test AUROC and associated ROC curves for each of the four trained models (XGBoost, LSTM-Autoencoder, Bi-LSTM, and TCN) on the same 30-file multi-window sample; values shown in bold exceed
(a heuristic threshold for plausible deployability).
Operating-point statistics are summarised in
Table 7. At the threshold that maximises
on each fold, the false-negative and false-positive counts are both large for every solo model, reflecting that AUROC values well below
admit no operating point with simultaneously high recall and bounded false-positive rate. Recall at a fixed false-positive rate of
(R
5%) is essentially zero across all three solo models on every fold; deployment-relevant detection on SWaT network traffic under unseen-attack evaluation requires the ensemble combination of
Section 6.3.
The pattern visible in
Table 6 is striking and is the central empirical contribution of this paper. The two model families exhibit
opposite sets of detectable attacks. The XGBoost classifier achieves above-chance performance only on attacks 19, 20, 21 and 29; on every other held-out attack, it ranks the attack rows below the normal rows—the sign of a model whose decision boundary, learnt from other training attacks, lies on the wrong side of the held-out attack’s signature. The LSTM-Autoencoder displays the converse pattern: it detects attacks 8, 15, 23, 25, 26, 28 and 29 with AUROC values of
or higher (and
or higher for five of them), but it is no better than chance, or actively misses, on attacks 19, 20 and 27.
This bimodality has a clean physical interpretation that we elaborate on in
Section 7. Attacks that induce large excursions in sensor readings or actuator commands—visibly outside the autoencoder’s learnt envelope of normal behaviour—are detected by reconstruction error regardless of whether their identity was seen during training. Attacks that closely mimic the statistical envelope of normal operation (e.g., sensor-spoofing attacks 19 and 20, where the malicious commands deliberately interpolate inside the normal range) cannot be flagged by reconstruction alone.
The supervised XGBoost succeeds on a different subset (19, 20, 21, 29) because for those attacks, the discriminative features useful within the training set happen also to be useful for the held-out attack; for the rest, the feature regions occupied by the held-out attack do not coincide with those of any training attack. Under the LSTM-Autoencoder’s much weaker assumption (“attack rows are unlike anything I saw during normal-only training”), the per-attack distribution of detectability is simply that of attacks-as-physical-events rather than attacks-as-similar-to-other-attacks.
The mean-and-standard-deviation summary collapses this bimodality and is therefore misleading on its own: a mean AUROC of
for the LSTM-Autoencoder hides the fact that more than one third of the attacks are detected with AUROC values above
. We argue in
Section 7 that the proper figure of merit for an unseen-attack protocol is the per-attack detectability map of
Table 6 rather than its mean.
6.3. Ensemble Combination of Heterogeneous Members
The XGBoost and LSTM-Autoencoder per-attack distributions in
Table 6 are nearly disjoint: XGBoost achieves above-chance AUROC values on attacks 19, 20, 21 and 29, while the LSTM-Autoencoder achieves AUROC values above
on attacks 8, 15, 23, 25, 26, 28 and 29; their detectable-attack sets intersect on attack 29 alone. The Bi-LSTM and TCN, like the supervised XGBoost, both score below random on the majority of folds (mean LOO AUROC values of
and
, respectively), but their per-attack rankings are decorrelated from each other and from XGBoost. The combination of four nearly orthogonal but individually weak rankers is precisely the situation in which simple ensemble rules can produce a substantially stronger detector—though, as we show below, only the oracle-bound sign-adjusted variant actually does so.
We implement and release three combination rules over the per-row attack probabilities of the base models, which are computed from the predictions cached in each fold’s predictions.npz file. Average is the simple per-attack mean of member probabilities. Maximum (OR rule) represents the elementwise per-attack maximum. The sign-adjusted average is used for each held-out attack when members whose per-attack AUROC value is below are flipped before averaging; this uses the held-out labels only to diagnose inversion rather than to choose an operating point. The sign-adjusted rule represents an upper bound on what a fully label-aware meta-learner could achieve over the same base predictions. Implementation is at scripts/loo_ensemble.py in the public repository.
Quantitative ensemble results are reported in
Table 8. The simple average and maximum rules are slightly worse than the LSTM-Autoencoder solo, because they are diluted by the two near-inverted supervised members. The sign-adjusted average, by contrast, achieves a mean LOO AUROC value of
(
) across the 16 folds, recovering signals from members whose unflipped predictions would be discarded as the wrong direction. The per-attack ensemble values in the rightmost column of
Table 6 cross the
heuristic on 14 of 16 folds; the two folds below this threshold are attacks 19 (
) and 29 (
), both of which are nonetheless above
.
6.3.1. Oracle Bound
The sign-adjusted rule consults the held-out labels to compute each member’s per-attack AUROC, against which sign is flipped. The rule uses the labels only to determine the
direction per held-out attack; it does not use them to fit a threshold, weight, or operating point. The reported
is therefore best read as an
oracle bound: the per-row probabilities of the three base members, if combined with one bit of attack-level direction information per fold, retain enough discriminative signal to detect the held-out attack in 14 of 16 cases at an AUROC of ≥0.7. In contrast, the simple-average and maximum rules in
Table 8 are deployable (they consult no labels), and on this dataset, both are
worse than the LSTM-Autoencoder solo, because the supervised members systematically point in the wrong direction on most novel attacks and dilute the autoencoder’s signal.
6.3.2. Does TCN Help the Ensemble?
The four-member rows in
Table 8 add the TCN of
Section 4.5 as a fourth base member. All three combination rules degrade slightly relative to the three-member configuration: simple average
, maximum
, and sign-adjusted
. The TCN’s per-attack AUROC distribution is itself below random everywhere (mean
,
), so it adds another inverted member that the simple/max rules dilute and the sign-adjusted rule must flip but then weights at
rather than
. We therefore retain the three-member configuration as the headline ensemble result, and we read the small four-member regression as evidence that simply enlarging the supervised-classifier pool does not help under unseen-attack evaluation: what is needed is an additional
detection-mode (unsupervised reconstruction, graph-relational scoring, deployable sign estimation) rather than another classifier of the same family. This is consistent with the empirical pattern in the Transformer/GNN IDS literature reviewed in
Section 2.5.
6.3.3. Approximating Sign-Adjustment Without Labels
A practical detector that approximates the per-attack direction from the training-only signal is the natural follow-up. We sketch three concrete options for future work, none of which we evaluate here: (i) signature clustering: at training time, cluster training attacks by feature-space fingerprint (e.g., Modbus function-code histogram and source-address signature); at inference time, they route each suspect window to the nearest cluster and apply that cluster’s known per-model sign pattern; (ii) few-shot calibration: in deployment, allow an operator to label a small handful of windows during the incident response and use those labels to set per-attack member directions; (iii) meta-learning the sign: train a separate meta-classifier on validation predictions of the training attacks to predict the inversion sign of each base member from features of the input window; then, apply that meta-classifier at inference. Each of these is itself a contribution-sized open problem beyond the scope of this protocol-focused paper.
6.3.4. Statistical Significance of the Comparisons
Paired Wilcoxon signed-rank tests across the LOO folds give the following: LSTM-Autoencoder > XGBoost (, median ), LSTM-Autoencoder > Bi-LSTM (, median ), XGBoost > Bi-LSTM marginal (). The sign-adjusted ensemble strictly dominates every solo model: vs. XGBoost (, median ), vs. LSTM-AE (, median ), and vs. Bi-LSTM (, median ). The bootstrap confidence intervals on mean LOO AUROC values (10,000 resamples of the 16 folds with replacement) follow: XGBoost , LSTM-Autoencoder , Bi-LSTM , sign-adjusted ensemble . The CIs for the three solo models overlap pairwise, which is consistent with the marginal XGBoost-vs-Bi-LSTM p-value; the ensemble CI does not overlap any solo CI.
7. Discussion
7.1. Why Supervised Models Score Below Random on Unseen Attacks
The fact that supervised models which fit the training data near-perfectly (training AUROC of in every fold) produce test AUROC values well below on the majority of held-out attacks is, at first glance, surprising. We argue that this is not pathology but the expected consequence of supervised learning under a strict label distribution shift.
Each SWaT attack is a single event with a particular signature in the network-traffic feature space: a small set of source/destination addresses, a particular Modbus function-code and value pattern, and a characteristic temporal profile. A classifier trained on attacks learns a decision boundary that separates these specific signatures from the normal background. When evaluated on the held-out attack , two outcomes are possible. If ’s signature lies in the same feature region as one of the training attacks, the model generalises and the AUROC value is close to 1. If ’s signature lies in a different region—typical when the attack targets a different stage, a different actuator, or uses a different injection technique—the model has no positive evidence in that region, and its prediction is dominated by whatever the local noise pattern happens to look like to the trained boundary. In our experiments, that local noise pattern systematically resembles normal traffic from the training set, so the model rates the held-out attack rows as more normal-like than the actually normal rows, producing AUROC values well below .
The result is a model that is highly confidently wrong. This is qualitatively different from a model that is uncertain (AUROC near
): the inversion is informative, in the sense that flipping the prediction would yield AUROC values near
. We exploit this property in the sign-adjusted ensemble of
Section 6.3.
Empirical Evidence: XGBoost Feature Gains
Figure 5 reports the top-20 features by gain for the XGBoost model trained on the 30-file multi-window cache under attack-held-out. The four highest-gain features are the cyclic time encodings (
hour_sin,
hour_cos,
day_of_week_sin,
day_of_week_cos). Because the SWaT attack catalogue places each attack at a particular wall-clock time, the classifier learns time-of-day as a strong proxy for “attack present”. When LOO holds out an attack whose execution time lies outside the training-time distribution, this proxy fails by construction: the model has learned to score the held-out attack’s time-of-day as
normal even though the underlying attack-vector features are present. The dominance of time features in
Figure 5 is therefore both empirical evidence for the signature-memorisation argument above and a direct critique of any SWaT IDS evaluation that does not control for attack-timing leakage.
7.2. Why the LSTM-Autoencoder Is Bimodal
The per-attack distribution of the LSTM-Autoencoder AUROC values in
Table 6 contains nine attacks above
(six above
) and seven attacks below
(three below
). The split tracks the type of attack rather than its identity. Attacks that produce large physical excursions—a sensor reading driven outside its operating band, an actuator command issued out-of-sequence, or a Modbus function code outside the normal vocabulary—are detected reliably because their reconstruction error sits in the upper tail of the all-normal validation distribution. Attacks that interpolate inside the normal envelope—replay attacks, slow drift attacks, attacks that spoof a sensor toward a value within its normal range—are not detectable by reconstruction; the autoencoder reconstructs them as well as any normal sequence, by definition.
This is not a defect of the LSTM-Autoencoder architecture. It is a fundamental limit on what reconstruction-based anomaly detection can do irrespective of model capacity. Detecting in-envelope attacks requires either a positive label signal (which supervised methods exploit) or a model of the legitimate command sequence (e.g., a learnt grammar of allowed Modbus exchanges) that an autoencoder does not directly possess.
7.3. Threshold Tuning Is a First-Class Concern
The reported AUROC numbers are threshold-independent. In deployment, an IDS must commit to a threshold, which converts probabilities to alerts. The LSTM-Autoencoder achieves an AUROC of
on the most detectable attacks but, at the threshold equal to the 95
th percentile of normal-only validation reconstruction error, it only catches a fraction of those attack rows—the per-attack
best- recall (a threshold-tuned operating point) is uniformly higher than the recall at the default threshold. Any honest reporting of IDS deployment readiness should therefore include both the threshold-independent ranking quality and an explicit operating-point analysis. We follow [
25] in reporting both and recommend it as a standard.
7.4. Implications for Practitioners and Evaluators
Three concrete recommendations follow. For evaluators, report attack-held-out, or preferably leave-one-attack-out, alongside any random-split number on SWaT. The per-attack detectability map is more informative than any aggregate, particularly under bimodal distributions. For model designers, unsupervised reconstruction methods generalise better to unseen attack types than supervised classifiers, but the converse holds for in-envelope attacks; an ensemble that combines both is strictly more useful than either alone. For dataset curators, the fact that one quarter of the SWaT attacks are essentially undetectable by either family of models in our experiments suggests that the attack inventory itself is a meaningful axis of detector evaluation. Future ICS testbeds would benefit from attack catalogues that explicitly span the in-envelope versus out-of-envelope axis.
8. Conclusions, Limitations and Future Work
We revisited supervised and unsupervised machine-learning intrusion detection on the network-traffic modality of the SWaT dataset, extending a prior conference paper that reported strong AUROC under random stratified splits. Under stricter evaluation protocols—attack-held-out and leave-one-attack-out—the supervised XGBoost classifier drops from an AUROC of under random splits to a mean LOO AUROC of with per-attack AUROC below on the majority of held-out attacks. The unsupervised LSTM-Autoencoder retains the best solo mean LOO AUROC of across the 16 held-out attacks but exhibits a strongly bimodal per-attack distribution: it detects attacks that produce large physical excursions and misses attacks that interpolate inside the normal operating envelope. The two other supervised baselines score below random on the majority of folds (Bi-LSTM ; TCN ). The models’ detectable-attack sets are nearly disjoint, and a three-member sign-adjusted oracle-bound ensemble flips per-fold members whose AUROC inverts achieve a mean LOO AUROC of () with per-attack AUROC values at or above on 14 of the 16 folds. Adding the TCN as a fourth ensemble member does not improve the result, which is evidence that the unseen-attack regime requires additional detection modes rather than additional supervised classifiers. We additionally report recall at a fixed FPR alongside threshold-independent AUROC, paired Wilcoxon significance tests, and bootstrap confidence intervals; the threshold-tuned and FPR-bounded recall are low across the board for every solo model.
This paper has clear limitations that we list explicitly so that the reader can correctly weight the conclusions.
Our experiments operate on 15- and 30-file subsamples drawn diversely from the 737-file SWaT A6 corpus. The 30-file sample contains 17 of the 36 SWaT attack identifiers; the remaining attacks are not evaluated. The full dataset is approximately 100 GB and exceeds the in-memory budget of the streaming-free pipeline used here; a streaming loader (XGBoost ExtMemQuantileDMatrix and PyTorch IterableDataset over Parquet) is the principal item of future work and would unlock evaluation on all 737 files and all 36 attack identifiers.
We work exclusively on SWaT network-traffic data. The physical-process modality, where rigorous unsupervised work is well established [
25,
26,
27], is not evaluated here. A cross-modality study—training on network features, validating on process features, or training a fused model—would be a natural extension and would address the question of whether physical excursions detectable in process readings are predictable from contemporaneous network traffic.
SWaT is a single physical implementation of one water-treatment process. A model that performs well on SWaT need not generalise to a different plant; conversely, our protocol-gap finding would carry more weight if reproduced on the EPIC, MSU WADI or HAI testbeds. We have not yet performed this work; it would be the natural follow-up paper.
The Bi-LSTM run encountered out-of-memory pressure during preliminary trials at
batch_size on the 30-file leave-one-attack-out configuration; the results reported in
Table 6 were obtained at
batch_size to fit the container’s 62 GB cgroup cap. The streaming data loader (above) would also remove this constraint and is part of the same future work.
The
StandardScaler is fit once on the union of all selected files before splitting (
Section 3.2), so per-feature mean and standard deviation incorporate rows that subsequently become validation or test partitions. This is a known but limited form of leakage; we expect its practical impact to be small because the statistics are univariate and are dominated by the abundant normal-traffic rows that are present in every partition. A leakage-aware variant that re-fits the scaler on each fold’s training partition is straightforward but requires the streaming loader.
SWaT produces traffic from a controlled, scaled-down plant with a small fixed inventory of supervisory workstations and PLCs. Real-world utility networks include richer benign-traffic populations (engineering workstations, vendor remote access, monitoring agents, third-party telemetry), and statistical analyses of operational ICS captures consistently report distributional differences relative to testbed datasets. An unsupervised reconstruction-based detector tuned on SWaT normals would, in deployment, almost certainly experience higher false-positive rates from this richer benign distribution; conversely, a supervised classifier may fail to flag novel benign anomalies as “normal”. The narrowness of SWaT’s benign distribution should be considered when transferring numbers from this paper to operational settings.
The LSTM-Autoencoder fails on attacks that interpolate inside the normal operating envelope (
Section 6.2). Reconstruction-based detection is fundamentally limited here. Approaches that explicitly model inter-sensor or inter-flow relationships—the Graph Deviation Network [
27] learns a directed graph over sensors and scores deviations with respect to predicted neighbour behaviour—are a promising complementary direction for SWaT and a natural follow-up.
The headline ensemble result (mean LOO AUROC
) is an oracle bound: it consults the held-out labels to decide which members to flip per fold. A deployable approximation that estimates the per-attack sign from training-time signal alone (
Section 6.3, options (i)–(iii)) is the principal modelling follow-up. Signature-clustering and few-shot calibration would be most readily integrated with the current pipeline; meta-learning the sign with a small auxiliary classifier requires additional held-out validation data not present in the 30-file cache.
All experiments here are offline: models train once on a fixed sample and are evaluated on disjoint attacks. Practical ICS IDSs must adapt to drift in benign traffic over weeks and months, and ideally, it ought to incorporate operator-confirmed labels as they accrue. Continual-learning approaches for IDSs (e.g., Cassales et al., reviewed in recent surveys) are a separate axis of follow-up and would interact non-trivially with the LOO evaluation framework introduced here.
We report training and inference timings in
Section 5; we do not report end-to-end alert latency on a streaming source. A streaming evaluation harness against a captured SWaT A6 PCAP would complete the deployment-realism picture and is part of the same future engineering item as full-737-file LOO.
The principal methodological recommendation that follows is to report attack-held-out or leave-one-attack-out evaluation as standard for SWaT network-traffic IDS work alongside the per-attack detectability breakdown and at least one operating-point claim (e.g., recall at a specified false-positive-rate budget). The principal modelling recommendation is that no single supervised model family detects every attack class on this testbed under unseen-attack evaluation, and an honest IDS pipeline should combine reconstruction-based and signature-based detectors with explicit per-attack sign awareness. We release the full preprocessing, evaluation, and ensemble pipeline to support reproduction and extension.