Using NetFlow Anomaly Scoring to Spot Lateral Movement in Hybrid Clouds

Why NetFlow Still Matters in 2026

Hybrid clouds blur the line between on‑prem and public infrastructure. Attackers exploit that blur to hop between VMs, containers, and SaaS services. Host‑based EDR often misses the “between‑the‑hosts” traffic that actually carries the movement. NetFlow, the de‑facto flow‑recording protocol, is still a low‑overhead way to see that traffic. By applying anomaly scoring to NetFlow data you can surface suspicious lateral movement before it reaches its target.


1. Setting the Stage: What Is NetFlow Anomaly Scoring?

NetFlow (and its successors, IPFIX, sFlow) records flows: source IP, destination IP, ports, protocol, byte and packet counts, timestamps. Anomaly scoring gives each flow a numeric score based on how much it deviates from a learned baseline. The baseline is built from normal traffic patterns—volume, direction, protocol mix, and even time‑of‑day.

In 2026, most vendors expose NetFlow data via APIs or push it to SIEMs. Open‑source tools like nfdump and ntopng can ingest raw NetFlow and expose a REST API for scoring. The key is to keep the model lightweight enough to run on a single VM while still catching the subtle signatures of lateral movement.


2. Building a Baseline in a Hybrid Cloud

2.1 Collecting Flow Data

  1. On‑prem routers/switches – Enable NetFlow v9 or IPFIX on all core devices.
  2. Public cloud – Use the cloud provider’s flow logs (e.g., AWS VPC Flow Logs, Azure Network Watcher). Convert them to NetFlow format with a small script.
  3. Container runtimes – Export eBPF‑based flow records from the host kernel (e.g., bcc’s trace_tcp).
# Example: Convert AWS VPC Flow Logs to NetFlow using a Python script
python convert_vpc_to_netflow.py --input logs/2026-11-01/ --output netflow/

2.2 Normalizing and Storing

Store flows in a time‑series database (InfluxDB, TimescaleDB) with a retention policy of 30 days. Keep a separate “baseline” table that aggregates daily averages per source/destination pair.

2.3 Learning Phase

Run the scoring engine for 14 days with no alerts. Compute mean and standard deviation for each flow attribute:

  • bytes_per_flow
  • packets_per_flow
  • duration
  • protocol

Use a simple z‑score formula:

score = |value - mean| / stddev

Flows with a score above 3 are flagged as “highly anomalous.” Store the threshold per attribute; adjust per environment (e.g., a data‑center may have higher baseline traffic than a dev sandbox).


3. Detecting Lateral Movement

Lateral movement typically shows up as:

  1. Unusual port usage – e.g., SMB (445) or RDP (3389) between internal VMs that normally use only HTTP/HTTPS.
  2. New source/destination pairs – a VM that never spoke to another subnet starts communicating.
  3. Burst of small flows – many short flows to a single target, typical of credential dumping or lateral scans.

3.1 Rule Set

Attribute Threshold Rationale
Destination port in {445, 3389, 139} > 0 Non‑web protocols
New source/destination pair > 5 occurrences in 1 h Sudden new relationship
Flow duration < 5 s and packets > 20 > 10 per hour Likely credential dump
Total bytes > 10 MB in 5 min to a single host > 1 Data exfiltration attempt

Combine these with the anomaly score. A flow that satisfies any rule and has a z‑score > 3 gets a composite alert.

3.2 Example Alert

[ALERT] 2026‑11‑27 14:32:07
Source: 10.0.3.12
Destination: 10.0.5.45
Port: 445
Score: 4.7
Notes: New SMB session; 12 short flows in last 15 min

The alert is enriched with the host names (via DNS or inventory lookup) and the last known good session for that pair.


4. Integrating with Existing Tooling

4.1 SIEM / SOAR

Push alerts to your SIEM via Syslog or a REST endpoint. In Splunk, create a correlation search:

index=netflow sourcetype=netflow
| eval anomaly_score = abs((bytes - mean_bytes)/std_bytes)
| where anomaly_score > 3 AND dest_port IN (445, 3389)
| table _time, src_ip, dest_ip, dest_port, anomaly_score

In a SOAR platform, trigger a playbook that:

  1. Stops the source VM’s network interface (if you have API access).
  2. Runs nmap -p 445 --script smb-vuln* against the destination.
  3. Creates a ticket in JIRA with the evidence.

4.2 Cloud Native Observability

If you’re on AWS, push NetFlow data to CloudWatch Logs and use Metric Filters to detect spikes. In Azure, use Network Watcher Flow Logs and Azure Monitor alerts.


5. Trade‑offs and Caveats

Trade‑off Impact Mitigation
False positives Legitimate dev traffic may trigger alerts Tune thresholds per environment; use whitelists
Data volume NetFlow can generate millions of records per day Aggregate by 1‑minute buckets; drop flows < 100 bytes
Latency Real‑time scoring needs low‑latency ingestion Use a Kafka‑based pipeline; keep scoring logic in memory
Visibility gaps Encrypted traffic hides payload Rely on flow metadata; consider DPI only for critical segments
Cloud provider limits Some providers cap flow log export rates Use multiple export points; compress logs

6. Troubleshooting Common Issues

Symptom Likely Cause Fix
No alerts for known lateral movement Baseline too permissive Re‑run learning phase with a longer window; lower z‑score threshold
Alerts flooding during a patch window New services open ports Update whitelist; add patch‑window exception
Missing flows from a subnet Flow export disabled on router Verify NetFlow configuration; enable on all interfaces
High CPU on scoring VM Too many flows per second Scale horizontally; use a dedicated scoring cluster

7. Real‑World Example: A 2025 Incident

In late 2025, a mid‑size financial firm detected a lateral movement chain that started from a compromised employee workstation. The NetFlow anomaly engine flagged a burst of SMB traffic from the workstation to a database server that had never communicated before. The alert was routed to the SOAR playbook, which isolated the workstation, ran a forensic scan, and blocked the SMB session. The incident was contained before any data was exfiltrated.

The key lessons:

  • Baseline matters – The firm had a 14‑day learning period; a shorter period would have missed the anomaly.
  • Integration is critical – The alert reached the SOAR in under 30 seconds, enabling rapid response.
  • Visibility across clouds – The lateral movement crossed from an on‑prem VM to a cloud‑hosted database; the NetFlow pipeline included both environments.

8. Next Steps

  1. Deploy a pilot – Start with a single subnet and a 7‑day learning window.
  2. Iterate thresholds – Use the first month of data to refine the z‑score cutoffs.
  3. Automate remediation – Tie alerts to playbooks that can isolate hosts or block IPs.
  4. Document – Keep a run‑book that maps alert types to response actions.

NetFlow anomaly scoring is not a silver bullet, but it is a low‑overhead, high‑visibility layer that complements host‑based detection. In a hybrid cloud, where traffic traverses multiple administrative domains, it provides the continuity that other tools lack.

See also