Agent Foskett Academy • SOC Analyst Academy • Module 9 • Lesson 81 • Detection Engineering: Turning Findings into Protection

Lesson 81 — This Investigation Should Become a Detection

The investigation was finished.

The behaviour was malicious. The device was contained. The timeline was complete.

Then Agent Foskett looked back at the evidence: browser → PowerShell → suspicious command → file execution → external communication.

“If this happens again tomorrow, why should we have to rediscover it manually?”

The investigation had found more than an attacker. It had found behaviour worth detecting.

Detection engineering begins when a repeatable, observable and actionable investigation finding is worth turning into ongoing protection.
Agent Foskett turning an investigation finding into a detection candidate
Not every finding needs a detection.

The behaviour should be observable, repeatable enough to matter, sufficiently distinctive and connected to an action the SOC can take.

✓ Observe
✓ Repeat
✓ Validate
✓ Operationalise

Case briefing

INCIDENT Browser → PowerShell ↓ Suspicious command ↓ File execution ↓ External connection VERDICT: MALICIOUS THREAT HUNT: Same core behaviour on two more devices QUESTION: Should the SOC wait for another manual hunt next time?

Investigation objective

Decide whether a validated investigation or hunting finding is suitable for operational detection by testing its observability, repeatability, distinctiveness, actionability and expected analyst value.

Investigator's rule

A detection should preserve the security hypothesis — not merely copy the query that happened to find it.

Stage 1 — start with the security hypothesis

Weak starting pointStronger starting point
Alert whenever PowerShell runs.Identify unusual browser-initiated PowerShell with suspicious context.
Detect this IP.Detect the repeatable behaviour associated with the incident; retain the IOC for enrichment.
Turn this hunt query into an alert.Define what malicious behaviour the SOC needs surfaced and why.

The query is an implementation

The hypothesis explains what matters. The query implements that hypothesis against available telemetry.

Preserve the reason

If future analysts cannot explain what security problem the rule is intended to identify, tuning becomes guesswork.

Stage 2 — can we observe it reliably?

CAN WE OBSERVE: ✓ initiating process? ✓ PowerShell execution? ✓ command line? ✓ device and account? ✓ timestamp? ✓ follow-on activity? Missing telemetry = unreliable detection.

Telemetry comes first

A strong hypothesis cannot compensate for missing or inconsistent data. Confirm coverage across the population the rule is meant to protect.

State coverage boundaries

If the logic works only on a subset of devices, document that limitation rather than implying universal visibility.

Stage 3 — reproduce the known behaviour

01-detection-candidate.kql
123456789
DeviceProcessEvents
| where Timestamp > ago(14d)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where InitiatingProcessFileName in~ (
    "msedge.exe", "chrome.exe", "firefox.exe"
)
| project Timestamp, DeviceId, DeviceName, AccountName,
          ProcessCommandLine, InitiatingProcessFileName
| order by Timestamp asc

Prove it sees the incident

If the candidate cannot reproduce the known malicious behaviour that motivated it, do not rush it into production.

Then inspect everything else

The engineering work begins when you review what the same logic returns across ordinary historical activity.

Stage 4 — test repeatability

FIN-WS-204 → MATCH FIN-WS-219 → MATCH FIN-WS-233 → MATCH Different IPs. Different domains. Different hashes. Same core behaviour. The behaviour has repeated.

Repeatable does not automatically mean detectable

The team must still understand how often legitimate activity produces the same pattern.

Look for stable characteristics

Meaningful process relationships and sequences often survive changes in attacker-controlled infrastructure.

Stage 5 — compare malicious and benign matches

CharacteristicMaliciousKnown benign
Browser → PowerShellObservedRare
Novel command lineObservedNot typical
User-writable stagingObservedNot typical
Immediate external communicationObservedNot typical
Approved change contextAbsentPresent where expected

Distinctiveness matters

A behaviour can be malicious yet make a poor standalone detection if normal activity constantly produces the same signal.

Do not tune away the hypothesis

Reduce irrelevant matches while preserving the suspicious behaviour. Lesson 82 will test this when false positives start dominating.

Stage 6 — is the result actionable?

WHEN IT FIRES, CAN THE ANALYST: ✓ identify device and user? ✓ see process and command? ✓ pivot to network/file/identity evidence? ✓ decide benign, investigate, escalate or contain? If not, more engineering may be required.

Detection without response value creates noise

A rule is not useful merely because it can generate alerts. Its output should support a meaningful investigation.

Think about the analyst at 2 AM

The engineer knows why the rule matters. The receiving analyst needs the alert to transfer enough of that understanding.

Stage 7 — what should not become a detection?

FindingLikely treatment
One-time IOC with no continuing relevanceEnrichment or historical scoping
Very broad behaviour with overwhelming legitimate useKeep hunting or add context
Behaviour requiring substantial human interpretationMay remain a proactive hunt
Repeatable, observable, distinctive and actionable behaviourStrong detection candidate

Not every hunt needs an alert

Some hypotheses are more valuable when investigated periodically with human context than when added permanently to the queue.

Operationalisation is a decision

The team should be able to explain why continuous monitoring creates more security value than retaining the behaviour as a hunt.

Stage 8 — define the candidate

NAME: Suspicious Browser-Initiated PowerShell HYPOTHESIS: A malicious web interaction may cause a browser to initiate PowerShell before suspicious follow-on activity. PRIMARY TELEMETRY: DeviceProcessEvents CONTEXT: command line • prevalence • network • files • change context LIMITATION: The process relationship alone does not prove malicious intent.

Write limitations before deployment

A transparent detection says what it can establish and what it cannot.

Give it an owner

Someone must own tuning, environmental review, modification and eventual retirement.

Stage 9 — production-readiness check

QuestionStatus
Meaningful security hypothesis?Required
Reliable telemetry?Required
Reproduces known malicious examples?Required
Historical benign matches reviewed?Required
Analyst can explain why it fired?Required
Useful investigation path?Required
Limitations and ownership documented?Required

Production is not the finish line

The environment changes, analysts provide feedback and assumptions must be revisited.

Detection engineering is operational engineering

The goal is not a clever query. The goal is reliable security value delivered repeatedly to the SOC.

Stage 10 — engineering decision

DECISION: The browser-to-PowerShell behaviour repeated across multiple malicious cases despite changing attacker indicators. The behaviour is observable and provides useful investigative context. Legitimate matches remain possible. PROGRESS AS A PRODUCTION DETECTION CANDIDATE. NEXT: • baseline historical frequency • refine context • backtest logic • measure alert volume • document guidance • define ownership

The investigation created protection

The SOC extracted a repeatable lesson from the evidence and began turning it into something capable of finding the behaviour next time.

The detection-engineering mindset

Investigate the attack. Understand the behaviour. Decide whether it is worth operationalising. Then engineer the signal so another analyst can act on it.

Lesson 81 key takeaways

  • Start detection engineering with a security hypothesis, not a saved query.
  • Not every finding needs a production detection.
  • Confirm reliable telemetry coverage.
  • Reproduce known malicious cases.
  • Review historical legitimate matches.
  • Repeatable behaviour is often more durable than one-time IOCs.
  • Distinctiveness affects signal quality.
  • Detection output must support analyst action.
  • Document limitations and ownership.
  • Preserve the original hypothesis while tuning implementation.
  • Production begins an ongoing lifecycle.

Module 9 — Detection Engineering: Turning Findings into Protection

Lesson 81 recognised repeatable malicious behaviour worth operationalising. Lesson 82 tests what happens when the new detection starts producing too much noise.

Next: Lesson 82 — The Detection Generated Too Many False Positives

Continue your SOC Analyst training

Module 3 focuses on identity incidents, authentication, MFA, privilege, sessions and application access.

When should a threat hunt become a detection?

Lesson 81 of the Agent Foskett SOC Analyst Academy teaches analysts how to decide whether repeatable malicious behaviour discovered during an investigation or threat hunt should be operationalised as a production detection.

Detection engineering in Microsoft Defender XDR

Evaluate detection candidates using hypotheses, telemetry coverage, historical behaviour, distinctiveness, analyst actionability, limitations and ownership before moving hunting logic into ongoing SOC protection.