Read the docs

Uninitialized memory leak to server in FreeRDP smartcard redirection

Priority LOW 35CWE-200Published · Updated

Key facts

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

Attack profile from CVSS 3.1 · GHSA-f554-v4xw-5j39. Fix status from GitHub. Impact type from CWE-200.

Summary

FreeRDP from 3.0.0 before 3.32.0 leaks uninitialized client memory to a malicious or compromised RDP server when smartcard redirection is enabled. The server sends an SCardTransmit request with an invalid card handle and a nonzero receive length, and the response packer still returns the unset receive buffer bytes. A user only needs to connect to such a server, and the sources show stale memory contents, not a specific secret.

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

Description from the GitHub advisory

### Summary When a user connects a FreeRDP client to a malicious or compromised RDP server with smartcard redirection enabled, the server can send an `SCardTransmit` request with an invalid card handle and a nonzero receive length. FreeRDP allocates that receive buffer without initializing it. The smartcard backend returns an error before changing the length, but the response packer still serializes the requested number of bytes to the server. This is a client-memory disclosure primitive, not a smartcard authentication bypass. The requested receive length is capped at 66,560 bytes and the operation can be repeated, but the exact contents depend on allocator reuse. Validation did not recover a particular PIN, key, credential, pointer, or other secret, so the report does not claim reliable targeted secret recovery, integrity impact, or availability impact. The earliest verified affected release is 3.0.0. The same material logic was inspected in 3.0.0, 3.10.3, 3.20.2, 3.28.0, 3.29.0, 3.31.1, and current `master`. ### Root cause In `libfreerdp/utils/smartcard_call.c`, `smartcard_Transmit_Call` caps the server-controlled `cbRecvLength` at 66,560, allocates that many bytes with `malloc`, and stores the full count in `ret.cbRecvLength`. It then invokes the selected `SCardTransmit` backend and calls `smartcard_pack_transmit_return` regardless of the returned error. The emulated backend checks the card handle before its success-only block. On an invalid handle it does not initialize `pbRecvBuffer` or assign through `pcbRecvLength`. The PC/SC wrapper likewise returns on a failed card-handle lookup before changing the count. In `libfreerdp/utils/smartcard_pack.c`, `smartcard_pack_transmit_return` does not gate the buffer on `ret->ReturnCode`: ```c if (!ret->pbRecvBuffer) cbRecvLength = 0; Stream_Write_UINT32(s, cbRecvLength); if (!smartcard_ndr_pointer_write(s, &index, cbRecvLength)) return SCARD_E_NO_MEMORY; status = smartcard_ndr_write(s, ret->pbRecvBuffer, ret->cbRecvLength, 1, NDR_PTR_SIMPLE); if (status != SCARD_S_SUCCESS) return status; return ret->ReturnCode; ``` Consequently, an early backend error leaves the requested count attached to an untouched allocation, and the packer copies those bytes into the RDPESC response. ### Security impact and prerequisites - The user must initiate a connection to the malicious or compromised RDP server with smartcard redirection enabled. - The server needs no client-side account or other client privilege. - The server controls the transmit card handle and requested receive length and can deterministically select an invalid handle. - The production response packer returns bytes from the supplied receive buffer even when `ReturnCode` is `SCARD_E_INVALID_HANDLE`. - The demonstrated effect is disclosure of stale receive-buffer bytes to the connected server. No specific secret contents were demonstrated. ### Proof of concept The following local-only reproducer uses the production FreeRDP response packer. Its positive case supplies an eight-byte marker as the retained receive-buffer contents for `SCARD_E_INVALID_HANDLE`; the null-buffer control keeps the same error and length but supplies no receive buffer. By default, the script downloads and verifies the public 3.31.1 source archive, builds the necessary libraries, compiles the harness, and runs both cases. It does not connect to an RDP server or access a physical smartcard. Save these two files in one directory, make `run.sh` executable, and run `./run.sh`. <!-- BEGIN FILE: transmit_pack_repro.c --> ```c #include <freerdp/utils/smartcard_pack.h> #include <winpr/stream.h> #include <stdio.h> #include <string.h> static int contains(const BYTE* haystack, size_t haystack_len, const BYTE* needle, size_t needle_len) { for (size_t i = 0; i + needle_len <= haystack_len; i++) { if (memcmp(&haystack[i], needle, needle_len) == 0) return 1; } return 0; } static void run_case(const char* name, BYTE* buffer, DWORD length) { static const BYTE marker[] = { 0xde, 0xad, 0xbe, 0xef, 0x41, 0x42, 0x43, 0x44 }; wStream* stream = Stream_New(NULL, 128); Transmit_Return ret = { 0 }; ret.ReturnCode = SCARD_E_INVALID_HANDLE; ret.cbRecvLength = length; ret.pbRecvBuffer = buffer; LONG rc = smartcard_pack_transmit_return(stream, &ret); printf("%s pack_rc=%08lx encoded=%zu marker_present=%d\n", name, (unsigned long)rc, Stream_GetPosition(stream), contains(Stream_Buffer(stream), Stream_GetPosition(stream), marker, sizeof(marker))); Stream_Free(stream, TRUE); } int main(void) { BYTE marker[] = { 0xde, 0xad, 0xbe, 0xef, 0x41, 0x42, 0x43, 0x44 }; run_case("error_with_buffer", marker, sizeof(marker)); run_case("error_without_buffer", NULL, sizeof(marker)); return 0; } ``` <!-- END FILE: transmit_pack_repro.c --> <!-- BEGIN FILE: run.sh --> ```sh #!/bin/sh set -eu VERSION=3.31.1 ARCHIVE_SHA256=254de9fe176758e9787347469fb310523782f03c61130508b51b266e374eb6c1 BASE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) WORK_DIR=${WORK_DIR:-"$BASE_DIR/.build"} ARCHIVE="$WORK_DIR/$VERSION.tar.gz" SOURCE=${SOURCE_DIR:-"$WORK_DIR/FreeRDP-$VERSION"} BUILD=${BUILD_DIR:-"$WORK_DIR/build"} mkdir -p "$WORK_DIR" if { [ -n "${SOURCE_DIR:-}" ] && [ -z "${BUILD_DIR:-}" ]; } || { [ -z "${SOURCE_DIR:-}" ] && [ -n "${BUILD_DIR:-}" ]; }; then echo "SOURCE_DIR and BUILD_DIR must be supplied together" >&2 exit 2 fi if [ -z "${SOURCE_DIR:-}" ] || [ -z "${BUILD_DIR:-}" ]; then if [ ! -f "$ARCHIVE" ]; then curl -fL --retry 3 -o "$ARCHIVE" \ "https://github.com/FreeRDP/FreeRDP/archive/refs/tags/$VERSION.tar.gz" fi printf '%s %s\n' "$ARCHIVE_SHA256" "$ARCHIVE" | sha256sum -c - rm -rf "$SOURCE" "$BUILD" tar -xzf "$ARCHIVE" -C "$WORK_DIR" if command -v cmake >/dev/null 2>&1; then CMAKE=cmake else CMAKE="python3 -m cmake" fi $CMAKE -S "$SOURCE" -B "$BUILD" \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_KRB5=OFF -DWITH_UNICODE_BUILTIN=ON \ -DWITH_SWSCALE=OFF -DWITH_FFMPEG=OFF -DWITH_DSP_FFMPEG=OFF \ -DWITH_VIDEO_FFMPEG=OFF -DWITH_CAIRO=OFF -DWITH_X11=OFF -DWITH_FUSE=OFF \ -DWITH_CLIENT=OFF -DWITH_SERVER=OFF -DWITH_CHANNELS=OFF \ -DWITH_MANPAGES=OFF -DWITH_SAMPLE=OFF -DWITH_TESTING=OFF \ -DWITH_JPEG=OFF -DWITH_WEBP=OFF -DWITH_PNG=OFF $CMAKE --build "$BUILD" --target freerdp -j"${JOBS:-2}" fi FREERDP_LIB=${FREERDP_LIB:-"$BUILD/libfreerdp/libfreerdp3.so"} WINPR_LIB=${WINPR_LIB:-"$BUILD/winpr/libwinpr/libwinpr3.so"} LIBRARY_PATHS=${LIBRARY_PATHS:-"$BUILD/libfreerdp:$BUILD/winpr/libwinpr"} test -f "$FREERDP_LIB" test -f "$WINPR_LIB" resolve_shared() { name=$1 path=$(cc -print-file-name="$name") if [ "$path" != "$name" ] && [ -f "$path" ]; then printf '%s\n' "$path" return fi ldconfig -p 2>/dev/null | awk -v n="$name" \ '$1 == n || index($1, n ".") == 1 { print $NF; exit }' } SSL_LIB=$(resolve_shared libssl.so) CRYPTO_LIB=$(resolve_shared libcrypto.so) ZLIB_LIB=$(resolve_shared libz.so) test -f "$SSL_LIB" test -f "$CRYPTO_LIB" test -f "$ZLIB_LIB" SYSTEM_LIBRARY_PATHS=$(dirname "$SSL_LIB") SYSTEM_LIBRARY_PATHS="$SYSTEM_LIBRARY_PATHS:$(dirname "$CRYPTO_LIB"):$(dirname "$ZLIB_LIB")" RUN_LIBRARY_PATHS="$LIBRARY_PATHS:$SYSTEM_LIBRARY_PATHS" cc ${CPPFLAGS:-} ${CFLAGS:--g -O2} \ -I"$SOURCE/include" -I"$SOURCE/winpr/include" \ -I"$BUILD/include" -I"$BUILD/winpr/include" \ "$BASE_DIR/transmit_pack_repro.c" \ -o "$WORK_DIR/transmit_pack_repro" \ "$FREERDP_LIB" "$WINPR_LIB" \ ${LDFLAGS:-} \ -Wl,-rpath,"$RUN_LIBRARY_PATHS" \ "$SSL_LIB" "$CRYPTO_LIB" "$ZLIB_LIB" -lpthread -ldl -lm LD_LIBRARY_PATH="$RUN_LIBRARY_PATHS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \ "$WORK_DIR/transmit_pack_repro" | tee "$WORK_DIR/output.txt" grep -Fx 'error_with_buffer pack_rc=ffffffff80100003 encoded=24 marker_present=1' \ "$WORK_DIR/output.txt" grep -Fx 'error_without_buffer pack_rc=ffffffff80100003 encoded=24 marker_present=0' \ "$WORK_DIR/output.txt" ``` <!-- END FILE: run.sh --> Observed output: ```text error_with_buffer pack_rc=ffffffff80100003 encoded=24 marker_present=1 error_without_buffer pack_rc=ffffffff80100003 encoded=24 marker_present=0 ``` The positive case confirms that the error status does not suppress receive-buffer serialization. The null-buffer control confirms that the marker is not part of fixed response metadata. ### Suggested remediation Do not serialize receive-buffer bytes after a failed `SCardTransmit`. Set the effective returned buffer length to zero unless the backend successfully initialized that many bytes. If an error such as `SCARD_E_INSUFFICIENT_BUFFER` must preserve a required-size value, encode the count as metadata without serializing the receive allocation. In addition, make `smartcard_pack_transmit_return` use the same validated effective length for both its NDR length fields and the final `smartcard_ndr_write`. Add regression tests for invalid handles in both the emulated and PC/SC backends, successful transmission, null receive buffers, and insufficient-buffer responses.

Why it matters now

Fix Fixed FreeRDP (c): 3.32.0

SSVC decision points

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

Affected products

VendorProductAffected versionsFixed inStatusSource
—FreeRDP (c)>= 3.0.03.32.0Patch availableGHSA-f554-v4xw-5j39
  • FreeRDP (c) Vendor— Affected >= 3.0.0 Fixed in 3.32.0 Patch available GHSA-f554-v4xw-5j39

Remediation

Upgrade FreeRDP to version 3.32.0, the fixed version.

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

  • Fix · GHSA-f554-v4xw-5j39 FreeRDP (c) Fixed in 3.32.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-f554-v4xw-5j39

References

Sources

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