Skip to content

GUACAMOLE-2263: Harden CLIPRDR channel against FreeRDP 3.x state machine.#678

Open
escra wants to merge 1 commit into
apache:mainfrom
ESCRA-GmbH:fix/cliprdr-freerdp3-hardening-main
Open

GUACAMOLE-2263: Harden CLIPRDR channel against FreeRDP 3.x state machine.#678
escra wants to merge 1 commit into
apache:mainfrom
ESCRA-GmbH:fix/cliprdr-freerdp3-hardening-main

Conversation

@escra

@escra escra commented Jun 10, 2026

Copy link
Copy Markdown

This is the main-targeted forward-port of #661 (GUACAMOLE-2263), reworked on top of current main (HEAD e775052).

This could not be cherry-picked from the staging/1.6.1-based #661: main has already restructured the same functions (heap-allocated clipboard buffers from GUACAMOLE-2002, clipboard recording from GUACAMOLE-1969, and the changed guac_rdp_clipboard_alloc(client, buffer_size) signature). Only the additive hardening is applied here; existing main logic is preserved, not duplicated.

Problem

Under FreeRDP 3.x the CLIPRDR state machine is stricter: overlapping format-data requests can trigger errors (e.g. 1359), and failure/edge cases were not signalled back to the peer.

Fix

  • request_pending / request_lock mutex guarding outstanding format-data requests (prevents overlap).
  • Send and check CB_RESPONSE_FAIL for unsupported formats / failures.
  • NULL/empty-data guards in the format-data handlers; advertise capabilities/format-list even on partial failure (warn instead of abort).
  • Preserves main's heap allocation and guac_recording_report_clipboard().

Verification

Built against FreeRDP 3.26.0: cliprdr.c compiles warning-free and libguac-client-rdp links against libfreerdp3/libwinpr3. Preprocessor-confirmed that the FreeRDP-3 code paths (not the FreeRDP-2 #else branches) are compiled.

FreeRDP 3.x tracks pending CLIPRDR requests internally and disconnects
(error 1359) when a Format Data Response arrives without a matching
pending request, or when an expected response is never sent. Forward and
backward clipboard transfers could desynchronize the channel and tear
down otherwise healthy RDP sessions.

This adds a request_pending/request_lock state machine on the existing
guac_rdp_clipboard structure to prevent overlapping Format Data Requests,
clears stale requests when a new Format List arrives, sends a
CB_RESPONSE_FAIL Format Data Response for unsupported formats instead of
silently dropping the request, evaluates CB_RESPONSE_FAIL on incoming
responses, and guards against NULL/empty clipboard data. monitor_ready
and the clipboard end handler now advertise capabilities and the format
list even if an individual PDU fails.

The hardening is layered on top of the current main structure, preserving
the heap-allocated clipboard buffers (GUACAMOLE-2002) and clipboard
recording (GUACAMOLE-1969) and the guac_rdp_clipboard_alloc(client,
buffer_size) signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant