Read the docs

Uninitialised heap disclosure in FreeRDP Save Session Info PDU

Priority MEDIUM 44CWE-200Published · Updated

Key facts

Attack vector
Network
Privileges required
Low
User interaction
None
Attack complexity
Low
Impact type
Information disclosure
Confidentiality · integrity · availability
High · None · None
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-v649-94v2-p72q. Fix status from GitHub. Impact type from CWE-200.

Summary

FreeRDP up to and including 3.30.0 skips reserved pad fields in Save Session Info PDUs instead of zeroing them. The skipped bytes keep whatever the heap already held, and the PDU sends them over the network (CWE-200). A remote attacker with low privileges can read this leaked heap memory.

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

Description from the GitHub advisory

Three PDU writers in `libfreerdp/core/info.c` use `Stream_Seek` instead of `Stream_Zero` for reserved pad fields. `Stream_Seek` just moves the write cursor. It doesn't touch the bytes. So whatever the heap allocation already contained gets added into the PDU and sent over the wire. The largest pad is 576 bytes, in `rdp_write_logon_info_plain`: ```c static BOOL rdp_write_logon_info_plain(wStream* s) { if (!Stream_EnsureRemainingCapacity(s, 576)) return FALSE; Stream_Seek(s, 576); /* 576 bytes never written, sent on the wire */ return TRUE; } ``` | writer | line | pad | |---|---|---| | `rdp_write_logon_info_v2` | `info.c:1567` | 558 bytes | | `rdp_write_logon_info_plain` | `info.c:1581` | 576 bytes | | `rdp_write_logon_info_ex` | `info.c:1624` | 570 bytes | The buffer comes from `transport_send_stream_init`, which calls `Stream_New(nullptr, 4096)`. That's a plain `malloc`, not `calloc` (`winpr/libwinpr/utils/stream.c:94-101`). No StreamPool either; pooling is receive-only (`transport.c:1731`). So each PDU gets a fresh malloc that recycles whatever the allocator last freed in the 4096-byte class. Reconnect, get a new sample. Forty lines away in `capabilities.c:1531`, the same kind of pad is written correctly: `Stream_Zero(s, 64)`. ## Affected versions Introduced in `1b2b1c4ac` ("Add support for saveSessionInfo PDU"), 2016-02-18. The write path has never been touched since. Present in every 3.x release we checked: 3.0.0 through 3.30.0, and in `master`. 2.x has the same code but is out of support. We're reporting against 3.30.0 per `SECURITY.md` policy. ## Who is affected `freerdp-proxy` is the main concern. It's in-tree, built by default, and it forwards Save Session Info PDUs from upstream to downstream (`pf_update.c:317/332/675`). An attacker-controlled upstream target makes the proxy re-serialise the PDU and leak its own heap (shared across tenant sessions) to the downstream client. Third-party FreeRDP-based servers that call `rdpUpdate::SaveSessionInfo` are also affected. That's the documented public API for sending logon notifications. `freerdp-shadow` and `sfreerdp` are not affected. They never originate this PDU. ## Root cause ### What gets transmitted Buffer offset equals wire offset (`rdp_write_header` does no `memmove`): ``` transport_send_stream_init(.., 4096) -> 0 TPKT(4) + X.224(3) + MCS(8) = 15 -> 15 RDP_SHARE_CONTROL_HEADER = 6 -> 21 RDP_SHARE_DATA_HEADER = 12 -> 33 Stream_Write_UINT32(s, type) -> 37 Stream_Seek(s, 576) -> 613 leaked window = bytes [37, 613) ``` That's a 613-byte TPKT frame with `pduType2 = 0x26` (`PDUTYPE2_SAVE_SESSION_INFO`). ### Why the buffer is dirty ``` transport_send_stream_init -> Stream_New(nullptr, 4096) -> s->buffer = malloc(size) not calloc ... Stream_Free(s, TRUE) -> free(s->buffer) no scrub ``` `malloc(4096)` produces chunk size 0x1010, above the tcache ceiling. `free` puts it in the unsorted bin. Next `malloc(4096)` gets the exact same block back. Two per-connection buffers feed this bin without scrubbing: - `nla_server_recv_stream` (`nla.c:707`): holds the raw CredSSP TSRequest, including the NTLM `UserName`/`DomainName`/`Workstation` in cleartext UTF-16. - `rdstls_recv_authentication_request` (`rdstls.c:1092`): holds the client's password field. ## Impact 576 bytes of server heap per PDU. Unconditional. No special build flags, no config knobs, no race window. The peer reads the bytes after `infoType` and reconnects for a fresh sample. There is no limit on how many samples you can take. In our runs the leaked bytes were recycled handshake PDU data from the same connection: ``` session 1: TPKT len 613, pduType2 0x26, infoType 0x00000002 -- NON-ZERO PAD 78/576 session 2: TPKT len 613, pduType2 0x26, infoType 0x00000002 -- NON-ZERO PAD 305/576 ``` No crash, no corruption, just a confidentiality issue. The attacker doesn't get to choose what lands in the window; it's whatever the allocator had lying around in that size class. CVSS 3.1: `AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N`, 4.3 Medium. If the unlimited resampling pushes it to C:H, that's `AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N`, 6.5 Medium. PR:L because Save Session Info is post-logon. AC:L because there's no race and no special config. We score C:L because in the runs we recorded, the content was consistently the same recycled handshake buffer, not attacker-selected data. ## Conditional escalation: private key recovery We also managed to recover the server's full RSA private key from a single PDU. But that took four conditions that no FreeRDP server in the tree actually meets, so we're not claiming this as an attack against FreeRDP as shipped. The four conditions: 1. Server loads its PEM key from a file via `BIO_new_file`, not from an in-memory string. 2. The key load happens right before the notification, so the glibc stdio buffer (which held the PEM text) is the most recent free in the 4096-byte bin. This is the one that kills it. Every in-tree server loads the key at peer-accept (`sfreerdp.c:1158`, `mf_peer.c:390`, `wf_peer.c:258`) while the notification fires at Activate, a whole handshake later. Dozens of `malloc(4096)`/`free(4096)` cycles happen in between, pushing the PEM buffer out. Our demo server re-reads the PEM immediately before sending the PDU to force adjacency. 3. RSA key <= 1024 bits. The leaked window covers PEM bytes [37, 613). For RSA-1024, `n | e | d | p | q` all fit. For RSA-2048, `p` starts at offset 755, past the window. We verified this as a negative control. 4. `TlsSecLevel <= 1`. FreeRDP's default is level 2, which rejects 1024-bit certs outright. The mechanism: `BIO_new_file` -> glibc stdio buffer `malloc(4096)` -> `BIO_free_all` -> `fclose` -> `free` (unscrubbed) -> next `malloc(4096)` returns the same block -> `Stream_Seek(s, 576)` skips over it -> transmitted. The attacker base64-decodes the fragment, walks the DER INTEGERs, and tests every pair against the public modulus from the server's certificate. We tried to reach this without the forced adjacency. Sequential reconnects: 3/3 negative. Cross-connection race at concurrency 10 and 24 against `sfreerdp`: 0/180 PDUs contained any PEM text. The recycled chunk was always a handshake buffer from the same connection. The recovery itself is real (p*q == n, verified 3/3, proof-of-possession verified). It just requires conditions that don't exist in any shipped binary. ## Reproducing it ### Build and run the server ```sh docker build -t padlock-server . docker run --rm -p 3389:3389 -e MODE=adjacent padlock-server ``` `MODE=stock` for the heap leak only. `MODE=adjacent` adds the forced key-adjacency. `KEYBITS=2048` for the negative control. `--build-arg FREERDP_REF=master` for a different revision. ### Run the exploit Needs Python 3 (stdlib only) and a FreeRDP client (`brew install freerdp` on macOS, `apt install freerdp3-x11` on Debian/Ubuntu). ```sh python3 padlock_attack.py --host 127.0.0.1 --port 3389 --expect key ``` Against `MODE=stock`, use `--expect leak-only --samples 3`. The exploit grabs the server's public key from its TLS certificate over the wire (`certgrab.py`), then connects as a normal RDP client and reads the Save Session Info PDU. Capture uses FreeRDP's built-in `/dump:record` feature. No hooks, no `LD_PRELOAD`, no packet capture. ## Suggested fix Replace `Stream_Seek` with `Stream_Zero` in the three pad writes. `Stream_Zero` already exists and is used for the same purpose at `capabilities.c:1531`. ```diff --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ rdp_write_logon_info_v2 - Stream_Seek(s, logonInfoV2ReservedSize); + Stream_Zero(s, logonInfoV2ReservedSize); @@ rdp_write_logon_info_plain - Stream_Seek(s, 576); + Stream_Zero(s, 576); @@ rdp_write_logon_info_ex - Stream_Seek(s, 570); + Stream_Zero(s, 570); ``` Also worth scrubbing the 4096-byte receive buffers (`nla.c:2282`, `rdstls.c:1127`) on release, the way `sspi_SecBufferFree` already does. That way a future `Stream_Seek` mistake leaks zeros instead of a peer's credentials. Optionally, `setvbuf(fp, NULL, _IONBF, 0)` in the PEM reader so key material never sits in an unscrubbed glibc stdio buffer. ## Side-finding: OOB write in NTLM MIC computation (library API only) While looking at the NTLM code we found a missing bounds check in `ntlm_computeMicValue` (`winpr/libwinpr/sspi/NTLM/ntlm.c:934-946`). It zeros 16 bytes at an attacker-controlled offset past a heap allocation during NTLM AUTHENTICATE processing. The sibling function (`ntlm_compute_message_integrity_check`, `ntlm_compute.c:957-964`) does the same thing and has a bounds check. This one doesn't. Pre-auth, no credentials needed. ASan confirms it: `WRITE of size 16`, 48 bytes past a 248-byte region. Adding the VERSION flag shifts the write to +56, so the offset is attacker-controlled. The catch: this path only runs when the server has registered `SspiNtlmHashCallback` (`include/freerdp/peer.h:213`), a public API for custom NTLM validation. No shipped FreeRDP binary sets this callback. We had to write a custom server to trigger it. Real code bug in a documented API, but not reachable in anything FreeRDP ships. Fix: add the same guard the sibling has: ```c if ((size_t)ntlm->MessageIntegrityCheckOffset + 16 > ntlm->AuthenticateMessage.cbBuffer) return SEC_E_INVALID_TOKEN; ``` ## Files in this package - `report.md` -- this report - `Dockerfile` -- builds FreeRDP from source (non-ASan, glibc/ptmalloc) and the victim server - `padlock_victim.c` -- minimal FreeRDP peer server that sends Save Session Info on Activate - `rdp-server` -- container entrypoint (key generation, stock/adjacent mode switch) - `padlock_attack.py` -- the exploit: connects as a normal RDP client, reads the leaked window, attempts key reconstruction - `certgrab.py` -- grabs the server's public key from its TLS certificate - `dumpparse.py` -- parses FreeRDP's `/dump:record` stream format - `reconstruct.py` -- DER walk + factor search over the leaked bytes [padlock-remote.zip](https://github.com/user-attachments/files/30973080/padlock-remote.zip)

Why it matters now

Fix Fixed FreeRDP (freerdp): 3.31.0

SSVC decision points

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

Affected products

VendorProductAffected versionsFixed inStatusSource
—FreeRDP (freerdp)<= 3.30.03.31.0Patch availableGHSA-v649-94v2-p72q
  • FreeRDP (freerdp) Vendor— Affected <= 3.30.0 Fixed in 3.31.0 Patch available GHSA-v649-94v2-p72q

Remediation

Upgrade FreeRDP to version 3.31.0.

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

  • Fix · GHSA-v649-94v2-p72q FreeRDP (freerdp) Fixed in 3.31.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-v649-94v2-p72q

References

Sources

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