Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Security operations basics

Workbook · Hard · 5 hoursFree account

Detection Engineering

Writing detection rules, YARA, Sigma, and tuning for low false positive rates.

  • detection-engineering
  • sigma
  • yara
  • tuning
On this page 5 sections
  1. ·About This Workbook
  2. ·Chapter 1 — The Discipline
  3. Locked: Chapter 2 — Building Detections
  4. Locked: Chapter 3 — Testing & Maintenance
  5. Locked: Next steps

Before you start

Detection engineering turns the SIEM from a graveyard of brittle alerts into a product with owners, tests and a shelf life. A detection pairs a behaviour, a data source and a measure of quality, so the rule either fires on the attack and stays quiet on normal work, or the team learns why. The craft covers three jobs that people often skip: writing a requirement, checking the data before the logic, and keeping a rule as code with automatic tests. Tools matter less than the discipline; Sigma, YARA and a few lines of jq can carry a whole programme. The skills map to MITRE ATT&CK, apply across hosts, networks and cloud, and turn tuning from a chore into a measure of precision.

What You'll Learn

  • Explain how detection engineering differs from alert handling
  • Write a detection requirement from an attacker behaviour
  • Check that the data for a detection exists before you write the rule
  • Make a rule robust, and recognise a brittle one
  • Test a rule with data that must match and data that must not match
  • Measure precision and tune a noisy rule

About This Workbook

Detection engineering treats detections as a product. A product has a requirement, a design, a test, an owner and a life that ends. A detection that no one tests breaks silently: the rule stays in the SIEM, the dashboard stays green, and the attack passes.

This workbook covers the discipline in three chapters. You already know how to write one rule from the lab YARA & Sigma for Defenders. Here you learn how to make a rule that stays correct for years. For the analyst side, see SOC Operations & SIEM. For network rules, see IDS/IPS Detection Engineering.

All examples use fictional lab data and only read logs.

Chapter 1 — The Discipline

Objectives

  • Compare indicator-based and behaviour-based detection
  • Map a detection to an ATT&CK technique
  • Describe the lifecycle of a detection

Explanation

An indicator is a fixed fact about one attack: a file hash, an IP address or a domain. A behaviour is what an attacker must do to reach a goal, whatever tool or address they use. David Bianco's Pyramid of Pain (2013) ranks indicators by the pain that a change causes the attacker. From the bottom: hash values, IP addresses, domain names, network and host artefacts, tools, and tactics, techniques and procedures (TTPs). An attacker changes a hash in seconds. Changing a TTP means changing how the attack works.

Indicator detections are cheap and fast, and they age quickly. Behaviour detections take more work and last longer. Build both, but spend your effort on the upper part of the pyramid.

MITRE ATT&CK is a public catalogue of attacker behaviour. It groups behaviour into tactics (the goal, such as Execution) and techniques (the method, such as T1059.001, PowerShell). Map each detection to a technique. Then you can count what you cover, find what you miss, and talk to other teams with the same words. A map is a tool for planning and not a score: one rule for a technique does not mean that you detect every way to use it.

Lifecycle. A detection moves through these stages, and the work does not end at deployment:

  1. Requirement. What behaviour, and why does it matter here?
  2. Data check. Does the log source exist, with the fields that you need?
  3. Build. Write the rule.
  4. Test. Prove that it fires on the behaviour and stays quiet on normal activity.
  5. Deploy and review. Put it in production. An analyst reviews the first alerts.
  6. Tune. Reduce false positives and close gaps.
  7. Retire. Remove the rule when the data, the system or the threat is gone.

Worked example

A detection requirement is a short card. It keeps the rule tied to a purpose.

ID:            DET-014
Behaviour:     PowerShell runs a command that is passed in encoded form
ATT&CK:        T1059.001 Command and Scripting Interpreter: PowerShell
Why it matters: The encoding hides the command from reviewers of process logs.
Data needed:   Process creation events with full command line
               (Windows event 4688 with command-line audit, or Sysmon event 1)
Known benign:  Some admin and management tools use encoded commands
Response:      Analyst decodes the command and checks the user and the host
Owner:         SOC detection team          Review date: every 6 months

The card says what the rule is for, what it needs and who owns it. It also states the known benign use before the first alert, so that the first analyst is not surprised.

Practice questions

  1. Order these by the pain they cause the attacker if you detect them, from least to most: a file hash, a TTP, an IP address.
  2. A rule detects the file name update_check.exe. Is it indicator-based or behaviour-based? What breaks it?
  3. Why does a detection need an owner and a review date?
  4. A coworker says: "We have a rule for T1059.001, so we cover PowerShell." What is wrong?
Answers
  1. File hash, then IP address, then TTP. Hashes are the cheapest for the attacker to change and TTPs are the most expensive.
  2. It is indicator-based. Renaming the file breaks it, and the attacker needs only seconds to do that.
  3. The data, the network and the attacker change. A rule without an owner is not fixed when it breaks, and a review date forces a check of whether the rule is still correct and still needed.
  4. One rule covers one way to use the technique. A technique has many variants, so the rule shows a part of the coverage. Test the rule against several variants and record what it misses.

Sign in to continue

3 more sections are for signed-in members. It is free: sign in with Google.

Related

This workbook is extra practice for the course Security operations basics. Do the lessons first.Open the course