liveBook · Manning

Standard deviation

As explained in Cyber Threat Hunting

Standard deviation is the square root of variance and measures the typical distance of data values from their mean.

Standard deviation is the square root of variance. It expresses how spread out values are around their mean: a low value signals consistent timing, while a higher value signals greater variation. In network analysis, it turns repeated connection intervals into a compact measure of regularity. section 6.1.1

To hunt for beaconing, group connections by source IP, destination IP, and destination port; calculate the time between consecutive connections; then calculate standard deviation for each group. Prioritize groups with enough repeated events and low standard deviation, because their intervals are unusually consistent. section 6.1.1 section 6.1.5

A practical investigation workflow is:

  • Collect timestamped network connections and retain the source address, destination address, and destination port. section 6.1.1
  • Filter to connection groups with a meaningful repeat count before measuring their intervals. section 6.1.5
  • Calculate consecutive time differences, standard deviation, variance, and count for every group. section 6.1.5
  • Sort or filter by low standard deviation, then investigate the destination, traffic details, and processes behind the connection. section 6.1.5 section 7.1.1

Separating regular traffic from suspicious beaconing

One investigation reduced 667,827 connection records to 584 unique, high-repeat connection groups, then used low standard deviation to focus the review. Follow-up showed that some regular destinations were benign, while traffic to 34.125.188.180 included repeated /cm GET requests and /submit.php POST requests; endpoint querying identified powershell.exe connecting to that address. section 6.1.5

Listing 6.14 Calculating standard deviation, variance, and count
df['std1'] = df.groupby(['src_ip', 'dest_ip', \
    'dest_port'])['time_diff_sec'].transform('std')       #1
 
df['var1'] = df.groupby(['src_ip', 'dest_ip', \
    'dest_port'])['time_diff_sec'].transform('var')       #2
 
df['count1'] = df.groupby(['src_ip', 'dest_ip', \
    'dest_port'])['time_diff_sec'].transform('count')     #3

Use the grouped DataFrame calculation to attach standard deviation, variance, and event count to each connection pattern before filtering and sorting candidates. section 6.1.5

Standard deviation is a prioritization signal, not a verdict. Regular traffic can be legitimate, so validate candidates with destination context, event details, and endpoint evidence rather than relying on low variance or low standard deviation alone. section 6.1.5 section 7.1.1

How Cyber Threat Hunting covers it

How deep it goes
Defines standard deviation from variance and works through grouped interval calculations, thresholds, plots, and follow-up investigation.
Examples
Uses network flows to Wikipedia and 34.125.188.180, line plots, histograms, certificates, HTTP events, and an osquery process query.
What it assumes
Assumes no statistical specialization, while Python programming and SQL query knowledge are beneficial for the tooling.
What you can do after
Diagnose/debug with it by ranking regular connection patterns and validating beaconing candidates with network and endpoint evidence.
How it connects
Connects variance, mean, time differences, network beaconing, pandas DataFrames, and endpoint process queries.

Also explained in

Compare how 15 books explain standard deviation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Cyber Threat Hunting. The section links point to the parts of the book it draws on.