NtAlpcImpersonateClientOfPort
Primitive d'impersonation principale d'un serveur ALPC — endosse le contexte de sécurité du client ayant envoyé un message.
Prototype
NTSTATUS NtAlpcImpersonateClientOfPort( HANDLE PortHandle, PPORT_MESSAGE Message, PALPC_IMPERSONATE_INFO Flags );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| PortHandle | HANDLE | in | Handle vers le port de communication ALPC côté serveur renvoyé par NtAlpcAcceptConnectPort. |
| Message | PPORT_MESSAGE | in | Le PORT_MESSAGE tout juste reçu du client dont le token doit être impersonné. Les builds pré-Win10 acceptaient NULL. |
| Flags | PALPC_IMPERSONATE_INFO | in | ALPC_IMPERSONATE_INFO avec le niveau d'impersonation demandé (anonymous / identify / impersonate / delegate) et les drapeaux de token requis. NULL = utilise la QoS fournie à la connexion. |
IDs de syscalls par version de Windows
| Version de Windows | ID de syscall | 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 |
Module noyau
APIs liées
Stub du syscall
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
Notes non documentées
`NtAlpcImpersonateClientOfPort` est l'analogue ALPC de `ImpersonateNamedPipeClient` : le thread serveur qui vient de recevoir un message endosse temporairement le token primaire du client, effectue une opération privilégiée pour son compte, puis appelle `RevertToSelf`. Le niveau d'impersonation est borné par le `SECURITY_QUALITY_OF_SERVICE.ImpersonationLevel` du client au moment du connect, mais un serveur demandant *Impersonate* sans override QoS côté client reste la valeur par défaut pour quasi tous les services Windows. Tout appel Win32 / RPC `RpcImpersonateClient` sur une liaison `ncalrpc` finit ici. Implémentation : `AlpcpImpersonateClient` dans `ntoskrnl.exe`, qui appelle `SeImpersonateClientEx`.
Usage courant par les malwares
**C'est le syscall ALPC à plus forte valeur pour l'élévation de privilèges** — mais, surtout, le bug est presque toujours dans l'*appelant*, pas dans le syscall lui-même. Le pattern : un service tournant en SYSTEM expose un endpoint ALPC, accepte une connexion d'un client non privilégié, l'impersonne pour faire un access check (« cet utilisateur peut-il supprimer ce fichier ? »), puis **oublie de revert** avant l'action privilégiée — ou fait le check sur un objet différent de celui sur lequel il agit (TOCTOU). CVE-2018-8440 (LPE Task Scheduler ALPC de SandboxEscaper), CVE-2019-1130 (impersonation UMPS), CVE-2020-0668 (LPE Windows Service Tracing) et plusieurs variantes PrintNightmare Print Spooler reposent toutes sur ce type d'abus d'impersonation. Le malware n'*appelle* généralement pas ce syscall — il envoie le bon message ALPC au bon moment pour piéger un service SYSTEM qui le fait.
Opportunités de détection
Côté *appelant* : le syscall est invoqué par à peu près chaque serveur RPC Windows à chaque message — inutile comme signal primaire. Côté *exploit* : se concentrer sur les conséquences. Sysmon Event ID 1 (Process Create) avec `ParentImage=services.exe` / `spoolsv.exe` / `taskschd.exe`, `User=SYSTEM` mais un token dont l'`IntegrityLevel` ne correspond pas aux attentes est un signal fort. Les rafales ETW `Microsoft-Windows-Security-Auditing` Event ID 4624 (logon) de type 9 (NewCredentials) depuis un service host sont suspectes. Les mitigations noyau (famille `ImpersonateCheck` de Microsoft, `RpcServerRegisterAuthInfoExW` avec SIDs restreints) réduisent l'exposition plus sûrement que les règles de détection.
Exemples de syscalls directs
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.
Mappings MITRE ATT&CK
Last verified: 2026-05-20