Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 36 ยท Security and Apps

Splunk for Security: Detections, Correlation Searches and Risk

Use Splunk for security monitoring: log sources, SPL detections for brute force and impossible travel, correlation searches, notable events, risk-based alerting and MITRE ATT&CK mapping.

Splunk began as a log search engine, and security teams adopted it quickly: security incidents leave traces in logs, and a SIEM (Security Information and Event Management) is essentially a platform that collects those logs, normalizes them, detects suspicious patterns and organizes the response. This lesson shows how detections are built in SPL, how Splunk Enterprise Security (ES) structures them, and how to reason about quality.

Data for security

Typical sources: authentication (Windows Security events, Linux auth.log, identity providers, VPN), endpoints (Sysmon, EDR), network (firewalls, DNS, proxies, NetFlow, IDS), cloud audit logs (CloudTrail, Entra ID, GCP), email, vulnerability scanners and web servers. Map them to the CIM so a detection written once works for every vendor: Authentication, Network_Traffic, Endpoint.Processes, Web, Change, Malware, Network_Resolution.

Security searches are normally written against accelerated data models with tstats, because detections run every few minutes over large volumes.

Detection patterns in SPL

1. Brute force: many failures from one source.

SPL
| tstats summariesonly=true count from datamodel=Authentication
  where Authentication.action=failure by Authentication.src, Authentication.user, _time span=5m
| rename Authentication.* AS *
| stats sum(count) AS failures, dc(user) AS users by src, _time
| where failures >= 20

Many users from one source suggests password spraying; one user from many sources suggests a distributed attack.

2. Success after failures. An attacker who finally guesses a password is the highest-value signal:

SPL
index=auth action IN (success, failure)
| sort 0 user _time
| streamstats window=11 current=f count(eval(action="failure")) AS recent_failures by user
| where action="success" AND recent_failures >= 10

3. Rare processes (stack counting). Count how many hosts ran each process and look at the rare ones; Endpoint.Processes with | stats dc(dest) ... | where hosts<=2.

4. Impossible travel. Two successful logins for one user from places too far apart for the elapsed time. Using iplocation for latitude and longitude, compute the distance between consecutive logins and the implied speed with streamstats and eval. Speeds above about 900 km/h (a passenger jet) flag the event.

5. Data exfiltration. Compare each host's outbound bytes with its own baseline: eventstats avg(bytes_out) stdev(bytes_out) by src, then flag results more than three standard deviations above average.

6. Persistence and change. New scheduled tasks, new services, new local admins, security tool tampering from Change and Endpoint models.

Try it: a brute-force detector (stand-in)

This stand-in applies the first two patterns to a small, fixed list of events.

Python Stand-in: failures per source and success after failures

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Try it: impossible travel (stand-in)

Python Stand-in: distance and speed between two logins

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

(VPNs and mobile carriers produce false positives; real detections allow-list known gateways.)

Enterprise Security concepts

Splunk Enterprise Security is a premium app that sits on top of the platform. Its main ideas:

  • Correlation searches: scheduled searches (the detections) that run against data models and, when they match, create a notable event or a risk event.
  • Notable events appear in Incident Review with an urgency (computed from severity and the importance of the asset or identity), a status (New, In Progress, Resolved, Closed) and an owner. Analysts triage, add comments and run response actions.
  • Asset and identity framework: lookups that describe hosts (owner, criticality, category) and people (department, privileged or not), so alerts for a domain controller outrank those for a test laptop.
  • Risk-Based Alerting (RBA): instead of alerting on every weak signal, detections add risk scores to an entity (a user or system) with the reason and the MITRE ATT&CK technique. A risk incident rule alerts only when an entity's total risk exceeds a threshold within a window or when several tactics are observed. This reduces alert volume dramatically.
  • Threat intelligence framework: matches indicators (IPs, domains, hashes) against events.
  • Adaptive response actions: run actions such as isolate host, block IP or open a ticket, through add-ons.
  • Security Posture and Security Intelligence dashboards for management views.

A related product is Splunk SOAR, which automates response with playbooks. Both Splunk ES and SOAR need licenses; the open concepts above are what you can practice with plain Splunk Enterprise and the free Security Content detection library.

Try it: risk scores per entity (stand-in)

Python Stand-in: risk-based alerting threshold

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Detection quality

  • Test with attack data: replay recorded attack logs or run safe simulations in a lab, and confirm that the correlation search fires.
  • Tune: measure false positives, add allow-lists (a lookup of known scanners), and raise thresholds based on baselines.
  • Document: purpose, data sources, logic, ATT&CK mapping and response steps. A detection nobody can explain is noise.
  • Respect privacy: security data identifies people; follow policy on who can search it (roles and permissions).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why write detections against CIM data models?

    Normalized, accelerated data lets a single search cover many sources efficiently.
  2. 2. What is a notable event in Enterprise Security?

    Notables are the alerts created by correlation searches, with urgency, status and owner.
  3. 3. What problem does risk-based alerting solve?

    RBA turns weak signals into scores and alerts only when an entity looks risky overall.
  4. 4. A user logs in from London and 90 minutes later from New York. Which detection fits?

    The distance divided by elapsed time implies a speed no traveler could reach.

Summary

  • Security detections are SPL searches over normalized, accelerated data.
  • Core patterns: brute force, success after failures, rare processes, impossible travel, exfiltration, persistence.
  • Enterprise Security adds correlation searches, notable events, asset and identity context and risk-based alerting.
  • Tune, test and document every detection, and map it to MITRE ATT&CK.

Next: Apps, add-ons and Splunkbase