Read the docs

Incorrect permission in FreeRDP exposes soft-smartcard private key

Priority LOW 36CWE-732Published · Updated

Key facts

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

Attack profile from CVSS 3.1 · GHSA-q9p9-j22r-577p. Fix status from GitHub.

Summary

FreeRDP versions from 3.0.0 through 3.31.1 copy the private key of a soft-smartcard logon into a shared temporary directory using a file created with default permissions. On a multi-user Unix host with a permissive umask, a local user with low privileges can read that key while the file exists, which requires the user to supply the cert and key suboptions. The flaw is tracked as CWE-732.

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

Description from the GitHub advisory

### Summary When a user enables FreeRDP's soft-smartcard logon with a PEM certificate and private key on a multi-user Unix host, FreeRDP copies the private key into the shared system temporary directory for PKINIT. The production PEM writer opens that new file with mode `"w"` and never enforces owner-only permissions. With umask `022`, it creates mode `0644`, allowing another unprivileged local user to read the active private-key copy. This is a local temporary-file confidentiality issue. It is not remotely reachable through RDP, does not break Kerberos, and does not persist after FreeRDP overwrites and deletes the temporary file. Soft-smartcard logon is opt-in; the ordinary hardware-smartcard path is separate. ### Affected versions and prerequisites Commit `b3790d7` introduced the temporary soft-smartcard key file during 3.0 development. The behavior is absent from FreeRDP 2.11.8 and present in all 50 inspected stable 3.x tags from 3.0.0 through 3.31.1. It remains unchanged on current `master` at `193fe551`. No fixed release or exact public advisory is known. Required conditions are: - the user supplies the `cert:` and `key:` suboptions to `/smartcard-logon`; - FreeRDP runs on a multi-user Unix host with a shared searchable temporary directory; - the process has a permissive umask such as `022`; - an unprivileged local user observes and reads the file while it exists. The basename contains 32 random bytes, so it is not practically guessable in advance. A local user can nevertheless enumerate newly appearing entries in a conventional shared temporary directory. The temporary key is removed when the associated smartcard information is freed, limiting the exposure window. ### Technical details In FreeRDP 3.31.1, `smartcard_enumerateCerts` selects the software path when `FreeRDP_SmartcardEmulation` is enabled. `smartcardCertInfo_New` in `libfreerdp/core/smartcardlogon.c` creates a random path beneath `KNOWN_PATH_TEMP` and sends the private-key PEM to the generic writer: ```c info->keyPath = create_temporary_file(); WLog_DBG(TAG, "writing PKINIT key to %s", info->keyPath); if (!crypto_write_pem(info->keyPath, privKeyPEM, strlen(privKeyPEM))) goto fail; ``` `crypto_write_pem` in `libfreerdp/crypto/crypto.c` creates the file without a private mode: ```c const size_t size = strnlen(pem, length) + 1; size_t rc = 0; FILE* fp = winpr_fopen(filename, "w"); if (!fp) goto fail; rc = fwrite(pem, 1, size, fp); ``` On Unix, the resulting access bits depend on the process umask. There is no owner-only create, `chmod`, or permission check in the private-key path. `smartcardKeyInfo_Free` eventually calls `delete_file`, which overwrites and deletes the file, but this cleanup occurs after the key has already been exposed for its active lifetime. ### Reproduction The attached PoC calls the exported production `crypto_write_pem` function from a caller-provided FreeRDP shared build. The runner accepts only the exact FreeRDP 3.31.1 commit, the runtime-tested `fe8e4a68` master snapshot, or the source-reviewed current `193fe551` master snapshot. The build must match the supplied source checkout. From the disclosure directory, with a matching FreeRDP checkout and build alongside it: ```sh ./poc/run.sh ../FreeRDP ../FreeRDP/build ``` Observed result against the reviewed master build: ```text positive: umask=022 mode=644 group_read=yes other_read=yes restrictive-control: umask=077 mode=600 group_read=no other_read=no PASS: the production PEM writer inherits process umask for private-key files ``` The `022` positive case proves that the writer grants group and other read access. The otherwise identical `077` control proves that the different result comes from ambient umask rather than a hidden owner-only policy. The PoC writes only a dummy PEM-shaped string, contacts no server, and deletes its files and directory. <!-- POC_FILES_BEGIN --> #### `poc/pem_mode.c` <!-- BEGIN FILE: poc/pem_mode.c --> ```c #define _POSIX_C_SOURCE 200809L #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> extern int crypto_write_pem(const char* filename, const char* pem, size_t length); static int exercise(const char* directory, const char* label, mode_t mask, mode_t expected) { char path[512] = { 0 }; struct stat st = { 0 }; const char key[] = "-----BEGIN PRIVATE KEY-----\nDEMO-ONLY\n-----END PRIVATE KEY-----\n"; if (snprintf(path, sizeof(path), "%s/%s.pem", directory, label) >= (int)sizeof(path)) return 2; umask(mask); if (!crypto_write_pem(path, key, sizeof(key) - 1)) { fprintf(stderr, "%s: crypto_write_pem failed\n", label); return 2; } if (stat(path, &st) != 0) { fprintf(stderr, "%s: stat failed: %s\n", label, strerror(errno)); return 2; } const mode_t actual = st.st_mode & 0777; printf("%s: umask=%03o mode=%03o group_read=%s other_read=%s\n", label, mask, actual, (actual & S_IRGRP) ? "yes" : "no", (actual & S_IROTH) ? "yes" : "no"); unlink(path); return actual == expected ? 0 : 1; } int main(void) { char directory[] = "./freerdp-pem-mode.XXXXXX"; const mode_t original = umask(0); int rc = 0; umask(original); if (!mkdtemp(directory)) { fprintf(stderr, "mkdtemp failed: %s\n", strerror(errno)); return 2; } if (chmod(directory, 0755) != 0) { fprintf(stderr, "chmod failed: %s\n", strerror(errno)); rmdir(directory); return 2; } rc |= exercise(directory, "positive", 0022, 0644); rc |= exercise(directory, "restrictive-control", 0077, 0600); umask(original); rmdir(directory); if (rc == 0) puts("PASS: the production PEM writer inherits process umask for private-key files"); return rc; } ``` <!-- END FILE: poc/pem_mode.c --> #### `poc/run.sh` <!-- BEGIN FILE: poc/run.sh --> ```sh #!/bin/sh set -eu if [ "$#" -ne 2 ]; then echo "usage: $0 <freerdp-source> <freerdp-build>" >&2 exit 2 fi SOURCE=$(CDPATH= cd -- "$1" && pwd) BUILD=$(CDPATH= cd -- "$2" && pwd) REVISION=$(git -c safe.directory="$SOURCE" -C "$SOURCE" rev-parse HEAD) case "$REVISION" in 63b948ca5cb94307fd5444ee6e73927a41ccdab4) LABEL="FreeRDP 3.31.1" ;; fe8e4a68c7b7c6a80e0f7e92778ccf63df5ef7c3) LABEL="reviewed master snapshot" ;; 193fe551c9925c761722f589437decf9bc81d7aa) LABEL="current master snapshot" ;; *) echo "unsupported source revision: $REVISION" >&2 echo "use FreeRDP 3.31.1 or one of the two reviewed master snapshots" >&2 exit 2 ;; esac LIB=$(find "$BUILD/libfreerdp" -maxdepth 1 -type f -name 'libfreerdp3.so.*' | sort | head -n 1) if [ -z "$LIB" ]; then echo "libfreerdp3 shared library not found under $BUILD/libfreerdp" >&2 exit 2 fi LIBDIRS=$(find "$BUILD" -type f -name '*.so.*' -printf '%h\n' | sort -u | paste -sd: -) DEPENDENCIES=$(dirname -- "$BUILD")/deps if [ -d "$DEPENDENCIES" ]; then DEPDIRS=$(find "$DEPENDENCIES" -type f -name '*.so.*' -printf '%h\n' | sort -u | paste -sd: -) LIBDIRS="$LIBDIRS:$DEPDIRS" fi HERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) SANITIZERS="" if readelf -d "$LIB" | grep -q 'libasan'; then SANITIZERS="-fsanitize=address,undefined" fi echo "source: $LABEL ($REVISION)" echo "library: $LIB" cc -std=c11 -Wall -Wextra -Werror $SANITIZERS "$HERE/pem_mode.c" "$LIB" \ -Wl,--allow-shlib-undefined -o "$HERE/pem_mode" LD_LIBRARY_PATH="$LIBDIRS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" "$HERE/pem_mode" rm -f "$HERE/pem_mode" ``` <!-- END FILE: poc/run.sh --> <!-- POC_FILES_END --> ### Impact The demonstrated impact is disclosure of an active PKINIT private-key copy across local Unix account boundaries. A same-host unprivileged user can read the file under the stated conditions. We did not exercise certificate impersonation, Kerberos authentication, remote access, data modification, denial of service, or recovery after cleanup. The suggested CVSS vector is `CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:N/A:N` (4.4, Moderate). Attack complexity is High because the attacker must observe an unpredictable temporary name within the file's lifetime, and user interaction is Required because the victim must invoke the affected soft-smartcard flow. ### Suggested remediation Create the private-key file atomically with mode `0600`, independent of process umask, and write through the already-open descriptor. A private per-user runtime directory can add defense in depth but should not replace the file-level permission invariant. If the generic PEM helper must retain broader certificate behavior, add a private-key-specific writer or explicit permission parameter. Add a Unix regression test that sets umask `022`, exercises soft-smartcard key creation, and asserts `st_mode & 0777 == 0600`. Keep the `077` case as a control and verify cleanup still overwrites and deletes the temporary file. Until a fix ships, operators can use umask `077`, a private temporary directory, or avoid soft-smartcard emulation on multi-user systems.

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.0, <= 3.31.13.32.0Patch availableGHSA-q9p9-j22r-577p
  • FreeRDP (c) Vendor— Affected >= 3.0.0, <= 3.31.1 Fixed in 3.32.0 Patch available GHSA-q9p9-j22r-577p

Remediation

Upgrade FreeRDP to version 3.32.0 or later, which fixes this flaw.

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

  • Fix · GHSA-q9p9-j22r-577p FreeRDP (c) Fixed in 3.32.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-q9p9-j22r-577p

References

Sources

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