GetProcessHandleFromHwnd (GPHFH) Deep Dive#1947
Open
carlospolop wants to merge 1 commit intomasterfrom
Open
Conversation
Collaborator
Author
🔗 Additional ContextOriginal Blog Post: https://projectzero.google/2026/02/gphfh-deep-dive.html Content Categories: Based on the analysis, this content was categorized under "Windows Hardening -> Windows Local Privilege Escalation (or a new subpage under Windows LPE such as "Abusing GUI HWND-to-Process Handle APIs (GetProcessHandleFromHwnd / NtUserGetWindowProcessHandle)")". Repository Maintenance:
Review Notes:
Bot Version: HackTricks News Bot v1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
This Project Zero post reverse-engineers the Windows accessibility API GetProcessHandleFromHwnd across OS versions, showing how it evolved from a Vista-era user-mode hook/handle-duplication protocol into a Win32k kernel function (NtUserGetWindowProcessHandle) that (in Windows 10 1803+) could open arbitrary process handles using KernelMode access checks bypass. That design flaw enabled opening handles into processes that should be protected (notably Protected Process / PPL), and in some cases san...
🔧 Technical Details
When an OS/API provides a “GUI object -> process handle” conversion (e.g., HWND to process handle), the GUI object becomes a capability. If the implementation opens the target process using a kernel-trusted access mode (e.g., ObOpenObjectByPointer(..., KernelMode)) or otherwise bypasses normal ACL/protection checks, an attacker can request powerful rights (even if the caller couldn’t normally OpenProcess the target). Practical exploitation is: ensure the victim has at least one window on the same desktop, obtain/guess/enumerate its HWND, call the conversion API, and use the resulting rights (commonly PROCESS_VM_READ/PROCESS_VM_WRITE/PROCESS_VM_OPERATION) to compromise the target by reading/writing memory, allocating executable memory, and hijacking control flow.
A legacy pattern for safely returning a handle across processes is: inject a hook DLL into the window owner with SetWindowsHookEx, trigger it with a custom registered message (e.g., RegisterWindowMessage(L"WM_OLEACC_HOOK")), h...
🤖 Agent Actions
Summary:
Updated the UIAccess/Admin Protection page with a new section describing the HWND-to-process handle primitive (
GetProcessHandleFromHwnd/NtUserGetWindowProcessHandle), its security impact, practical abuse flow, and post-fix behavior, plus added the Project Zero reference.Files modified:
src/windows-hardening/windows-local-privilege-escalation/uiaccess-admin-protection-bypass.mdTests:
Next steps:
src/windows-hardening/windows-local-privilege-escalation/README.md.This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.