Read the docs

Out-of-bounds memory access in FreeRDP X11 client monitor selection

Priority MEDIUM 44CWE-125Published · Updated

Key facts

Attack vector
Local
Privileges required
None
User interaction
Required
Attack complexity
Low
Impact type
—
Confidentiality · integrity · availability
Low · Low · High
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-23pf-q83q-x45r. Fix status from GitHub.

Summary

FreeRDP from 3.11.0 through 3.30.0 does not check the monitor ID read from the selectedmonitors setting of a .rdp file in the X11 client. The value is used directly as an index into a monitor array (CWE-129), so a crafted file makes xfreerdp read and write memory outside that array. A local attacker needs a victim to open the malicious .rdp file, and no server connection is required.

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

Description from the GitHub advisory

## Summary A `.rdp` connection file can put any 32-bit value in `selectedmonitors`. The value lands in `FreeRDP_MonitorIds` with no range check, and `xf_detect_monitors()` later uses `MonitorIds[0]` directly as an index into a heap array whose size comes from the number of X monitors actually attached. On an ordinary one or two monitor desktop, `selectedmonitors:s:999` makes `client/X11/xf_monitor.c:620` form `&rdpmonitors[999]`, roughly 44 KB past a `calloc` of two elements. The code then reads two `int` fields through that pointer and, if either is non zero, writes `is_primary = TRUE` back through it. So this is an out of bounds read plus a conditional out of bounds write of a fixed value at an offset the attacker picks, in the default build of the X11 client, triggered by opening a file. ## Where it is The value is parsed with no bound. `client/common/file.c:2522-2551`: ```c if (~(size_t)file->SelectedMonitors) { size_t count = 0; char** ptr = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count); ... for (size_t x = 0; x < count; x++) { unsigned long val = 0; errno = 0; val = strtoul(ptr[x], nullptr, 0); if ((val >= UINT32_MAX) && (errno != 0)) { CommandLineParserFree(ptr); return FALSE; } list[x] = (UINT32)val; } ``` The only guard is the `strtoul` overflow check, and even that is an `&&` of two conditions rather than an `||`, so 999 or 0xFFFFFFFE goes straight into `MonitorIds[0]`. Nothing anywhere validates that a monitor id corresponds to an attached monitor. The array being indexed is sized from the X server, `client/X11/xf_monitor.c:253`: ```c rdpMonitor* rdpmonitors = calloc(vscreen->nmonitors + 1, sizeof(rdpMonitor)); ``` And the index is used raw, `client/X11/xf_monitor.c:619-626`: ```c UINT32 j = monitor_index; rdpMonitor* pmonitor = &rdpmonitors[j]; /* If the "default" monitor is not 0,0 use it */ if ((pmonitor->x != 0) || (pmonitor->y != 0)) { pmonitor->is_primary = TRUE; } ``` `monitor_index` was assigned five lines earlier from the settings array, `xf_monitor.c:600-606`: ```c if (freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) > 0) { UINT32* ids = freerdp_settings_get_pointer_array_writable( settings, FreeRDP_MonitorIds, 0); if (ids) monitor_index = *ids; } ``` There is a bounds-checked accessor for exactly this kind of lookup. `freerdp_settings_get_pointer_array_writable` compares `offset` against the array size and returns NULL when it is out of range (`libfreerdp/common/settings.c:1709-1713` for `FreeRDP_MonitorDefArray`). Before 3.11.0 this site used that accessor. It was replaced with the raw local `rdpmonitors` array, and the bound went with it. ## Attacker model Someone gets a victim to open an attacker-supplied `.rdp` file with an X11-based FreeRDP client (`xfreerdp`). No server needs to be reachable: the crash happens in `PreConnect`, before any RDP traffic. No special build flags, no non-default settings. This is the same delivery model as the `selectedmonitors` double-free (GHSA-f27x-frr8-j9hc) and the `.rdp` slash-option issue (GHSA-rq8f-9xjh-pr3m). ## Call chain Every hop below was read at tag 3.30.0. 1. `client/common/cmdline.c:5708` and `:5737`. When `argv[1]` looks like a connection file, the client calls `freerdp_client_settings_parse_connection_file(settings, argv[1])`. 2. `client/common/file.c:2522-2551`. `selectedmonitors` is split on commas and each token is written into `FreeRDP_MonitorIds` via `strtoul`, with `NumMonitorIds` set to the token count. 3. `client/X11/xf_client.c:2068` sets `instance->PreConnect = xf_pre_connect`, and `xf_client.c:1239` inside `xf_pre_connect` calls `xf_detect_monitors(xfc, &maxWidth, &maxHeight)`. The only condition is `!AuthenticationOnly`. 4. `client/X11/xf_monitor.c:253`. `rdpmonitors` is allocated with `vscreen->nmonitors + 1` elements. 5. `xf_monitor.c:292-305`. With multimon off (the default) the code forces `NumMonitorIds` to 1 but leaves the parsed value in `MonitorIds[0]`. The comment there says validation is unnecessary because an invalid monitor "will default back to current monitor later as a fallback", which is the assumption this report is about. 6. `xf_monitor.c:417` calls `xf_is_monitor_id_active(xfc, i)` for each attached monitor. That helper (`xf_monitor.c:119-140`) compares the X monitor id against the entries of `MonitorIds`, so 999 matches nothing and every monitor is skipped. The local `nmonitors` counter stays 0 and `primaryMonitorFound` (set only at `xf_monitor.c:490-493` inside that skipped loop) stays FALSE. 7. `xf_monitor.c:502-524`. Because `nmonitors == 0`, the fallback fills `rdpmonitors[0]` from the current monitor and sets `nmonitors = 1`, so `FreeRDP_MonitorCount` becomes 1 and execution enters the `MonitorCount > 0` block. 8. `xf_monitor.c:597`. `primaryMonitorFound` is still FALSE, `NumMonitorIds` is 1, so `monitor_index` is set to 999 and line 620 forms `&rdpmonitors[999]`. Step 6 is the part worth noticing: the value has to be an id that does not match any attached monitor for the fallback to run, and an id that does not match any attached monitor is exactly the value that is out of range as an index. ## Reproduction I did not run this. I do not have an X11 build environment here, so verification is source only and the call chain above is what I read, hop by hop, in the 3.30.0 tree. The steps to run it are: ```text $ cat > poc.rdp <<'EOF' full address:s:127.0.0.1:3389 selectedmonitors:s:999 EOF $ xfreerdp poc.rdp ``` Under ASan the expected report is a heap-buffer-overflow READ of 4 bytes in `xf_detect_monitors` at `xf_monitor.c:623`, and with a non-zero value at that address, a heap-buffer-overflow WRITE at `xf_monitor.c:625`. `999 * sizeof(rdpMonitor)` is about 44 KB, so on a typical desktop this is well outside the `calloc` region. A larger token pushes the offset further and lets the reporter pick roughly where the write lands. ## Suggested fix Two things are wrong and both are worth fixing. The narrow fix is to bound the index before dereferencing: reject or clamp `j` when it is not less than `vscreen->nmonitors + 1`, or go back to `freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, j)` and handle NULL, which is what the code did before 3.11.0. The real fix is that `MonitorIds` holds monitor ids, not indices into the packed `rdpmonitors` array, and the two only coincide when every attached monitor is selected. The correct lookup is to search `rdpmonitors[0 .. MonitorCount-1]` for the element whose `orig_screen` equals `monitor_index` (`orig_screen` is set at `xf_monitor.c:457`) and to fall back to `rdpmonitors[0]` when nothing matches, which is what the comment at `xf_monitor.c:300-303` already promises. Rejecting out-of-range ids at parse time in `client/common/file.c` would be good defence in depth but cannot be the whole fix, since the monitor set is not known when the `.rdp` file is parsed. ## Deduplication The closest published advisory is GHSA-f27x-frr8-j9hc, the double-free of `MonitorIds` on the `strtoul` error path in the same `client/common/file.c` block. That fix removed the stray `free(list)`. It did not add any validation of the parsed values, and it did not touch `client/X11/xf_monitor.c`, so the values still flow unbounded into the index at line 620. I checked the rest of the published FreeRDP advisories and none of them mention `xf_detect_monitors`, primary monitor selection, or `rdpmonitors`. ## Affected versions Present in 3.30.0, the latest release, and on `master`. The raw indexing was introduced in 3.11.0: 3.10.1 and earlier used the bounds-checked settings accessor at this site, 3.11.0 and later use `&rdpmonitors[j]`. So the range is 3.11.0 through 3.30.0 inclusive. I did not check the 2.x line. ## How I found it and a note on tooling I was reading the `selectedmonitors` parsing block in `client/common/file.c` after the double-free in it was fixed, and wanted to know what consumes the values that block writes. Following `FreeRDP_MonitorIds` into the X11 front end turned up the raw index. I then walked the `xf_detect_monitors` control flow to work out which combination of settings reaches line 620 with an unmatched id, and confirmed the line numbers against tag 3.30.0 and against `master`. I used AI tooling while investigating this and checked every hop by hand against the tagged source; since I could not build the X11 client here, the finding is code-verified rather than run.

Why it matters now

Fix Fixed 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>= 3.11.0, <= 3.30.03.31.0Patch availableGHSA-23pf-q83q-x45r
  • freerdp Vendor— Affected >= 3.11.0, <= 3.30.0 Fixed in 3.31.0 Patch available GHSA-23pf-q83q-x45r

Remediation

Upgrade FreeRDP to version 3.31.0, which fixes this flaw. Versions from 3.11.0 through 3.30.0 are affected.

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

  • Fix · GHSA-23pf-q83q-x45r freerdp Fixed in 3.31.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-23pf-q83q-x45r

References

Sources

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