Learn any cloudLabsDefender for Endpoint WSL2 Plug-in & Hunting Walkthrough
Defender for Endpoint WSL2 Plug-in & Hunting Walkthrough
WorkspacesUnknownSupplementary Linux container simulation (no Windows 11 Azure VM): explore how Microsoft Defender for Endpoint monitors WSL2 Linux distributions (`<HostName>-wslc`), inspect simulated healthcheck and EDR telemetry, practise the three Advanced Hunting KQL queries, and validate the Azure policy baseline.
Intermediateabout 30 minutesToolsaz, terraform
Inspect how the Microsoft Defender for Endpoint WSL2 plug-in extends kernel sensor visibility into every running WSL2 distribution, tags the machine as <HostName>-wslc, and surfaces process events in Advanced Hunting.
How it works
- Verify the plug-in status on the Windows 11 host with healthcheck.exe and inspect the seeded output in ~/mde-wsl-lab/mock-healthcheck.txt.
- Confirm both LAB-HOST and the WSL2-tagged LAB-HOST-wslc entry appear in the Device Inventory linked by HostDeviceId.
- Run diy-edr-test.sh --trigger-test-marker and query DeviceInfo and DeviceProcessEvents with the three KQL hunting queries.
Key services
- Defender for Endpoint Plug-in for WSL: Streams process and network telemetry from the shared WSL2 Linux kernel
- Defender Device Inventory: Lists each WSL2 machine as <HostName>-wslc with the WSL2 tag
- Advanced Hunting (KQL): Joins WSL2 DeviceProcessEvents back to the parent Windows 11 host via HostDeviceId
Security and best practices
- Ensure WSL 2.0.14.0 or newer is installed via wsl.exe --update so the plug-in can attach to the virtual machine kernel.
- Correlate Linux process telemetry to the physical workstation using AdditionalFields.HostDeviceId in KQL hunting queries.
- Use a benign marker script (diy-edr-test.sh) to verify sensor health and alert routing without introducing malicious binaries.
Outcome
End-to-end verification of Defender for Endpoint WSL2 sensor health, <HostName>-wslc inventory correlation, and KQL process hunting—all inside a safe Linux container and browser simulator.
Opening your lab workspace…
Inspect WSL2 Plug-in Health, Device Inventory, and KQL Telemetry
Verify the Windows host plug-in output, inspect the paired LAB-HOST and LAB-HOST-wslc records, trigger the safe DIY Linux EDR test marker, and run the three Advanced Hunting KQL queries right in your browser.
& "C:\Program Files\Microsoft Defender for Endpoint Plug-in for WSL\tools\healthcheck.exe"Steps
Step 1: Inspect simulated WSL2 plug-in status and compare with Windows host healthcheck.exe
On a real Windows 11 host onboarded to Microsoft Defender for Endpoint, the WSL2 plug-in (
Minimum build 2004 / KB5007253+with WSL2.0.14.0+) runs a Windows-host health check tool. On an onboarded Windows 11 workstation, run:& "C:\Program Files\Microsoft Defender for Endpoint Plug-in for WSL\tools\healthcheck.exe"Because this browser lab runs inside a Linux container rather than a Windows VM, the workspace provides simulated output so you can inspect the fields (
PluginStatus,SensorHealth,HostDeviceId,WslDeviceName) before running the real check on a Windows host:healthcheck.exeNotice the
[SIMULATED]banner in the Linux shim output and verify thatWslDeviceNamefollows the<HostName>-wslcnaming convention (LAB-HOST-wslc).Step 2: Trigger the simulated DIY Linux EDR test script inside the container
Run the benign DIY Linux EDR simulation script inside
~/mde-wsl-lab(or click Run DIY Linux EDR Test in the interactive simulator on this page):~/mde-wsl-lab/diy-edr-test.sh --trigger-test-markerIn this Linux container simulation, the script records a local simulated
DeviceProcessEventsJSON event rather than submitting a live alert to Defender. On a real onboarded Windows 11 + WSL2 host, validate actual detections in the Microsoft Defender portal (https://security.microsoft.com) under Incidents & alerts and Advanced hunting.Step 3: Inspect the three Advanced Hunting KQL queries
Open
~/mde-wsl-lab/hunting-queries.kqlin the workspace or step through the 4. Advanced Hunting KQL tab in the simulator above:cat ~/mde-wsl-lab/hunting-queries.kqlThe three queries cover: (1) listing all
WSL2-tagged Linux instances inDeviceInfowith theirHostDeviceIdcolumn, (2) joining WSL2 instances back to their parent Windows 11 host viaDeviceInfo.HostDeviceId, and (3) filteringDeviceProcessEventsacross WSL2 devices identified byDeviceInfo.HostDeviceId.Step 4: Validate the Terraform security management root
Initialise and validate the Terraform configuration in
~/mde-wsl-lab/main.tfusing the offline provider mirror:cd ~/mde-wsl-lab terraform init -backend=false terraform fmt -check terraform validateSubmit
main.tfto the lab runner to verify the configuration passes offline validation.Checked by the agent (terraform-validate): Send main.tf to the terraform-validate runner job to confirm the management configuration validates cleanly with no network access.