fix(pdu): retain unknown protocol bits in the GCC negotiation echo fields - #1846
Merged
Marc-André Moreau (mamoreau-devolutions) merged 1 commit intoAug 30, 2026
Conversation
…elds The two GCC core-data fields that echo the X.224 negotiation values are decoded strictly: serverSelectedProtocol in the client core data and clientRequestedProtocols in the server core data both rejected the whole settings exchange when the value carried a bit outside the five defined PROTOCOL_* flags. The negotiation layer itself already decodes this exact type with from_bits_retain in both the RDP Negotiation Request and Response, so a value the library accepted leniently at X.224 became connection-fatal when echoed back one phase later. The strictness also worked against the field's purpose. [MS-RDPBCGR] 3.3.5.3.3's mandated handling of serverSelectedProtocol is a value comparison: if the field does not contain the same value the server transmitted in the RDP Negotiation Response, the server SHOULD drop the connection. That comparison needs the value to survive decode; rejecting unknown bits at parse time replaces the spec's check with a decode error. The client-side echo is symmetric: the client knows what it requested and compares, rather than validating the bit set. The exposure is demonstrated by history: the PROTOCOL_* list has grown three times (RDSTLS, HYBRID_EX, RDSAAD), and each addition would have made older strict decoders refuse newer peers whose negotiation had already succeeded. Switch both sites to from_bits_retain, the crate-wide policy since Devolutions#1144; re-encoding a decoded block reproduces the wire value. This continues the interop line of Devolutions#1489, Devolutions#1458, Devolutions#1837, Devolutions#1843, Devolutions#1844 and Devolutions#1845.
Greg Lamberson (glamberson)
deployed
to
llm-providers
August 30, 2026 04:01 — with
GitHub Actions
Active
Marc-André Moreau (mamoreau-devolutions)
approved these changes
Aug 30, 2026
Marc-André Moreau (mamoreau-devolutions)
merged commit Aug 30, 2026
9af9931
into
Devolutions:master
43 checks passed
Marc-André Moreau (mamoreau-devolutions)
pushed a commit
that referenced
this pull request
Aug 30, 2026
…ropping the session (#1847) 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two GCC core-data fields that echo the X.224 negotiation values are decoded strictly: serverSelectedProtocol in the client core data and clientRequestedProtocols in the server core data both reject the whole settings exchange when the value carries a bit outside the five defined PROTOCOL_* flags. The negotiation layer itself already decodes this exact type with from_bits_retain in both the RDP Negotiation Request and Response, so a value the library accepts leniently at X.224 becomes connection-fatal when echoed back one phase later.
The strictness also works against the field's purpose. [MS-RDPBCGR] 3.3.5.3.3's mandated handling of serverSelectedProtocol is a value comparison: if the field does not contain the same value the server transmitted in the RDP Negotiation Response, the server SHOULD drop the connection. That comparison needs the value to survive decode; rejecting unknown bits at parse time replaces the spec's check with a decode error. The client-side echo is symmetric: the client knows what it requested and compares, rather than validating the bit set.
The exposure is demonstrated by history: the PROTOCOL_* list has grown three times (RDSTLS, HYBRID_EX, RDSAAD), and each addition would have made older strict decoders refuse newer peers whose negotiation had already succeeded.
Both sites switch to from_bits_retain, the crate-wide policy since #1144; re-encoding a decoded block reproduces the wire value.
This continues the interop line of #1489, #1458, #1837, #1843, #1844 and #1845.
Tests: one per direction, each verifying that a fixture with an undefined protocol bit decodes, that the bit is retained, and that re-encoding reproduces the exact input bytes. Both fail with the strict from_bits restored.
cargo xtask check fmt/lints/tests/typos/locksall pass.