NtAlpcImpersonateClientOfPort
Primäre Impersonation-Primitive eines ALPC-Servers — übernimmt den Sicherheitskontext des Clients, der eine Nachricht gesendet hat.
Prototyp
NTSTATUS NtAlpcImpersonateClientOfPort( HANDLE PortHandle, PPORT_MESSAGE Message, PALPC_IMPERSONATE_INFO Flags );
Argumente
| Name | Type | Dir | Description |
|---|---|---|---|
| PortHandle | HANDLE | in | Handle auf den server-seitigen ALPC-Kommunikationsport, geliefert von NtAlpcAcceptConnectPort. |
| Message | PPORT_MESSAGE | in | Die gerade vom Client empfangene PORT_MESSAGE, dessen Token impersoniert werden soll. Pre-Win10-Builds akzeptierten NULL. |
| Flags | PALPC_IMPERSONATE_INFO | in | ALPC_IMPERSONATE_INFO mit angefordertem Impersonation-Level (anonymous / identify / impersonate / delegate) und benötigten Token-Flags. NULL = nutzt die zur Connect-Zeit gelieferte QoS. |
Syscall-IDs pro Windows-Version
| Windows-Version | Syscall-ID | Build |
|---|---|---|
| Win10 1507 | 0x82 | win10-1507 |
| Win10 1607 | 0x82 | win10-1607 |
| Win10 1703 | 0x83 | win10-1703 |
| Win10 1709 | 0x83 | win10-1709 |
| Win10 1803 | 0x84 | win10-1803 |
| Win10 1809 | 0x84 | win10-1809 |
| Win10 1903 | 0x84 | win10-1903 |
| Win10 1909 | 0x84 | win10-1909 |
| Win10 2004 | 0x86 | win10-2004 |
| Win10 20H2 | 0x86 | win10-20h2 |
| Win10 21H1 | 0x86 | win10-21h1 |
| Win10 21H2 | 0x86 | win10-21h2 |
| Win10 22H2 | 0x86 | win10-22h2 |
| Win11 21H2 | 0x86 | win11-21h2 |
| Win11 22H2 | 0x86 | win11-22h2 |
| Win11 23H2 | 0x86 | win11-23h2 |
| Win11 24H2 | 0x88 | win11-24h2 |
| Server 2016 | 0x82 | winserver-2016 |
| Server 2019 | 0x84 | winserver-2019 |
| Server 2022 | 0x86 | winserver-2022 |
| Server 2025 | 0x88 | winserver-2025 |
Kernel-Modul
Verwandte APIs
Syscall-Stub
4C 8B D1 mov r10, rcx B8 88 00 00 00 mov eax, 0x88 F6 04 25 08 03 FE 7F 01 test byte ptr [0x7FFE0308], 1 75 03 jne short +3 0F 05 syscall C3 ret CD 2E int 2Eh C3 ret
Undokumentierte Hinweise
`NtAlpcImpersonateClientOfPort` ist das ALPC-Pendant zu `ImpersonateNamedPipeClient`: Der Server-Thread, der gerade eine Nachricht empfangen hat, übernimmt vorübergehend das Primary-Token des Clients, führt eine privilegierte Operation in dessen Namen aus und ruft anschließend `RevertToSelf` auf. Der Impersonation-Level ist durch das `SECURITY_QUALITY_OF_SERVICE.ImpersonationLevel` des Clients beim Connect begrenzt, doch ein Server, der *Impersonate* ohne Client-QoS-Override anfordert, ist die Voreinstellung für fast jeden Windows-Dienst. Jeder Win32-/RPC-`RpcImpersonateClient`-Aufruf gegen ein `ncalrpc`-Binding landet hier. Implementierung: `AlpcpImpersonateClient` in `ntoskrnl.exe`, ruft `SeImpersonateClientEx`.
Häufige Malware-Nutzung
**Dies ist der wertvollste ALPC-Syscall für Privilege Escalation** — entscheidend ist jedoch: Der Bug steckt fast immer im *Aufrufer*, nicht im Syscall selbst. Das Muster: Ein als SYSTEM laufender Dienst exponiert einen ALPC-Endpoint, akzeptiert eine Verbindung eines unprivilegierten Clients, impersoniert diesen für einen Access-Check ("Darf dieser User diese Datei löschen?") und **vergisst dann das Reverten** vor der privilegierten Aktion — oder prüft auf einem anderen Objekt als dem, auf das gehandelt wird (TOCTOU). CVE-2018-8440 (SandboxEscapers Task-Scheduler-ALPC-LPE), CVE-2019-1130 (UMPS-Impersonation), CVE-2020-0668 (Windows-Service-Tracing-LPE) und mehrere Print-Spooler-PrintNightmare-Varianten beruhen alle auf solchem Impersonations-Missbrauch. Malware *ruft* diesen Syscall meist nicht selbst — sie sendet die richtige ALPC-Nachricht zum richtigen Zeitpunkt, um einen SYSTEM-Dienst dazu zu bringen.
Erkennungsmöglichkeiten
Auf der *Aufrufer*-Seite: Der Syscall wird quasi von jedem Windows-RPC-Server bei jeder Nachricht aufgerufen — als primäres Signal nutzlos. Auf der *Exploit*-Seite: auf die Folgen fokussieren. Sysmon Event ID 1 (Process Create) mit `ParentImage=services.exe` / `spoolsv.exe` / `taskschd.exe`, `User=SYSTEM`, aber einem Token, dessen `IntegrityLevel` nicht passt, ist ein starkes Signal. ETW `Microsoft-Windows-Security-Auditing` Event ID 4624 (Logon) Typ 9 (NewCredentials) in Bursts aus einem Service-Host ist verdächtig. Kernel-Mitigations (Microsofts `ImpersonateCheck`-Familie, `RpcServerRegisterAuthInfoExW` mit Restricted-SIDs) senken die Exposition zuverlässiger als Detektionsregeln.
Direkte Syscall-Beispiele
asmx64 direct stub (Win11 24H2)
; Direct syscall stub for NtAlpcImpersonateClientOfPort (SSN 0x88 on Win11 24H2)
NtAlpcImpersonateClientOfPort PROC
mov r10, rcx ; PortHandle
mov eax, 88h ; SSN — drifts per build
syscall
ret
NtAlpcImpersonateClientOfPort ENDPcALPC server-side impersonation (the canonical SAFE pattern)
// The bug class lives in callers that forget RevertToSelf, or that
// perform the privileged work on a different object than the one checked.
#include <windows.h>
#include <winternl.h>
typedef struct _ALPC_IMPERSONATE_INFO {
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
ULONG Flags;
ULONG RequiredImpersonationLevel;
} ALPC_IMPERSONATE_INFO, *PALPC_IMPERSONATE_INFO;
typedef NTSTATUS (NTAPI *pNtAlpcImpersonateClientOfPort)(
HANDLE, PPORT_MESSAGE, PALPC_IMPERSONATE_INFO);
NTSTATUS DoAsClient(HANDLE hCommPort, PPORT_MESSAGE pMsg,
NTSTATUS (*work)(void)) {
pNtAlpcImpersonateClientOfPort imp = (pNtAlpcImpersonateClientOfPort)
GetProcAddress(GetModuleHandleA("ntdll.dll"),
"NtAlpcImpersonateClientOfPort");
NTSTATUS st = imp(hCommPort, pMsg, NULL /* default QoS */);
if (!NT_SUCCESS(st)) return st;
st = work(); // ALL privileged work happens here
RevertToSelf(); // NEVER skip — exploit class is forgetting this
return st;
}cNote: typical CVE pattern (illustration only, not a working exploit)
// Real ALPC LPE chains (CVE-2018-8440, CVE-2020-0668, PrintNightmare variants) // trick a privileged service into calling NtAlpcImpersonateClientOfPort against // an attacker-controlled message, then performing FS / registry I/O AFTER the // impersonation has either been reverted or never applied to the right object. // The syscall itself behaves correctly — the vulnerability lives in the service. // This file documents the syscall only; PoCs belong with the CVE references.
MITRE ATT&CK-Mappings
Last verified: 2026-05-20