Catching Cloud-Native Cyber Attacks with Graphs in Real Time
A container that starts mining cryptocurrency looks, from the outside, much like a container doing its job: it runs processes, opens files and talks to the network. What gives the attack away is the shape of that activity: which process started which, what it touched, and in what order. At Cisco I worked on detecting attacks in cloud-native applications by turning system activity into graphs and classifying the graphs. That code became the basis of an ICDE 2025 paper with Tailai Song, whom I supervised during a PhD internship at Cisco, and colleagues from Cisco and Politecnico di Torino. A related patent application, with Lennart Gulikers and me as co-inventors, covers the real-time side.
This post walks through the whole system: why containers are hard to defend, how system calls become graphs, the features and embeddings we built, how they compared with eight deep learning models, what the evaluation does and does not prove, and how the pieces run in real time.
In short
- Attacks on containers unfold in stages and leave traces in system activity. Written as triplets such as process → read → file, that activity forms one graph per time window, and attacks show up as shapes.
- We turned each 500 ms graph into 2,895 hand-built features at five levels, kept 82, and trained XGBoost. Against eight deep models it tied for the best macro recall (0.57) and was the only one above 0.5 recall on ransomware; the best graph neural networks had higher precision and F1.
- With one attack type withheld from training, at most 41 per cent of its graphs were called benign; the rest were still flagged as some attack.
- The dataset is small and emulated, and the splits were random over windows, so treat the numbers as a direction. Grouping splits by attack run is the first thing I would change.
- Real time needs more than a fast model: compact telemetry, short windows, separate training and serving, and a check that predictions stay stable across consecutive windows.
Why cloud-native attacks are hard to see
A cloud-native application runs as containers that Kubernetes starts, moves and stops all day. That is good for scaling and bad for the defender. Containers share the host kernel, so a container escape can reach everything on the node. Images ship with vulnerable packages. A misconfigured cluster lets an attacker who reaches one pod deploy new ones. Signatures of known malware catch little of this, because attackers mostly use tools already in the image: bash, curl, nc, kubectl.
The defender's advantage is that attacks take time. MITRE ATT&CK organises them into tactics, from initial access through discovery to impact, and keeps a matrix of techniques seen against containers. Each stage leaves traces in system calls, files and connections. We emulated four attacks against OWASP Juice Shop, an intentionally vulnerable web shop, running in Kubernetes. All four begin the same way, which is part of what makes them hard to tell apart:
| Stage | What the attacker did | Closest ATT&CK technique |
|---|---|---|
| Initial access | Exploit a Juice Shop vulnerability | T1190 Exploit Public-Facing Application |
| Discovery | env, pwd, netstat, find, ls | T1083 File and Directory Discovery, and related |
| Privilege escalation (some runs) | Deploy pods with kubectl and continue inside them | T1610 Deploy Container |
| Impact: crypto-jacking | Download and run a miner such as XMRig | T1496 Resource Hijacking |
| Impact: data destruction | Delete data | T1485 Data Destruction |
| Impact: data exfiltration | Compress data and send it out, for example with nc | T1048 Exfiltration Over Alternative Protocol |
| Impact: ransomware | Encrypt data | T1486 Data Encrypted for Impact |
Initial access, container deployment, resource hijacking and data destruction appear in ATT&CK's containers matrix; the discovery, exfiltration and encryption techniques come from the wider Enterprise matrix. Steps and targeted data varied between runs, so a model could not memorise one script. Automated browsing produced ordinary shop traffic as benign background, the "noise" class in the paper.
Four ways to catch an attack
Security teams already have three families of tools, and each fails in a known way. Supervised graph classification is a fourth, with failures of its own:
| Approach | How it decides | Where it breaks |
|---|---|---|
| Rules and signatures | Match known patterns, such as a Falco rule for a shell in a container | Misses new techniques and floods analysts with duplicate alerts |
| Anomaly detection | Flag what differs from normal behaviour | Unusual is not malicious, and normal behaviour drifts between training and use |
| Threat hunting | An analyst writes and refines queries over recorded activity | Flexible but manual, and too slow for a decision every second |
| Supervised graph classification | Learn the shapes of known attacks from labelled examples | Needs labelled attacks, and is only as good as their variety |
The anomaly row comes with evidence. Writing about a DARPA detection competition in 2017, IBM researchers reported that anomaly detection "mechanisms were limited due to the lack of training data and the variance of user behaviors between training and detection periods". Supervised learning answers that by emulating attacks to get labels, which is why our dataset, and its limits, matter so much later on.
From system calls to graphs
Raw system calls are too many to store or analyse: on a MySQL benchmark, IBM Research counted 156 million system call records. SysFlow, an open telemetry format whose collector is built on Falco's libraries, describes itself as "NetFlow for system events". It folds many calls into one flow record: a process, what it touched, how much it read or wrote, and when. The same MySQL workload produced 189 SysFlow records. Falco, a CNCF graduated project, applies rules to the same kernel events and raises alerts with context such as the container. SysFlow can also tag records with ATT&CK techniques: on a Kubernetes cluster with 12 worker nodes, over 100 minutes, its rate modulation cut such alerts from 108,546 to 2,853, which matters to anyone who has to read them.
Each record is a relation between two system objects, so we wrote it as a triplet, from_node → relation → to_node, with a timestamp. Nodes are one of 10 types, such as process, file and path. Edges are one of 17 relation types, such as create, open and update. Because SysFlow follows a process from start to exit, the object at the end of one triplet starts the next, and the triplets link into a graph. We cut each activity into consecutive 500 ms windows and built one directed graph per window, with 91 triplets on average. Every window inherits the label of the activity it came from.
Windows bring two benefits. A detector can answer every half second instead of waiting for an attack to finish, and graphs stay small enough to keep features cheap. The cost is the labelling assumption: a window from an attack run may contain only ordinary-looking steps and still carry the attack label.
Graphs as patterns of attack
Treating security data as a graph is an old and productive idea. Threat Intelligence Computing, from IBM Research at CCS 2018, modelled a system's whole history as a computation graph of entities and events. In that view, threat discovery "reduces to the graph query problem of iteratively computing the closure over the subset of security-relevant subgraphs". Hunters wrote patterns as graph queries; one example flags a data leak when "an entity labeled with SENSITIVE connects to an entity labeled NETFLOW within 10 hops". In the DARPA competition, a detector of a few lines flagged 17 DLL injections across two weeks of data, before any benign ones were whitelisted; the red team credited three as part of its attack.
A pattern like that is knowledge, and knowledge graphs are how security teams store it. Two kinds meet in a detector:
| Aspect | Knowledge about threats | Knowledge about your system |
|---|---|---|
| Examples | Actors, malware, vulnerabilities, ATT&CK techniques | Processes, files, sockets, pods and how they interacted |
| Built from | Reports and advisories, often by text extraction | Telemetry such as SysFlow, Falco and OCSF events |
| Changes | Over days and weeks | Every second |
| Answers | What to look for | Where to look, and whether it happened |
Both use the same unit, the triplet of head, relation and tail, and both can be embedded. Knowledge graph embeddings learn vectors so that head plus relation lands near the tail, which TransE writes as h + r ≈ t; they are built to complete missing facts. Our task was different: label a whole small graph as benign or one of four attacks. That is graph classification, and it leaves two routes: hand-built features fed to a classic model, or a graph neural network (GNN) that learns its own features. We used both, in two stages.
Building the dataset
For the paper we recorded several runs of each attack type, with varied steps and targets, alongside separate benign runs. The result is small and imbalanced, as attack data usually is:
In production, attacks never arrive alone: they run inside a busy cluster. The patent application describes how to train for that. An orchestrator deploys the application, a workload generator drives it, and a threat injector replays a list of attack steps, each tagged with its technique ID, with and without background load. Recorded background activity is then split into small "building blocks" and mixed into attack graphs, either inserted or replacing existing facts. Entity names are relabelled to avoid collisions, timestamps are reset, and the connecting facts are sampled from how often each relation appears in real data, because not every fact is plausible: the patent's example is that "process-findings-process" may be valid, but "file-parent_of-cluster" may not.
The training set then holds three kinds of example: pure attack, attack mixed with background in varying proportions, and pure background. The modelling assumption is stated plainly: an attack "can, in principle, be 'mixed' with any kind of background activity that has ever been recorded". Mixing multiplies scarce attack data cheaply and teaches the model that the attack, not the noise around it, is the signal.
Feature engineering in five levels
We started with hand-built features for four reasons, set out in the paper. Deep models are costly to retrain, and attack data changes often. Inference must be fast enough to act on. Analysts need to see why a window was flagged. And a classic model deploys with standard MLOps tools: XGBoost runs on KServe without a custom container.
- Node level. Count and share of each node type as source, target and overall; degrees, centrality and clustering per type; and keywords attackers leave in node descriptions:
bash,xmrig,busybox,tmp. A process creating a directory under/tmpis rare in a web shop. - Edge level. Count and share of each of the 17 relation types, and relation types next to keyword nodes.
- Triplet level. Counts of each combination of source type, relation and target type. Attackers follow steps that benign traffic rarely repeats, so specific triplets are strong evidence.
- Graph level. Ten features from the spectrum of the graph Laplacian: largest eigenvalue, sum, mean and variance of eigenvalues, spectral gap and radius, graph energy, Laplacian energy, rank and nullity.
- Subgraph level. Processes in a window hang off a shared cluster node. Splitting there gives separate process subgraphs, whose sizes and type frequencies we summarise.
That gave 2,895 features per graph. Dropping constant, low-variance and highly correlated ones left 82, and only those 82 need computing in production. The spectral features are less exotic than they sound:
import networkx as nx
import numpy as np
def window_graph(triplets):
"""One directed graph per time window: nodes are system objects, edges are relations."""
g = nx.MultiDiGraph()
for src, rel, dst in triplets:
g.add_edge(src, dst, relation=rel)
return g
def spectral_features(g):
"""Laplacian spectrum of the undirected skeleton: shape, not names."""
u = nx.Graph(g.to_undirected())
lam = np.sort(np.linalg.eigvalsh(nx.laplacian_matrix(u).toarray().astype(float)))
avg_degree = 2 * u.number_of_edges() / u.number_of_nodes()
return {
"largest_eigenvalue": lam[-1],
"spectral_gap": lam[1] - lam[0], # 0 if the graph is disconnected
"laplacian_energy": np.abs(lam - avg_degree).sum(),
"rank": int((lam > 1e-9).sum()),
"nullity": int((lam <= 1e-9).sum()), # number of connected components
}
window = [
("process:web", "connect", "net:198.51.100.7"),
("process:web", "write", "file:/tmp/x.py"),
("process:web", "clone", "process:python"),
("process:python", "read", "file:customers.db"),
("process:python", "connect", "net:203.0.113.9"),
("process:python", "runs_in", "container:shop"),
]
for name, value in spectral_features(window_graph(window)).items():
print(f"{name:20s} {value:.3f}" if isinstance(value, float) else f"{name:20s} {value}")
Run on two invented windows of the same size, the spectrum separates what simple counts cannot:
The benign window is a star: one process does everything, and its largest eigenvalue equals the number of nodes. The attack window hands work to a child process through a single clone edge. The spectral gap, which measures how well a graph holds together, drops from 1.00 to 0.40 because that edge is a bottleneck. Real windows are larger and messier, but the intuition holds: the spectrum summarises how activity is organised, not just how much of it there is.
The second stage: graph embeddings
Hand-built features see what we thought to count. The pipeline in the patent application adds a learnt view: a graph embedding network, trained in PyTorch, maps each window's graph to one point in Euclidean space. Its encoder and propagation layers compute vectors for nodes and edges, and an aggregator combines them into "a single point in Euclidean space". Those coordinates become topology features next to the hand-built graph features, and XGBoost does the classification. The model "may make the predictions based in part on how close the points are to those associated with a known attack type".
Why embed whole graphs rather than entities? Entity-level embeddings, the kind TransE produces, suit entity tasks such as clustering files or spotting an odd process. The patent lists why they are awkward for whole graphs: they are "not necessarily unique", their total dimension "grows with the graph size", and graphs of different sizes end up with vectors of different sizes. A graph-level embedding has a fixed size, so windows of any size can be compared. The patent describes three ways to get one:
| Method | Idea | Trade-off |
|---|---|---|
| Graph embedding network | Propagate along edges, aggregate into one vector, train on pairs of similar and dissimilar graphs | Learns what matters for the task; needs training and retraining |
| Random graph neural features | Average many randomly parameterised, permutation-invariant functions of the graph; their expected squared difference is a metric between graphs | No training, but blind to the task, so class boundaries can be complex |
| Wasserstein embedding | Compare a graph's entity embeddings with a reference distribution through approximate optimal transport | Fixed size whatever the graph; the patent calls it less natural for these tasks |
We used the first. It is trained on pairs, the Siamese set-up from Li et al. (2019): two graphs pass through the same network with shared weights, and the loss pulls same-class graphs together and pushes different-class graphs apart. Li et al. also propose graph matching networks, which compare two graphs jointly with cross-graph attention and scored higher in their experiments. The patent sets them aside for a practical reason: matching models "cannot directly be used to embed a single graph". At inference time there is one new window and no partner to match it with.
The two views meet in one table. Entity-level features describe each node of a window: its type, its keywords, whether a sensitive path or a miner name appears. Graph-level features are re-engineered from them as the presence and normalised frequency of each entity feature in the window, plus combinations that matter together, such as a path node and a miner keyword in the same window. The embedding adds a few coordinates. XGBoost reads the combined row and returns a probability per class.
The split of work is deliberate. The network learns shape, the trees learn decisions and explain them through feature importance and SHAP values, and each half retrains on its own schedule.
Results against eight deep models
The paper tests the feature route alone, so its numbers isolate what feature engineering buys. Every model saw the same graphs with the same information: one-hot node types, and edge features for relation type, endpoint types and keywords. The deep models were four message-passing GNNs (GAT, GEN, GINE, UniMP), the Graphormer transformer, a graph matching network, FLASH, a GNN built for intrusion detection, and ECAL, built for imbalanced graph classification. We ran five trials with stratified 80/20 splits, weighted classes against the imbalance, and tuned XGBoost with Bayesian optimisation. The spectral baseline is XGBoost trained on the ten spectral features alone.
| Model | Macro recall | Macro precision | Macro F1 | Ransomware recall |
|---|---|---|---|---|
| XGBoost on features | 0.57 | 0.54 | 0.52 | 0.55 |
| GEN | 0.57 | 0.68 | 0.57 | 0.25 |
| UniMP | 0.55 | 0.69 | 0.56 | 0.25 |
| FLASH | 0.52 | 0.62 | 0.52 | 0.30 |
| ECAL | 0.48 | 0.62 | 0.49 | 0.35 |
| Graphormer | 0.49 | 0.58 | 0.48 | 0.15 |
| GAT | 0.47 | 0.56 | 0.47 | 0.30 |
| GINE | 0.45 | 0.48 | 0.43 | 0.00 |
| Graph matching network | 0.43 | 0.47 | 0.43 | 0.05 |
| Spectral baseline | 0.35 | 0.37 | 0.35 | 0.00 |
Read the table as a trade, not a win. The two best GNNs reach a higher F1 and a much higher precision. XGBoost shares the best macro recall, and it is the only model above 0.7 recall on data destruction and above 0.5 on ransomware. In security, a missed attack usually costs more than a second look at a benign window, so recall on the rare, destructive classes matters most. The price is benign recall of 0.61: more benign windows get a second look, which is cheaper than a missed attack but still costs analyst time.
Averages hide where the errors go. One test split shows it:
The paper notes two patterns across models. When unsure, they lean towards crypto-jacking, plausibly because every attack shares its early discovery steps. And in the example splits, no ransomware graph was called benign by any model except the graph matching network. Each test split holds only about four ransomware graphs, which explains XGBoost's standard deviation of 0.24 on that class; treat those numbers as a direction, not a measurement.
Cost was the clearer difference. Deep models trained on a V100 GPU and slowed down as graphs and data grew; XGBoost trained on a CPU in negligible time regardless of graph size. Inference including feature construction was also cheapest for XGBoost. Graphormer, with nearly 50 million parameters, was too slow to include in the timing comparison. For very large graphs the advantage narrows, because Laplacian features get expensive, one more reason to keep windows short.
Attacks the model has never seen
A detector trained on four attacks will meet a fifth. To test this, we retrained XGBoost with one attack type removed each time and looked at where that type's graphs ended up.
At most 41 per cent were called benign; most still landed in some attack class, because they share discovery steps and footprints with the attacks the model knew. Withheld graphs also got lower predicted probabilities than known classes, except for data destruction. The paper proposes a cheap safeguard: send low-confidence windows for a second look, or add a benign-versus-attack model next to the multi-class one and combine several models by vote.
Which features mattered
Instead of reading feature importance, we removed one level at a time and retrained.
Every level contributes. The ten graph-level spectral features are the smallest group and the most important: without them, crypto-jacking and data destruction get confused. Only the run without node-level features called ransomware benign, which points to the keyword features.
What the evaluation does and does not show
The paper argues that much published work reports "deceptively high performance (e.g., 99% accuracy)" on datasets too simple to generalise. Holding ourselves to that standard means listing our own limits:
| Aspect | What we did | What it leaves open |
|---|---|---|
| Splits | Five random, stratified 80/20 splits over windows | Windows from one run can sit in both training and test. Consecutive windows look alike, so scores are probably optimistic; splitting by run, or by time, is the stricter test. |
| Data | One application, emulated attacks with varied steps and targets | Real clusters run many applications, and benign variety drives false positives. |
| Size | 438 graphs, 22 of them ransomware | About four ransomware graphs per test split, hence wide error bars. |
| Labels | Each window inherits its run's label | Quiet windows in attack runs are noisy labels; they cap measured recall and blur training. |
| Unknown attacks | One known type withheld at a time | A truly new campaign may share less with the known ones than our four share with each other. |
None of these overturns the comparison, since all ten models faced the same conditions. They do mean the absolute numbers are not production performance.
Training offline, serving online
The two halves of the system run on different clocks. Training is a batch job: we ran it as a Kubeflow pipeline whose steps load versioned data, preprocess graphs into training, validation and test sets per class, train the GNN embedding model, train XGBoost on the combined features, then evaluate and select the best models. Inference is a stream: telemetry arrives through Kafka, each window becomes a graph, and KServe serves the selected PyTorch embedding model and the classifier for real-time predictions.
Keeping them apart pays off both ways (more on Kubeflow itself in Kubeflow: Production-Grade ML on Kubernetes). Training can use more data, more hyperparameter trials and a GPU when needed, without touching the live path. The live path depends only on small, versioned model artefacts, so deploying a better model needs no code change. And because in real time the system sees only part of an attack, a few windows of it, the models are trained on windows rather than on whole attacks.
Making it real time
A good classifier is one part of a real-time detector. The patent application covers the rest of the loop:
- Telemetry. The knowledge graph is built from collectors already common in Kubernetes: the Falco daemonset, eBPF, Fluent Bit, OpenTelemetry, and the Open Cybersecurity Schema Framework (OCSF) for a common event format, streamed through Kafka.
- Slices. The graph is divided into slices by time frame, and each slice gets a prediction.
- Stability. A prediction counts only if it agrees with its neighbours. The claims assess "a gradient between predictions for neighboring graph slices" and can reject a prediction whose gradient crosses a threshold.
The patent's example of an unstable sequence is 0.15, then 1.0, then 0.0: changes of +0.85 and −1.0, both steep, so the spike is treated as noise. A real attack rises and stays up.
Then comes the threshold that turns a probability into an alert. Setting it is a business decision, because the errors cost different things:
| Error | What it costs | Levers |
|---|---|---|
| Missed attack | Damage continues: data leaves, files are encrypted, the bill grows | A lower threshold; a separate benign-versus-attack model; review of low-confidence windows |
| False alarm | Analyst time and alert fatigue, until real alerts are ignored | The stability check; a higher threshold; deduplication before alerting |
| Wrong attack type | The right alarm with the wrong playbook | Alert on "attack" first, then attach the type with its probability |
The last part is change. Clusters change, services appear, attackers adapt, and models must keep up. Embedding models for whole knowledge graphs struggle here: DKGE, a dynamic knowledge graph embedding method, was built because static models must be retrained on the whole graph after every update. Its online updates were at least 6 and 20 times faster on two benchmarks, and on a 3.2 million entity graph they took about two hours against a week from scratch, though accuracy drifted with repeated updates and a full retrain was still needed from time to time. Classifying short windows avoids most of this: each window is a new small graph, the embedding network handles it in one forward pass, and retraining XGBoost is cheap.
Where deep learning and LLMs fit
None of this argues against deep models. The best GNNs had better precision, and graph embeddings are part of our own design. The argument is about where to start. With a few hundred labelled graphs, strong imbalance and frequent retraining, hand-built features and gradient boosting gave the best recall per unit of cost, and they explain themselves.
Language models already appear in this field. The paper's related work includes BERT applied to malicious Unix shell logs, and sequence models that rebuild attack steps from audit logs. Their natural place is on the other side of the alert: summarising a flagged window for an analyst, mapping it to ATT&CK, or drafting the hunting query that confirms it. They fit poorly in the per-window decision, which must be made every half second on every node.
What I would keep, and change
- Compress before you model. Flow-level telemetry turns millions of calls into far fewer records, and windows of about a hundred triplets keep every later step cheap.
- Count what an analyst would look for. Triplet types, keywords and the Laplacian spectrum carried the signal and remain readable.
- Report recall per class, with spread. Macro averages hid the ransomware story, and four test graphs need their standard deviation shown.
- Split by run, not by window. Consecutive windows are near duplicates. Grouped or time-ordered splits are the honest test, and the first thing I would change.
- Test unseen attacks on purpose. Withholding one class at a time is the cheapest estimate of day one of a new campaign.
- Mix attacks into real background. Training on attack plus noise teaches the model what to ignore.
- Judge a window by its neighbours. One noisy prediction should not wake anyone up.
Tailai Song led the study as first author, building on my code, and is now an Assistant Professor at City University of Hong Kong (Dongguan). The authors are Tailai Song, me, Lennart Gulikers, Giulio Grassi, Giovanna Carofiglio and Michela Meo, from Politecnico di Torino and Cisco.
Sources
- Song et al., Advancing Cloud-Native Cyber Threat Detection with Graph-Based Feature Engineering, ICDE 2025
- The same paper, author's accepted manuscript (Politecnico di Torino)
- US 2025/0310358 A1, Real time inference of attack presence with machine learning (pending)
- Shu et al., Threat Intelligence Computing, CCS 2018
- SysFlow, and Araujo and Taylor, Relational Observability for Cloud-Native Security and Data Science, Open Source Summit North America 2023
- Falco
- MITRE ATT&CK, Containers matrix
- OWASP Juice Shop
- Li et al., Graph Matching Networks for Learning the Similarity of Graph Structured Objects, ICML 2019
- Wu et al., Efficiently Embedding Dynamic Knowledge Graphs
- Chen and Guestrin, XGBoost: A Scalable Tree Boosting System
- Kubeflow