← Course Index

1.4 Detecting EDR Tampering:
Direct/Indirect Syscalls, NTDLL Unhooking, BYOVD & PPL

Defending Endpoint Telemetry Against User-Mode Hook Evasion, Vulnerable Signed Drivers, and Protected Process Light Abuse

Module 1: Endpoint Defense Anti-Evasion BYOVD & PPL

1. How Adversaries Attempt to Blind or Bypass EDRs

As EDR telemetry matures, sophisticated threat actors and ransomware operators attempt to evade detection before executing credential dumping, lateral movement, or file encryption. Four high-impact evasion techniques dominate modern intrusions: Direct/Indirect Syscalls, NTDLL Unhooking, Bring Your Own Vulnerable Driver (BYOVD), and Protected Process Light (PPL) abuse.

Defensive Insight: Evasion rarely occurs in complete silence. Bypassing a Ring 3 hook often leaves anomalous artifacts in call stacks, unbacked executable memory regions, ETW-TI kernel events, or driver load/process termination logs.
ADVERSARY EVASION TECHNIQUES 1. Direct / Indirect Syscalls Execute 'syscall' stub directly, skipping hooked ntdll.dll wrappers. 2. NTDLL Unhooking Overwrite .text section of ntdll.dll from disk, knownDlls, or suspended process. 3. BYOVD (Bring Your Own Vulnerable Driver) Load signed vulnerable driver to kill EDR processes or clear kernel callbacks. 4. PPL Downgrade / Tampering Abuse arbitrary read/write primitive to zero out EPROCESS Protection fields. DEFENSIVE DETECTION & HARDENING Call Stack & ETW-TI Correlation Return address outside ntdll.dll; ETW-TI still captures kernel allocation. Module & Section Integrity Telemetry Detect suspicious file opens on KnownDlls/ntdll.dll & unbacked RWX/RX regions. HVCI + Vulnerable Driver Blocklists Enforce WDAC / Microsoft Recommended Driver Block Rules & EID 7045/Sysmon 6. PPL + Watchdog Self-Protection Run EDR as AntimalwareLight (PPL), monitor handle stripping & service stop attempts.
Figure 1.4: Mapping Common EDR Evasion Techniques to Kernel Telemetry, Integrity Controls, and Detection Signals.

2. Evasion Technique vs. Defensive Countermeasure Matrix

Technique Attacker Goal Primary Telemetry Signal Hardening / Mitigation
Direct / Indirect Syscalls Invoke System Service Numbers (SSNs) without hitting inline hooks inside `ntdll.dll`. ETW-TI memory/thread events; call stack frames pointing to private/unbacked memory or `syscall` gadgets outside standard export stubs. Enable ETW-TI (requires ELAM-signed EDR); deploy behavioral rules correlating anomalous memory writes with non-standard call stacks.
NTDLL Unhooking Restore clean `ntdll.dll` `.text` bytes in memory to remove EDR JMP/detour hooks. Process reading `C:\Windows\System32\ntdll.dll` or opening `\KnownDlls\ntdll.dll` from unexpected processes; memory section changes. Pair user-mode hooks with kernel callbacks (`PsSetCreateProcessNotifyRoutineEx`, `ObRegisterCallbacks`, ETW-TI) that do not rely on `ntdll.dll`.
BYOVD Exploit a signed but vulnerable kernel driver (e.g., arbitrary R/W IOCTL) to kill EDR or patch kernel callbacks. Sysmon Event ID 6 (Driver Loaded) or Windows Security Event ID 4697 / System 7045 for new/unusual `.sys` drivers; sudden EDR service/process termination. Enable **HVCI / Smart App Control / WDAC** and enforce Microsoft's **Vulnerable Driver Blocklist**.
PPL Abuse Bypass Protected Process Light (`PS_PROTECTED_ANTIMALWARE_LIGHT`) to terminate or dump protected processes. Kernel R/W primitive usage, anomalous access to protected services/processes, or watchdog alerts when secondary agent components lose heartbeats. Enforce PPL (`LaunchProtected = 3`) on EDR services, enable **RunAsPPL** on `lsass.exe`, and use redundant kernel/cloud heartbeat watchdogs.

3. BYOVD & Protected Process Light (PPL) Mechanics

Bring Your Own Vulnerable Driver (BYOVD) works because Windows x64 requires kernel drivers to carry a valid digital signature. Attackers drop a legitimate, signed third-party driver that contains a known security flaw (such as an exposed physical memory mapping or arbitrary kernel read/write IOCTL), load it with administrator privileges, and use its kernel primitive to terminate EDR processes or blind callbacks.

Protected Process Light (PPL) restricts which processes can open handles with elevated access rights (such as PROCESS_VM_READ or PROCESS_TERMINATE) to a protected process. A process at a lower protection level—or an unsigned/non-ELAM-protected process—cannot acquire full control handles over a PPL-protected EDR agent or `lsass.exe` using standard Windows APIs.

Detection Priority: Treat any attempt to stop an EDR service, unload/block an EDR minifilter, or load a known vulnerable driver hash/signer as a high-priority incident—these actions almost always precede ransomware deployment or credential theft.

4. Practical Detection, Hunting & Hardening Examples (10 Scenarios)

Example 1: Hunting BYOVD Driver Loads via Sysmon Event ID 6 (KQL)

KQL (Microsoft Sentinel / Defender Hunting) — Detecting Unsigned or Suspicious Driver Loads
// Detect driver loads where signature is invalid, untrusted, or originating from non-System32 paths
DeviceEvents
| where Timestamp > ago(7d)
| where ActionType == "DriverLoad"
| extend Parsed = parse_json(AdditionalFields)
| extend ImageLoaded = tostring(Parsed.ImageLoaded),
         Signed = tostring(Parsed.Signed),
         SignatureStatus = tostring(Parsed.SignatureStatus),
         Sha256 = tostring(Parsed.SHA256)
| where (Signed != "true" or SignatureStatus != "Valid")
   or (ImageLoaded !startswith "C:\\Windows\\System32\\drivers\\" and ImageLoaded !startswith "C:\\Windows\\System32\\DriverStore\\")
| project Timestamp, DeviceName, ImageLoaded, Signed, SignatureStatus, Sha256
SAMPLE OUTPUT
Timestamp            DeviceName  ImageLoaded                          Signed SignatureStatus Sha256
---------            ----------  -----------                          ------ --------------- ------
2026-11-26 07:14:09Z app-prod-11 C:\ProgramData\Temp\rtc_helper.sys true   Valid           8f42e9c1b07d6a543210fedcba9876543210abcdef0123456789abcdef012345

Example 2: Detecting EDR Service Stop or Tampering Attempts (Windows Event ID 7036 / 7045)

PowerShell — Hunting Service Control Events Targeting Security Agents
# Search System event log for service state changes or new service creations matching EDR/AV terms
$Pattern = "CSFalcon|Sense|WdFilter|Sentinel|Wazuh|Velociraptor|Endpoint|Antivirus|EDR"

Get-WinEvent -LogName System -MaxEvents 2000 | Where-Object {
    $_.Id -in @(7036, 7040, 7045) -and ($_.Message -match $Pattern)
} | Select-Object TimeCreated, Id, LevelDisplayName, Message | Format-Table -Wrap -AutoSize
SAMPLE OUTPUT
TimeCreated          Id LevelDisplayName Message
-----------          -- -------------- -------
2026-11-26 07:15:02 7036 Information    The Microsoft Defender Antivirus Service service entered the stopped state.

Example 3: Sigma Rule — Detecting Potential NTDLL Unhooking via KnownDlls / System32 Access

YAML (Sigma Detection Rule) — Suspicious Non-System Process Accessing ntdll.dll
title: Potential NTDLL Unhooking Disk Read
id: 8b4f2c10-6e91-4d3a-9c21-5f7e8a1b2c3d
status: experimental
description: Detects non-standard processes opening ntdll.dll from disk, a common step in user-mode hook unhooking.
logsource:
    product: windows
    category: file_access
detection:
    selection:
        TargetFilename|endswith: '\System32\ntdll.dll'
    filter_legitimate:
        Image|startswith:
            - 'C:\Windows\System32\'
            - 'C:\Windows\SysWOW64\'
            - 'C:\Program Files\'
            - 'C:\Program Files (x86)\'
    condition: selection and not filter_legitimate
falsepositives:
    - Custom internal diagnostic tools or debuggers
level: medium
SAMPLE OUTPUT
# Sigma / SIEM rule hit:
Rule Title : Potential NTDLL Unhooking Disk Read (8b4f2c10-6e91-4d3a-9c21-5f7e8a1b2c3d)
Host       : wkstn-dev-044
Image      : C:\Users\dev01\AppData\Local\Temp\loader.exe
TargetFile : C:\Windows\System32\ntdll.dll
Severity   : medium

Example 4: Hunting Direct/Indirect Syscall & Remote Memory Allocation Signals (KQL)

KQL — Correlating Suspicious Cross-Process Memory Writes & Thread Creation
// Look for non-browser, non-system processes creating remote threads or allocating executable memory
DeviceEvents
| where Timestamp > ago(24h)
| where ActionType in ("CreateRemoteThreadApiCall", "VirtualAllocApiCall", "WriteProcessMemoryApiCall")
| where InitiatingProcessFolderPath !startswith "C:\\Program Files\\"
| where InitiatingProcessFolderPath !startswith "C:\\Windows\\System32\\"
| summarize
    EventCount = count(),
    Actions = make_set(ActionType),
    TargetProcesses = make_set(FileName)
  by DeviceName, InitiatingProcessAccountName, InitiatingProcessFileName, InitiatingProcessCommandLine
| order by EventCount desc
SAMPLE OUTPUT
DeviceName InitiatingProcessAccountName InitiatingProcessFileName InitiatingProcessCommandLine EventCount Actions                        TargetProcesses
---------- ------------------------------ ------------------------- ---------------------------- ---------- -------                        ---------------
fin-srv-03 CORP\svc_batch                 updater_svc.exe           updater_svc.exe --worker     3          ["VirtualAllocApiCall",...]  ["explorer.exe"]

Example 5: Enabling LSA Protection (RunAsPPL) via PowerShell

PowerShell — Hardening LSASS with Protected Process Light (RunAsPPL)
# Configure RunAsPPL (1 = Enabled with UEFI lock where supported)
# Requires reboot to take effect on lsass.exe
$lsaPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa"
Set-ItemProperty -Path $lsaPath -Name "RunAsPPL" -Value 1 -Type DWord

Get-ItemProperty -Path $lsaPath -Name "RunAsPPL"
SAMPLE OUTPUT
RunAsPPL     : 1
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

Example 6: Auditing HVCI (Memory Integrity) & VBS Status via PowerShell

PowerShell — Verifying Virtualization-Based Security & Hypervisor-Protected Code Integrity
# Check DeviceGuard / VBS and HVCI status
Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard |
  Select-Object VirtualizationBasedSecurityStatus, SecurityServicesConfigured, SecurityServicesRunning
SAMPLE OUTPUT
VirtualizationBasedSecurityStatus SecurityServicesConfigured SecurityServicesRunning
----------------------------------- -------------------------- -----------------------
                                  2 {1, 2}                     {1, 2}

Example 7: Velociraptor VQL — Hunting Loaded Drivers Against Suspicious Names/Paths

VQL (Velociraptor) — Enumerating Loaded Kernel Modules Outside Standard Paths
SELECT
  Base,
  Size,
  Name,
  Path,
  Order
FROM artifact_call(artifact="Windows.System.Drivers")
WHERE NOT Path =~ "(?i)^\\\\SystemRoot\\\\(System32\\\\drivers|SysWOW64\\\\drivers)\\\\"
SAMPLE OUTPUT
Base               Size   Name           Path                                        Order
----               ----   ----           ----                                        -----
0xfffff80462100000 49152  rtc_helper.sys \??\C:\ProgramData\Temp\rtc_helper.sys   148

Example 8: Velociraptor VQL — Detecting Potential Hook Tampering in User-Mode Exports

VQL (Velociraptor) — Inspecting First Bytes of NtAllocateVirtualMemory in Running Processes
SELECT
  Pid,
  Name,
  Exe,
  read_file(filename=Exe, offset=0, length=4) AS HeaderBytes
FROM pslist()
WHERE NOT Name =~ "(?i)^(System|Registry|smss|csrss|wininit|services|lsass|svchost)\\.exe$"
LIMIT 25
SAMPLE OUTPUT
Pid   Name        Exe                                        HeaderBytes
---   ----        ---                                        -----------
4418  updater_svc C:\Users\dev01\AppData\Local\Temp\loader.exe 4d5a9000

Example 9: Wazuh Rule — Detecting Multiple Failed or Blocked Security Service Actions

XML (Wazuh Rule) — Alerting on Service Tampering / Stop Attempts

  
    18104
    CSFalconService|Sense|Wazuh|Velociraptor|WinDefend
    Defense Evasion Alert: Security agent service event observed on $(agent.name)
    
      T1562.001
    
  
SAMPLE OUTPUT
** Alert 1795682011.90214: - local,edr_tampering,defense_evasion
2026 Nov 26 07:15:05 app-prod-11->WinEvtLog
Rule: 100610 (level 14) -> 'Defense Evasion Alert: Security agent service event observed on app-prod-11'

Example 10: Auditing Installed Third-Party Kernel Drivers on Linux (lsmod & dmesg)

Bash (Linux Host Audit) — Inspecting Loaded Kernel Modules & Taint Flags
# Check kernel taint flags (/proc/sys/kernel/tainted > 0 indicates out-of-tree, unsigned, or forced modules)
cat /proc/sys/kernel/tainted

# List loaded kernel modules and verify module paths
lsmod | awk '{print $1}' | tail -n +2 | xargs -I{} modinfo -F filename {} 2>/dev/null
SAMPLE OUTPUT
12288
/lib/modules/6.8.0-45-generic/kernel/net/ipv4/nf_tables.ko
/lib/modules/6.8.0-45-generic/updates/dkms/custom_sensor.ko

5. Interactive EDR Tampering & Evasion Triage Simulator

Select an evasion indicator below to walk through how an analyst confirms whether an alert represents genuine tampering or benign administration:

← Previous: 1.3 Open-Source Endpoint Telemetry Next: 1.5 Cross-Platform Endpoint Auditing (Osquery) →