Counting the Background by Keys, Not Records: Drift-Robust Anomaly Selection in Heavy-Tailed Streams

Many anomaly detectors adapt to a changing world with the same trick. They assume most of what they see right now is normal, so they re-estimate "normal" from recent data and flag whatever sits far from it. In network traffic this assumption breaks in a specific way. Traffic is heavy-tailed: a handful of high-volume sources ("elephant flows") produce most of the records, and a very long tail of small sources ("mice flows") produces the rest. When one elephant is an attack flood, or when a benign service suddenly surges, it can make up most of a batch of records even though it is a single source. The adaptive detector then learns that the flood is normal, or it flags a whole legitimate service as anomalous. We propose to count the background by distinct traffic keys instead of by records. Elephants, which are few, each get their own tracked baseline. The long tail of mice shares one pooled baseline in which every key has equal weight. A new elephant earns its own baseline only after a short sequential test against the pooled tail.

The measure of success is practical. At a fixed budget of records the detector may flag per time window, which mirrors the fixed bandwidth of a physics trigger, the detector should flag more distinct anomalous sources. It should also stay above chance across the ten years of real traffic drift in the AnoShift benchmark. That is the regime where static detectors fall below chance and where the strongest zero-shot method fails whenever anomalies make up more than half of a batch.

Core Claim

The claim is narrow and testable. Test-time re-centering, meaning re-estimating the normal reference from incoming data, fails on heavy-tailed streams because its "normal majority" assumption is counted in records. The same assumption counted in keys holds much more often. A two-tier reference turns this into a working detector. Elephants are compared against their own decayed history. Mice are compared against a key-weighted, outlier-clipped running estimate. Admission to the elephant tier is gated by a sequential test. We predict this detector breaks down only when anomalous keys, not anomalous records, exceed half the tail. It can also score single records at line rate, because it keeps running statistics instead of normalizing whole batches.

The motivating evidence comes from three papers. AnoShift built a ten-year benchmark from Kyoto University honeypot traffic, split into IID (2006–2010), NEAR (2011–2013) and FAR (2014–2015) periods. It showed that normal traffic drifts faster than attacks, and that a 2014 "DNS cliff" moved DNS from 4% to 37% of volume. That surge is exactly a heavy benign key that record-level re-centering mishandles. Zero-Shot Anomaly Detection via Batch Normalization introduced ACR (Adaptive Centered Representations), which applies batch normalization at inference so that the normal majority of each batch is centered at the origin. It was the only zero-shot method reported to beat chance on AnoShift's extreme shifts. Its own authors state that it fails completely above 50% contamination and cannot score an isolated sample. We keep ACR's centering idea and change the unit of the majority. Online Heavy-tailed Change-point detection showed that classical likelihood-ratio detectors mistake Pareto tail values for real shifts, and that clipped stochastic gradient updates fix this with finite-sample false-positive control. We reuse its clipping for the pooled tail estimate. That paper monitors an undifferentiated mean and makes no selection decisions, whereas our target is discriminating signal from background under a budget.

Research Program

The system has three parts. The first is a small sketch, meaning a fixed-memory approximate counter. A count-min sketch with exponential decay estimates each key's recent count $\hat c_t(k)$. A heavy-hitter table holds the current elephants, in the spirit of Optimal Elephant Flow Detection. A key is a hash of the source identifier where the dataset provides one. Otherwise it is the service type combined with coarse bins of the flow features.

The second part is the pooled tail reference. For a record $x_t$ with key $k$ and feature embedding $\phi(x_t)$, the running center is updated as

$$\mu_t = \mu_{t-1} + \eta\, \frac{1}{\hat c_t(k)}\, \mathrm{clip}_\tau\big(\phi(x_t) - \mu_{t-1}\big).$$

Here $\eta$ is a step size, $1/\hat c_t(k)$ gives each key roughly equal total weight regardless of volume, and $\mathrm{clip}_\tau$ caps the update at norm $\tau$, following the heavy-tailed change-point work. A matching clipped estimate tracks per-dimension scale. The anomaly score is the scaled distance of $\phi(x_t)$ from the reference its key is assigned to.

The third part is the admission rule. When a key crosses the heavy-hitter threshold, it is first scored against the pooled tail. A sequential thresholding test decides whether to promote it to its own baseline or to quarantine it as a single flagged source. The test resembles the procedures in The Sample Complexity of Search over Multiple Populations, which need only the background distribution. A quarantined elephant is flagged once and then heavily down-sampled, so a flood cannot use up the flag budget.

Selection works like a trigger. The threshold is adjusted each window to keep flagged records at a budget $B$, borrowing the rate-budget framing of Learning to Trigger. The embedding $\phi$ is taken from a frozen detector: the AnoShift masked-language-model encoder, or the meta-trained ACR network. This isolates the adaptation rule from representation learning.

The analysis part asks a factual question we cannot answer from the file. On Kyoto-2006+, what is the anomalous fraction among distinct keys, compared with the reported record-level ratio of about 89%? If attacks are spread over many small keys, record- and key-level contamination are similar and the proposal loses most of its advantage. We will measure this first and report it whichever way it comes out.

Baselines

The naive reference is a static detector fit on the IID period. Local Outlier Factor is reported at a ROC-AUC (area under the ROC curve, higher is better) of 91.50 on IID falling to 34.96 on FAR, per AnoShift. We will rerun it under our streaming protocol so that the budgeted metrics are comparable.

The strongest existing method for zero-shot drift robustness on this benchmark is ACR. The file gives no numeric AnoShift ROC-AUC for it, only that it alone beat chance under extreme shift, so no reported result was found on Lacuna for ACR's AnoShift ROC-AUC. We will run the released method on the identical chronological stream at batch sizes matched to our window. It gets the same frozen backbone and the same hyperparameter search budget, tuned on 2006–2010 only.

The strongest non-zero-shot competitor is the AnoShift BERT masked-language model with knowledge distillation. It reached 86.05 ROC-AUC on NEAR, and distillation added about 3% on average over standard retraining. It will be retrained on the same schedule the benchmark prescribes.

For rate control, a PID controller (a standard feedback loop that adjusts the threshold from the observed flag-rate error) will be used on the same scores. The rate-control comparison with GFPO is optional. The file gives no reported number for GFPO on UNSW-NB15, so no reported result was found on Lacuna for GFPO on UNSW-NB15.

Three ablations isolate the key ingredient: record-weighted clipping without key weights, key weighting without the elephant tier, and the elephant tier without the admission test. Beating the baselines means two things. First, higher ROC-AUC than ACR on FAR, with a paired bootstrap confidence interval that excludes zero. Second, more distinct anomalous keys captured at every tested budget $B$, while flagged-record counts stay within 10% of $B$.

Why not just…?

Why not just make ACR robust with a median or trimmed mean instead of batch means? This is the most serious alternative. It changes a single line of ACR, and robust record-level statistics still have a 50% breakdown point counted in records. If contamination is spread across keys, it may match our method, and the key-level contamination measurement above will reveal this. We include "ACR with a coordinate-wise median" as a baseline. If it matches us on AnoShift, the claim survives only in the synthetic single-flood regime, and we will say so.

Why not just down-sample heavy hitters first, as Mahmood et al. did, and feed any detector? A scalable sampling scheme for clustering in network traffic analysis captured up to four times as many rare attack types by down-sampling known heavy clusters. Its definition of "known" is static, and it never asks whether a new elephant is benign. We run exactly this pipeline, static heavy-hitter down-sampling followed by ACR, as an ablation. On the DNS cliff it should either miss the surge or suppress a benign service, and the per-period results will show which.

Why not just retrain on a sliding window? Retraining adapts to whatever dominates the window, which is the flood problem again, only slower. AnoShift reports that naive fine-tuning forgets recurring patterns and needed distillation to gain about 3%. We include windowed retraining at equal compute.

Proposed Experiments

The first testbed is AnoShift, streamed in chronological order with windows of fixed wall-clock length. We report ROC-AUC per split and per year, distinct anomalous keys captured at budget $B$, and flag-rate deviation from $B$.

The second is a controlled synthetic stream built on the Pareto change-point suite from Online Heavy-tailed Change-point detection. We plant anomalies in two ways. In the single-key flood setting, one key carries 30% to 90% of records. In the diffuse setting, many small keys carry the same total mass.

The decisive check is the location of the breakdown in that sweep. If our prediction is right, ACR collapses near 50% record contamination in the flood setting and our method does not. In the diffuse setting both should degrade together near 50% key contamination. If our method fails in the flood setting, or the median-ACR baseline also survives the flood, the core claim is wrong.

A second check is the 2014 DNS cliff. We will track the false-flag rate on DNS keys through 2014. The admission test should promote DNS to its own baseline within a bounded number of windows, while record-level methods either absorb it into the center or flag it persistently.

UNSW-NB15, which has flow-level records, serves as a replication. The CMS trigger data is left out because collision events have no source-key structure. The method's premise does not apply there, and we will state this as a scope limit.