NtAlpcSendWaitReceivePort
Envía un mensaje ALPC en un puerto y opcionalmente espera respuesta o el siguiente mensaje entrante.
Prototipo
NTSTATUS NtAlpcSendWaitReceivePort( HANDLE PortHandle, ULONG Flags, PPORT_MESSAGE SendMessage, PALPC_MESSAGE_ATTRIBUTES SendMessageAttributes, PPORT_MESSAGE ReceiveMessage, PSIZE_T BufferLength, PALPC_MESSAGE_ATTRIBUTES ReceiveMessageAttributes, PLARGE_INTEGER Timeout );
Argumentos
| Name | Type | Dir | Description |
|---|---|---|---|
| PortHandle | HANDLE | in | Handle a un puerto ALPC (lado servidor o cliente, puerto de comunicación o de conexión). |
| Flags | ULONG | in | ALPC_MSGFLG_* (RELEASE_MESSAGE, SYNC_REQUEST, WAIT_USER_MODE, …) que controla la semántica de envío/recepción. |
| SendMessage | PPORT_MESSAGE | in | Mensaje saliente opcional; NULL para realizar sólo recepción. |
| SendMessageAttributes | PALPC_MESSAGE_ATTRIBUTES | in | Atributos del mensaje saliente (handle / contexto / vista / seguridad). |
| ReceiveMessage | PPORT_MESSAGE | out | Recibe la respuesta entrante o el siguiente mensaje en cola. |
| BufferLength | PSIZE_T | in/out | En entrada, tamaño del búfer ReceiveMessage; en salida, tamaño del mensaje recibido. |
| ReceiveMessageAttributes | PALPC_MESSAGE_ATTRIBUTES | in/out | Recibe los meta-atributos adjuntos al mensaje entrante. |
| Timeout | PLARGE_INTEGER | in | Tiempo de espera opcional (unidades de 100 ns, negativo = relativo). NULL = espera indefinida. |
IDs de syscalls por versión de Windows
| Versión de Windows | ID de syscall | Build |
|---|---|---|
| Win10 1507 | 0x88 | win10-1507 |
| Win10 1607 | 0x88 | win10-1607 |
| Win10 1703 | 0x89 | win10-1703 |
| Win10 1709 | 0x89 | win10-1709 |
| Win10 1803 | 0x8A | win10-1803 |
| Win10 1809 | 0x8A | win10-1809 |
| Win10 1903 | 0x8A | win10-1903 |
| Win10 1909 | 0x8A | win10-1909 |
| Win10 2004 | 0x8C | win10-2004 |
| Win10 20H2 | 0x8C | win10-20h2 |
| Win10 21H1 | 0x8C | win10-21h1 |
| Win10 21H2 | 0x8C | win10-21h2 |
| Win10 22H2 | 0x8C | win10-22h2 |
| Win11 21H2 | 0x8C | win11-21h2 |
| Win11 22H2 | 0x8C | win11-22h2 |
| Win11 23H2 | 0x8C | win11-23h2 |
| Win11 24H2 | 0x8E | win11-24h2 |
| Server 2016 | 0x88 | winserver-2016 |
| Server 2019 | 0x8A | winserver-2019 |
| Server 2022 | 0x8C | winserver-2022 |
| Server 2025 | 0x8E | winserver-2025 |
Módulo del kernel
APIs relacionadas
Stub del syscall
4C 8B D1 mov r10, rcx B8 8E 00 00 00 mov eax, 0x8E 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
Notas no documentadas
`NtAlpcSendWaitReceivePort` es el caballo de tiro de ALPC: cada llamada RPC sobre `ncalrpc` acaba en una o varias invocaciones de este syscall. Implementa cuatro patrones de alto nivel — send sólo, receive sólo, request/reply (síncrono), reply/wait-next (bucle de servidor) — seleccionados por Flags y por cuáles de SendMessage/ReceiveMessage son no NULL. La cabecera `PORT_MESSAGE` va seguida de un bloque opcional `ALPC_MESSAGE_ATTRIBUTES` que puede llevar handles duplicados, un blob de contexto de seguridad o una vista de sección compartida — son justamente esos atributos lo que convierte a ALPC en un objetivo LPE jugoso.
Uso común por malware
Dos patrones de abuso distintos: 1. **Exploit LPE**: toda cadena LPE ALPC termina en un `SendMessage` fabricado que dispara una ruta de código vulnerable en el servidor. CVE-2018-8440 enviaba un `ALPC_MESSAGE_ATTRIBUTE_HANDLE` falsificado al puerto ALPC del Task Scheduler; CVE-2019-1322 (SVCMOVER) abusaba services.exe vía ALPC; varios PoC de PrintNightmare alcanzan el endpoint ALPC del Print Spooler con este syscall. 2. **C2 IPC sigiloso**: frameworks de red team a veces construyen canales implante↔implante sobre un puerto ALPC sin nombre (creado con `NtAlpcCreatePort` y conectado vía `NtAlpcConnectPort`) porque ALPC es invisible para la telemetría de red de Sysmon. Baja capacidad pero suficiente para command-and-control.
Oportunidades de detección
Detección por llamada inviable — este syscall dispara millones de veces por hora en un host activo. Ángulos útiles: ETW `Microsoft-Windows-Kernel-ALPC` (cuando está activado) atribuye cada mensaje a nombre de puerto y PID; cargas `ALPC_MESSAGE_ATTRIBUTE_HANDLE` voluminosas desde procesos no privilegiados hacia servicios del sistema son sospechosas; la correlación con el ETW `Microsoft-Windows-RPC` (que se sitúa *por encima* de ALPC) da el UUID de la interfaz RPC invocada — un UUID inesperado desde un binario no Microsoft es la señal más fuerte. Los bugs LPE ALPC históricos se cazaron post-divulgación buscando atributos de handle apuntando a objetos de SYSTEM desde emisores en contexto de usuario.
Ejemplos de syscalls directos
asmx64 direct stub (Win11 24H2)
; Direct syscall stub for NtAlpcSendWaitReceivePort (SSN 0x8E on Win11 24H2)
NtAlpcSendWaitReceivePort PROC
mov r10, rcx ; PortHandle
mov eax, 8Eh ; SSN — version-sensitive
syscall
ret
NtAlpcSendWaitReceivePort ENDPcServer receive-reply loop
// Minimal ALPC server pump — receive, dispatch, reply.
#include <windows.h>
#include <winternl.h>
typedef NTSTATUS (NTAPI *pNtAlpcSendWaitReceivePort)(
HANDLE, ULONG, PVOID, PVOID, PVOID, PSIZE_T, PVOID, PLARGE_INTEGER);
void ServerPump(HANDLE hPort) {
pNtAlpcSendWaitReceivePort fn = (pNtAlpcSendWaitReceivePort)GetProcAddress(
GetModuleHandleA("ntdll.dll"), "NtAlpcSendWaitReceivePort");
BYTE recv[0x1000]; SIZE_T cb;
BYTE reply[0x1000];
for (;;) {
cb = sizeof(recv);
// Pure receive: SendMessage = NULL.
if (fn(hPort, 0, NULL, NULL, recv, &cb, NULL, NULL) != 0) break;
// ... build reply in 'reply' ...
// Send reply, wait for next request: ALPC_MSGFLG_RELEASE_MESSAGE = 0x10000.
cb = sizeof(recv);
fn(hPort, 0x10000, reply, NULL, recv, &cb, NULL, NULL);
}
}cClient SYNC_REQUEST (sync RPC)
// Synchronous request/reply on an already-connected ALPC port.
#include <windows.h>
#include <winternl.h>
#define ALPC_MSGFLG_SYNC_REQUEST 0x20000
typedef NTSTATUS (NTAPI *pNtAlpcSendWaitReceivePort)(
HANDLE, ULONG, PVOID, PVOID, PVOID, PSIZE_T, PVOID, PLARGE_INTEGER);
NTSTATUS Call(HANDLE hPort, PVOID req, SIZE_T reqLen, PVOID rsp, PSIZE_T rspLen) {
pNtAlpcSendWaitReceivePort fn = (pNtAlpcSendWaitReceivePort)GetProcAddress(
GetModuleHandleA("ntdll.dll"), "NtAlpcSendWaitReceivePort");
LARGE_INTEGER to; to.QuadPart = -5LL * 10000000LL; // 5 s
return fn(hPort, ALPC_MSGFLG_SYNC_REQUEST, req, NULL, rsp, rspLen, NULL, &to);
}Mapeos MITRE ATT&CK
Last verified: 2026-05-20