← Course Index

4.9 Breach & Attack Simulation (BAS):
Continuous Control Testing, Drift Detection & Triage

Scheduling Automated Control Assessments, Catching Policy & Telemetry Drift, Prioritizing Fixes & Verifying Defense Readiness

Module 4: Adversary Emulation & Hunting Breach & Attack Simulation Continuous Validation

1. Continuous Security Control Assessment with BAS

Security controls drift over time as systems patch, policies change, cloud/network rules update, and new applications roll out. Breach and Attack Simulation (BAS) automates recurring, safe simulations across endpoint, network, and identity controls so teams can spot coverage regressions early rather than discovering gaps during a real incident.

Continuous Drift Detection: Running scheduled simulations on a regular cadence turns one-time testing into an ongoing early-warning system that catches broken log pipelines, disabled policies, and unblocked egress paths.
1. SCHEDULED RUNS Recurring Control Checks Endpoint • Network • Identity Safe Non-Destructive Probes 2. CONTROL EVALUATION Prevent / Detect / Log Check Did control block, alert, or log? Drift & Regression Diff Compare against prior baseline run Triage & Remediation Fix drift or rule • Re-verify Update readiness posture 3. READINESS VALUE • Fast Drift Detection • Prioritized Fix Backlog • Auditable Trend Metrics
Figure 4.9: Continuous Breach & Attack Simulation Loop for Control Testing, Drift Detection, and Remediation.

2. Key Aspects of BAS Operations

Operational Area What to Focus On Best Practice
Scope & Safety Run non-disruptive simulations on approved targets with clear schedules. Exclude sensitive production workloads unless explicitly approved and safe to probe.
Drift vs. Baseline Track changes from prior runs (e.g., a control that previously blocked now allows). Alert on regressions right away and trace recent policy, network, or agent changes.
Actionable Triage Convert failed or degraded control checks into owned remediation tasks. Group by root cause (policy gap, log drop, rule miss) and re-run after fixes.
Avoid "Simulation Fatigue": Raw simulation counts without context can create noise. Prioritize regressions on critical assets, newly changed controls, and high-impact attack paths first.

3. Practical BAS & Control Assessment Examples (10 Scenarios)

Example 1: BAS Assessment Result Record (JSON)

JSON — Recording Control Assessment & Drift Status
{
  "sim_id": "BAS-2026-109",
  "control_area": "Egress & Network Policy",
  "target_agent": "bas-agent-03",
  "previous_status": "blocked",
  "current_status": "allowed",
  "drift_detected": true,
  "timestamp_utc": "2026-11-26T05:30:00Z"
}
SAMPLE OUTPUT
[BAS RESULT LOGGED] BAS-2026-109
  Control Area : Egress & Network Policy | Agent: bas-agent-03
  Transition   : blocked -> allowed | Drift Detected: True

Example 2: Detecting Control Drift Between Two Assessment Snapshots (Python)

Python — Comparing Current and Previous Simulation Statuses
previous = {"BAS-101": "blocked", "BAS-102": "detected", "BAS-109": "blocked"}
current  = {"BAS-101": "blocked", "BAS-102": "detected", "BAS-109": "allowed"}

drifted = [
    (sim_id, previous[sim_id], current[sim_id])
    for sim_id in current
    if sim_id in previous and previous[sim_id] != current[sim_id]
]

for sim_id, old_s, new_s in drifted:
    print(f"Drift on {sim_id}: {old_s} -> {new_s}")
SAMPLE OUTPUT
Drift on BAS-109: blocked -> allowed

Example 3: Summarizing Control Outcomes by Status in Python

Python (Counter) — Counting Blocked, Detected, Logged, and Allowed Checks
from collections import Counter

statuses = ["blocked", "detected", "blocked", "allowed", "detected", "logged"]
counts = Counter(statuses)
for state, total in sorted(counts.items()):
    print(f"{state}: {total}")
SAMPLE OUTPUT
allowed: 1
blocked: 2
detected: 2
logged: 1

Example 4: Hunting Simulation Activity on a BAS Agent Host (KQL)

KQL (Microsoft Defender) — Reviewing Recent Events on a BAS Test Agent
DeviceProcessEvents
| where Timestamp > ago(24h)
| where DeviceName =~ "bas-agent-03"
| project Timestamp, AccountName, InitiatingProcessFileName, FileName, ProcessCommandLine
| order by Timestamp desc
| take 25
SAMPLE OUTPUT
Timestamp            AccountName  InitiatingProcessFileName FileName   ProcessCommandLine
---------            -----------  ------------------------- --------   ------------------
2026-11-26 05:30:01Z NT AUTHORITY\SYSTEM bas-runner.exe       curl.exe   curl.exe -sS -m 5 http://198.51.100.72/probe

Example 5: Checking Outbound Reachability from a BAS Agent (Bash)

Bash (curl) — Testing Controlled Probe Endpoint with Timeout
curl -sS -o /dev/null -w "HTTP %{http_code}\n" --max-time 5 https://example.com || true
SAMPLE OUTPUT
HTTP 200

Example 6: Verifying Local Firewall / Policy Service Status on Linux

Bash (systemctl) — Checking Host Firewall & Telemetry Services
systemctl is-active nftables || true
systemctl is-active wazuh-agent || true
SAMPLE OUTPUT
active
active

Example 7: Velociraptor VQL — Checking Recent Processes on a BAS Agent

VQL (Velociraptor) — Listing Active Processes for Assessment Audit
SELECT
  Pid,
  Name,
  Exe,
  CommandLine
FROM pslist()
WHERE Name =~ "(?i)(bas|agent|powershell|pwsh|curl)\\.exe$"
SAMPLE OUTPUT
Pid   Name           Exe                                                   CommandLine
---   ----           ---                                                   -----------
3120  bas-runner.exe C:\Program Files\BASAgent\bas-runner.exe              bas-runner.exe --daemon

Example 8: Wazuh Rule — Alerting on Unexpected Policy / Configuration Changes

XML (Wazuh Rule) — Flagging Monitored Configuration or Alert Events

  
    550
    /etc/nftables.conf|/etc/ssh/sshd_config
    Configuration drift detected on monitored host $(agent.name)
  
SAMPLE OUTPUT
** Alert 1795689012.66210: - local,bas_monitoring,drift
2026 Nov 26 05:31:18 (bas-agent-03) 10.10.24.55->syscheck
Rule: 100950 (level 10) -> 'Configuration drift detected on monitored host bas-agent-03'

Example 9: Prioritizing Drifted Checks for Remediation (Python)

Python — Filtering Assessment Items Where Drift Was Detected
results = [
    {"sim_id": "BAS-2026-101", "drift_detected": False, "area": "Endpoint"},
    {"sim_id": "BAS-2026-109", "drift_detected": True,  "area": "Egress"},
]

action_items = [r for r in results if r["drift_detected"]]
for item in action_items:
    print("Action needed:", item["sim_id"], "-", item["area"])
SAMPLE OUTPUT
Action needed: BAS-2026-109 - Egress

Example 10: Writing a Concise BAS Readiness Digest in Python

Python — Formatting a Weekly Control Assessment Summary
total = 25
prevented_or_detected = 21
drift_count = 2
rate = (prevented_or_detected / total) * 100
print(f"Prevented/Detected: {rate:.1f}% ({prevented_or_detected}/{total}) | Drift items: {drift_count}")
SAMPLE OUTPUT
Prevented/Detected: 84.0% (21/25) | Drift items: 2

4. Interactive BAS Drift & Triage Simulator

Select a simulation scenario below to review the control finding and recommended triage steps:

← Previous: 4.8 Advanced Threat Hunting Queries 5.1 Cloud-Native Application Protection Platform (CNAPP) →