Skip to content

fix(pdu): retain unknown fast-path input eventFlags bits instead of dropping the session - #1847

Merged
Marc-André Moreau (mamoreau-devolutions) merged 1 commit into
Devolutions:masterfrom
lamco-admin:fix/fastpath-input-flags-retain
Aug 30, 2026
Merged

fix(pdu): retain unknown fast-path input eventFlags bits instead of dropping the session#1847
Marc-André Moreau (mamoreau-devolutions) merged 1 commit into
Devolutions:masterfrom
lamco-admin:fix/fastpath-input-flags-retain

Conversation

@glamberson

Copy link
Copy Markdown
Contributor

The fast-path input decoder rejects the whole event stream when a keyboard or synchronize event carries an eventFlags bit outside the defined set, and a decode error there is session-fatal mid-use: input events arrive continuously, so a single unknown flag bit from a client drops a live session with work in progress.

The strictness is also internally inconsistent: the slow-path decoders for the very same events already tolerate unknown bits. Slow-path keyboard flags (scan_code.rs), synchronize toggle flags (sync.rs) and unicode keyboard flags (unicode.rs) all decode with from_bits_retain, so the identical keystroke is tolerated on one path and connection-fatal on the other.

The spec's only mandated strictness in this area is about event types, not flags: [MS-RDPBCGR] 3.3.5.8.2 says the server SHOULD drop the connection when an event structure does not match one of the known types. That check is the existing eventCode rejection, which stays exactly as it is. The eventFlags tables (2.2.8.1.2.2.1 and 2.2.8.1.2.2.5) carry no receiver-validation language.

All three flag sites (scancode, sync, unicode) switch to from_bits_retain, the crate-wide policy since #1144. The retained bits fit the 5-bit header field, so re-encoding reproduces the wire value, and the server-side consumers read these flags with contains(), so retained bits flow through harmlessly.

This continues the interop line of #1489, #1458, #1837, #1843, #1844, #1845 and #1846, and it is the last flag-site conversion of that series.

Tests: a keyboard event and a synchronize event, each with an undefined bit in the 5-bit field, decode successfully, retain the bit, and re-encode byte-identically. Both fail with the strict from_bits restored.

cargo xtask check fmt/lints/tests/typos/locks all pass.

…ropping the session

The fast-path input decoder rejected the whole event stream when a
keyboard or synchronize event carried an eventFlags bit outside the
defined set, and a decode error there is session-fatal mid-use: input
events arrive continuously, so a single unknown flag bit from a client
dropped a live session with work in progress.

The strictness was also internally inconsistent: the slow-path decoders
for the very same events already tolerate unknown bits. Slow-path
keyboard flags (scan_code.rs), synchronize toggle flags (sync.rs) and
unicode keyboard flags (unicode.rs) all decode with from_bits_retain,
so the identical keystroke was tolerated on one path and
connection-fatal on the other.

The spec's only mandated strictness in this area is about event types,
not flags: [MS-RDPBCGR] 3.3.5.8.2 says the server SHOULD drop the
connection when an event structure does not match one of the known
types. That check is the existing eventCode rejection, which stays
exactly as it is. The eventFlags tables (2.2.8.1.2.2.1 and
2.2.8.1.2.2.5) carry no receiver-validation language.

Switch all three flag sites (scancode, sync, unicode) to
from_bits_retain, the crate-wide policy since Devolutions#1144. The retained bits
fit the 5-bit header field, so re-encoding reproduces the wire value,
and the server-side consumers read these flags with contains(), so
retained bits flow through harmlessly.

This continues the interop line of Devolutions#1489, Devolutions#1458, Devolutions#1837, Devolutions#1843, Devolutions#1844,
Devolutions#1845 and Devolutions#1846, and is the last flag-site conversion of that series.
@github-actions github-actions Bot added maintainer-required Maintainer review or intervention is required risk/unknown Risk could not be determined automatically; needs maintainer-level scrutiny scope/core Touches the core architectural tier size/S Size: up to 199 counted lines and 5 files; exceeds XS in either measure labels Aug 30, 2026
@mamoreau-devolutions
Marc-André Moreau (mamoreau-devolutions) merged commit 0c3fc70 into Devolutions:master Aug 30, 2026
43 checks passed
@glamberson
Greg Lamberson (glamberson) deleted the fix/fastpath-input-flags-retain branch August 30, 2026 15:03
Marc-André Moreau (mamoreau-devolutions) pushed a commit that referenced this pull request Aug 30, 2026
…ce policy (#1850)

STYLE.md's error handling section documents the message-formatting
conventions but predates two rounds of change in the machinery itself,
and it says nothing about the decode-tolerance convention that this
month's merges made the most exercised rule in ironrdp-pdu. This adds
three subsections, plus two mirroring bullets in AGENTS.md's Key Style
Conventions.

Choosing an error kind: the structured DecodeErrorKind/EncodeErrorKind
variants carry byte offsets and are constructed through the *_err!
macros with in: src; Other is the deliberate offset-less kind for
non-stream failures (constructors, conversions, state validation).

Error types: typed errors rather than anyhow in library crates, and no
proc-macro error derives in core-tier crates, hand-rolling Display and
Error per ironrdp-error's own Location-capturing Source pattern.

Decoding unknown values: the taxonomy the recent interop line converged
on. Peer advertisements decode with from_bits_retain (unknown bits kept,
never fatal, byte-identical re-encode); negotiation outputs the receiver
must implement stay strict; structural discriminants stay strict per the
specifications' own drop-the-connection language. Precedent: #1144
established retain crate-wide, #1489, #1458, #1536, #1541, #1837, and
#1843 through #1847 applied the taxonomy field by field, and #1845
documents the strict half in-code at the server-selected encryption
method.

Deliberately out of scope: connector-layer error types, which #1751 and
the sequence-contract stack are actively reshaping; nothing here
describes them. Testing guidance is also untouched; that conversation
belongs with the in-flight test-centralization series.

`cargo xtask check fmt/lints/tests/typos/locks` all pass (docs-only
change).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer-required Maintainer review or intervention is required risk/unknown Risk could not be determined automatically; needs maintainer-level scrutiny scope/core Touches the core architectural tier size/S Size: up to 199 counted lines and 5 files; exceeds XS in either measure

Development

Successfully merging this pull request may close these issues.

2 participants