Files
Marc-André Moreau c3dd17e607 fix(dvc): decompress the compressed data PDUs of DRDYNVC version 3 (#2173)
## Problem

`DrdynvcClient` echoes the server's capabilities version. When a server
offers version 3, the client therefore claims support for
DYNVC_DATA_FIRST_COMPRESSED (0x06) and DYNVC_DATA_COMPRESSED (0x07),
MS-RDPEDYC 2.2.3.3 and 2.2.3.4. It could not decode either:
`DrdynvcServerPdu::decode` had no arm for them. A server that used them
would break the DRDYNVC channel.

## Fix

This PR implements version 3 rather than answering with version 2. The
first commit downgraded the answer; the second replaces the downgrade
with real support.

- **`ironrdp-bulk`: new `rdp8` module.** An RDP 8.0 bulk decompressor
(MS-RDPEGFX 3.1.9.1) that is `no_std` (alloc only) and has no
dependencies. It accepts `PACKET_COMPR_TYPE_RDP8` (0x04) and
`PACKET_COMPR_TYPE_RDP8_LITE` (0x06), the type DVC segments carry. It
has two profiles. `Rdp8Decompressor::new()` is the graphics profile: a
2.5 MB history, 64 MiB per segment and 256 MiB per multipart message,
matching the existing decoder. `Rdp8Decompressor::new_lite()` is the RDP
8.0 Lite profile defined in MS-RDPEDYC 2.2.3.3: an 8,192-byte history
and maximum match distance, at most 8,192 uncompressed bytes per
segment, and a single segment per message. The existing ZGFX decoder in
`ironrdp-graphics` couldn't be reused: it needs `std` and `num-derive`
(a proc-macro), which core-tier `ironrdp-dvc` cannot depend on, and it
rejects 0x06.
- **`ironrdp-dvc`: decode and reassemble.** New `DataFirstCompressedPdu`
and `DataCompressedPdu` types, added to the `#[non_exhaustive]`
`DrdynvcDataPdu`, decode on both the client and server side.
`CompleteData` decompresses each block before reassembly, so one message
can mix compressed and uncompressed blocks (MS-RDPEDYC 2.2.3). Each
channel gets its own RDP 8.0 Lite decompression context (MS-RDPEDYC
3.1.5.2.5), created on the channel's first compressed block. A block
that makes a message longer than its declared `Length` is now an error
for both compressed and uncompressed data; before, the uncompressed path
logged it and dropped the message. The `DataFirstCompressedPdu` and
`DataCompressedPdu` constructors document the Lite payload format, so
the graphics pipeline's RDP 8.0 output is not mistaken for a valid
payload.
- **Client capabilities.** A version 3 offer is answered with version 3
again. `DrdynvcServer` still offers version 2 and now tolerates
compressed data from clients.

## Tests

- **Spec samples:** the MS-RDPEDYC 4.3.3 and 4.3.4 sample PDUs decode
and encode byte for byte (`dvc::data_compressed`). The client
reassembles them into one message (`dvc::client`). The spec's samples
decompress to 3,192 bytes while declaring 3,195, so the test supplies
the last 3 bytes in an uncompressed DYNVC_DATA block.
- **Per-channel history:** a test checks that one channel's compressed
data cannot refer back to another channel's history.
- **Length overruns:** tests check that a compressed first block, or a
later uncompressed block, that runs past the declared `Length` is an
error.
- **Lite limits:** `ironrdp-bulk` unit tests check that the Lite profile
rejects a match distance of 8,193 (accepted by RDP 8.0), keeps exactly
the last 8,192 bytes of history, caps segments at 8,192 bytes, and
rejects multipart messages.
- **Against the EGFX decoder:**
`bulk::rdp8_decodes_windows_egfx_captures` decodes the Windows ZGFX
captures already in `ironrdp-graphics` and gets identical output.
`bulk::rdp8_decodes_ironrdp_compressor_output` round-trips IronRDP's
ZGFX compressor output, including multipart messages.
- **Fuzzing:** a new `bulk_rdp8` fuzz target and `bulk_decompress_rdp8`
oracle require that any input the graphics decoder accepts decodes
identically with the new decompressor's RDP 8.0 profile. The same input
also runs through the Lite profile. Regression seeds are under
`test_data/fuzz_regression/bulk_decompress_rdp8`. A local run of 300,000
mutated captures and spec samples found no disagreement.
- **Unit tests:** `ironrdp-bulk` unit tests cover literals, matches, raw
byte runs, RDP 8.0 Lite, multipart messages, history carried across
messages, and malformed input.

## Checks

- **Tests:** `cargo test -p ironrdp-testsuite-core -p ironrdp-bulk`
passes: 1897 and 154 tests.
- **Format:** `cargo xtask check fmt -v` passes.
- **Lints:** `cargo clippy -D warnings` is clean on `ironrdp-bulk`,
`ironrdp-dvc`, `ironrdp-testsuite-core` and `ironrdp-fuzzing` (all
targets), and on the `no_std` builds of `ironrdp-bulk` and
`ironrdp-dvc`. `fuzz/` builds with the new target. The workspace-wide
`cargo xtask check lints` could not finish locally because the
`libopus_sys` build script fails on this machine.

## Not verified / follow-up

- **Live server:** not tested against a live Windows server sending
compressed DVC data.
- **Duplicate decoder:** EGFX still uses its own decoder in
`ironrdp-graphics`. Moving it onto `ironrdp_bulk::rdp8` would remove the
duplication, but it is a performance-sensitive path and should come with
benchmarks in a separate change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 22:54:58 -04:00
..

IronRDP fuzzing

Difference between fuzzing and property testing

ironrdp correctness is validated in various ways. Two of these are fuzzing and property testing. Both of these methods involve feeding random inputs to the API in order to check if the program is behaving as expected or not.

However,

  • Fuzzing is well suited for black-box-like testing. Inputs are typically guided by instrumentalizing the code (coverage…) rather than manually informed.

  • Property testing requires the developer to describe the interesting inputs and properties to test.

  • When fuzzing, some properties are tested as well, but those are typically simple (absence of crash, round-trip…).

  • In contrast, property testing is well suited when testing more complex properties.

  • With fuzzing, we are actively trying to show that something is (unexpectedly) broken.

  • With property testing, we are actively trying to show that the properties are holding (as expected).

Targets

pdu_decoding

Feeds random inputs to PDU decoding code.

bitmap_stream

Feeds random inputs to the RDP6 bitmap decoder.

rle_decompression

Feeds random inputs to the interleaved Run-Length Encoding (RLE) bitmap decoder.

bulk_mppc

Feeds random inputs to the MPPC bulk decompressor (ironrdp-bulk). The first input byte selects between RDP4 mode (low bit clear, 8 KB history) and RDP5 mode (low bit set, 64 KB history); remaining bytes are the compressed payload.

bulk_ncrush

Feeds random inputs to the NCRUSH bulk decompressor (RDP6.0, ironrdp-bulk).

bulk_xcrush

Feeds random inputs to the XCRUSH bulk decompressor (RDP6.1, ironrdp-bulk). XCRUSH has the largest sliding-window history of the bulk family (2 MB).

bulk_rdp8

Feeds random inputs to the RDP 8.0 bulk decompressor (ironrdp-bulk) and checks it against the graphics pipeline's ZGFX decoder: whatever the graphics decoder accepts, the bulk decompressor must decode to the same bytes. The same input also runs through the RDP 8.0 Lite profile (8 KB history and segments) that the dynamic virtual channels use for compressed data PDUs.

bulk_round_trip

Compresses arbitrary input via BulkCompressor::compress, then decompresses the result via BulkCompressor::decompress, and asserts byte-equality with the original input. First input byte selects the algorithm (RDP4 / RDP5 / RDP6 / RDP6.1). Catches asymmetric bugs where the compressor produces output the decompressor cannot consume, or the decompressor produces output that does not equal the original input.

Building crates with the arbitrary feature

Several crates expose an optional arbitrary feature that enables arbitrary::Arbitrary implementations on their PDU types. This is the foundation for structure-aware fuzzing harnesses that generate valid-looking inputs rather than raw bytes.

To verify the feature compiles cleanly for a single crate:

cargo check -p ironrdp-pdu --features arbitrary

The feature is also compatible with the no_std + alloc build path:

cargo check -p ironrdp-pdu --no-default-features --features arbitrary,alloc

A handful of PDU types do not implement Arbitrary. They fall into two categories:

  • Types with non-derivable fields (e.g., StaticChannelSet keyed by TypeId). These are either skipped via #[arbitrary(default)] on the containing struct's field, or hand-rolled with a placeholder.
  • Error types that are not part of the wire-protocol surface (e.g., ServerLicenseError). Most error enums fall here: they are constructed locally rather than decoded from the wire, so the fuzzer has no reason to generate them. The exception is wire-protocol error PDUs such as DisconnectProviderUltimatum in mcs.rs, which do implement Arbitrary because they are decoded from the wire.

Inline source comments mark each skip with the rationale.