Lesson 8 of 9 · 25m
Detection Engineering for Network Behavior
Build detections around attacker needs, environmental baselines, and high-fidelity sequences instead of deploying endless signatures that nobody tunes.
Most network detection programs begin with a vendor content pack and end with analysts ignoring it. Signatures are useful, but the durable advantage is understanding what attackers must do in your environment: establish control, move laterally, collect data, access identity systems, exfiltrate, and maintain persistence. Those needs create behavior. Behavior can be detected.
The craft is not writing rules. It is deciding what deserves a human.
Detect sequences, not isolated weirdness
A single connection to an uncommon port is weak evidence. A sequence is stronger:
new dns domain resolve
-> workstation connects outbound on tcp/443
-> long-lived session with low byte variance
-> same process later scans internal SMB
-> new admin logon appears on a serverNo single step proves compromise. Together they describe operator behavior. Sequence logic also helps tune: if the first step is common in your environment, do not alert until later corroboration appears.
Strong network hypotheses
Good detections start as falsifiable statements:
workstations should not initiate SMB to server VLANs except approved admin paths
database subnets should not browse the general internet
newly observed external domains should be rare for production payment services
domain controllers should not originate outbound web traffic
management-plane devices should talk only to jump hosts and monitoring systemsEach hypothesis encodes architecture. This is why detection engineering cannot be outsourced entirely to a SOC detached from network design. If the environment is flat and undocumented, the detector has no stable meaning of abnormal.
Example DNS detection logic
A lightweight Sigma-style rule concept:
title: Rare DNS Query From Production Server
logsource:
product: dns
service: resolver
detection:
selection:
src_zone: production
query_type: A
filter_known:
query_domain|endswith:
- ubuntu.com
- windowsupdate.com
- company.example
condition: selection and not filter_knownThe rule text is the easy part. The hard parts are the asset inventory behind src_zone, the known-good list, suppression expiry, and an owner who reviews first-time results.
Measure detection quality honestly
Track four numbers for every important detection:
true positives real malicious or unauthorized behavior
benign positives legitimate but unusual activity
false positives broken logic, inventory gaps, bad parsing
misses incidents or tests the logic failed to catchA detection with no true positives is not necessarily useless, but one with endless benign positives is definitely expensive. Tune the logic, the scope, or the response. Do not train analysts to close alerts reflexively.
Network detections need endpoint context
A network sensor sees a connection to an external storage service. The endpoint can tell you whether the process was rclone, a browser, a backup agent, or malware masquerading as svchost.exe. Conversely, endpoint data can be blind when the attacker uses a legitimate admin tool. Good detection joins these views instead of treating either as complete.
Purple-team the architecture
Run controlled tests that imitate the behavior you care about:
nc -lvp 4444
nmap -Pn -p445 10.30.0.0/24
curl --dns-servers 8.8.8.8 https://unusual-test.exampleDo not merely verify that an alert fired. Verify that the alert contains enough context to act: host, user or device attribution, destination, related DNS, asset criticality, process where available, and the next safe response step.
Field notes
- Alert on control-plane changes as well as traffic. A disabled logging agent is detection-relevant behavior.
- Avoid detections that only trigger on proof-of-concept tool names; operators rename tools immediately.
- Keep suppressions narrow and time-bound. Permanent suppression is untreated noise.
- Baselines drift after migrations and office closures. Review assumptions after major architectural change.
- Detection without response authority is just anxiety with a dashboard.
Was this lesson helpful?