Skip to main content

Learn any cloudLabsDefender for Endpoint WSL2 Plug-in & Hunting Walkthrough

Defender for Endpoint WSL2 Plug-in & Hunting Walkthrough

WorkspacesUnknown

Supplementary 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.

Defender for Endpoint WSL2 Plug-in — Host & Linux Sensor Telemetry Flow
Windows 11 Build 2004+ (KB5007253)WSL 2.0.14.0+Defender Portal Assets & Hunting
Windows 11 Host: LAB-HOST (Onboarded)

How it works

  1. 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.
  2. Confirm both LAB-HOST and the WSL2-tagged LAB-HOST-wslc entry appear in the Device Inventory linked by HostDeviceId.
  3. 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…

Interactive Defender Portal & Hunting Simulator

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.

SensorHealth: Healthy
PowerShell — Windows 11 host verification command
PowerShell
& "C:\Program Files\Microsoft Defender for Endpoint Plug-in for WSL\tools\healthcheck.exe"
PluginStatusRunning
PluginVersion1.0.2604.1
EngineVersion101.24082.0004
OrgId00000000-0000-0000-0000-000000000000
HostDeviceId8f3b2e10-4c9a-4d7e-9b1a-7c6d5e4f3a21
HostDeviceNameLAB-HOST
WslDeviceNameLAB-HOST-wslc
ActiveDistributionsUbuntu-24.04 (WSL2)
SensorHealthHealthy
TelemetryChannelConnected

Steps

  1. 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 WSL 2.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.exe
    

    Notice the [SIMULATED] banner in the Linux shim output and verify that WslDeviceName follows the <HostName>-wslc naming convention (LAB-HOST-wslc).

  2. 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-marker
    

    In this Linux container simulation, the script records a local simulated DeviceProcessEvents JSON 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.

  3. Step 3: Inspect the three Advanced Hunting KQL queries

    Open ~/mde-wsl-lab/hunting-queries.kql in the workspace or step through the 4. Advanced Hunting KQL tab in the simulator above:

    cat ~/mde-wsl-lab/hunting-queries.kql
    

    The three queries cover: (1) listing all WSL2-tagged Linux instances in DeviceInfo with their HostDeviceId column, (2) joining WSL2 instances back to their parent Windows 11 host via DeviceInfo.HostDeviceId, and (3) filtering DeviceProcessEvents across WSL2 devices identified by DeviceInfo.HostDeviceId.

  4. Step 4: Validate the Terraform security management root

    Initialise and validate the Terraform configuration in ~/mde-wsl-lab/main.tf using the offline provider mirror:

    cd ~/mde-wsl-lab
    terraform init -backend=false
    terraform fmt -check
    terraform validate
    

    Submit main.tf to 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.