Summary
A critical bounds-checking flaw in RustDesk's Windows clipboard redirection can cause peer-supplied data to be copied beyond the end of a paste consumer's buffer. When a local user pastes remote clipboard file contents, a malicious or compromised peer may trigger heap corruption and potentially influence code execution in the affected process.
Affected context
The vulnerability occurs in RustDesk's Windows clipboard redirection path when a remote peer provides file contents through the CLIPRDR protocol. It becomes risky when a local user pastes remote clipboard file data into an OLE consumer such as Windows Explorer, and the response length supplied by the peer exceeds the destination buffer requested by the consumer.
Exploit preconditions
- Attack surface: Windows clipboard file redirection over a RustDesk session
- Required access: A peer must be able to participate in or compromise a RustDesk connection and provide clipboard file-content responses
- Trigger point: A local user must paste remote clipboard file contents through an OLE consumer
- Why exploitation is possible: The response length is trusted and copied without being bounded by the caller-provided destination size, allowing data to extend past the allocated buffer
Why this happens
The underlying bug is improper input validation and an out-of-bounds write. RustDesk copies a peer-controlled file-content length into a caller-provided buffer without first enforcing that the length is no greater than the buffer capacity. The available comparison only handles a short-read condition after the copy has occurred, so it cannot prevent an oversized write. This maps primarily to CWE-787: Out-of-bounds Write, with CWE-20: Improper Input Validation describing the failure to constrain untrusted protocol data.
Potential impact
- A malicious peer could cause heap memory corruption in the local clipboard consumer
- The application or affected Windows process could crash
- An attacker could potentially influence corrupted memory and achieve code execution
- The issue could compromise the confidentiality or integrity of data handled by the affected process
- A successful attack could provide a stepping stone to broader endpoint compromise, depending on process privileges and exploitability
General mitigation guidance
Mitigation generally focuses on treating all peer-supplied protocol lengths as untrusted and enforcing destination-size limits before any memory operation.
Common defensive patterns include:
- Clamp or reject response lengths that exceed the caller-provided buffer capacity
- Validate protocol fields before allocating, copying, or processing associated data
- Use bounded copy operations whose limits are derived from the actual destination size
- Ensure short-read and oversized-response handling occurs before the copy
- Reduce clipboard redirection privileges and disable remote file clipboard features where they are not required
- Run desktop-session components with the least privilege practical and apply defense-in-depth endpoint protections
How teams detect issues like this
Organizations can look for this class of defect through:
- Static analysis rules identifying memory copies whose length derives from network or peer-controlled fields
- Code review checks tracing protocol lengths from response parsing through allocation and copy operations
- Tests that send zero-length, short, boundary-sized, and oversized protocol responses
- Fuzzing of CLIPRDR file-content response handling and OLE clipboard integration
- Policy enforcement requiring explicit bounds checks before every buffer write
- Automated security review tools that flag untrusted size values used in memory operations

