-
Notifications
You must be signed in to change notification settings - Fork 298
fix(server): recognize the Initiate Multitransport Response on the message channel #1964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Marc-André Moreau (mamoreau-devolutions)
merged 3 commits into
Devolutions:master
from
lamco-admin:fix/multitransport-response-dispatch
Sep 28, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| //! PDUs a client sends on the MCS message channel (MS-RDPBCGR 2.2.1.3.7). | ||
| //! | ||
| //! Two PDUs travel from client to server on this channel, both framed by a | ||
| //! Basic Security Header rather than a Share Control header: the Auto-Detect | ||
| //! Response (MS-RDPBCGR 2.2.14.4) and the Initiate Multitransport Response | ||
| //! (MS-RDPBCGR 2.2.15.2). The header's flags say which one follows | ||
| //! (`SEC_AUTODETECT_RSP` or `SEC_TRANSPORT_RSP`), so decoding dispatches on | ||
| //! them and reports a malformed PDU against the type its header names. | ||
|
|
||
| use ironrdp_core::{Decode, DecodeResult, Encode, EncodeResult, ReadCursor, WriteCursor, ensure_size}; | ||
|
|
||
| use crate::rdp::autodetect::AutoDetectRspPdu; | ||
| use crate::rdp::headers::BasicSecurityHeaderFlags; | ||
| use crate::rdp::multitransport::MultitransportResponsePdu; | ||
|
|
||
| /// A PDU received from the client on the MCS message channel. | ||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub enum ClientMessageChannelPdu { | ||
| /// An Auto-Detect Response (`SEC_AUTODETECT_RSP`). | ||
| AutoDetectResponse(AutoDetectRspPdu), | ||
| /// An Initiate Multitransport Response (`SEC_TRANSPORT_RSP`). | ||
| MultitransportResponse(MultitransportResponsePdu), | ||
| } | ||
|
|
||
| impl ClientMessageChannelPdu { | ||
| const NAME: &'static str = "ClientMessageChannelPdu"; | ||
|
|
||
| /// Dispatch only needs the leading `flags` field of the Basic Security | ||
| /// Header; the chosen PDU's own decode validates the rest. | ||
| const FLAGS_SIZE: usize = 2 /* flags */; | ||
| } | ||
|
|
||
| impl Encode for ClientMessageChannelPdu { | ||
| fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> { | ||
| match self { | ||
| Self::AutoDetectResponse(pdu) => pdu.encode(dst), | ||
| Self::MultitransportResponse(pdu) => pdu.encode(dst), | ||
| } | ||
| } | ||
|
|
||
| fn name(&self) -> &'static str { | ||
| Self::NAME | ||
| } | ||
|
|
||
| fn size(&self) -> usize { | ||
| match self { | ||
| Self::AutoDetectResponse(pdu) => pdu.size(), | ||
| Self::MultitransportResponse(pdu) => pdu.size(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<'de> Decode<'de> for ClientMessageChannelPdu { | ||
| fn decode(src: &mut ReadCursor<'de>) -> DecodeResult<Self> { | ||
| ensure_size!(in: src, size: Self::FLAGS_SIZE); | ||
|
|
||
| let flags = BasicSecurityHeaderFlags::from_bits_truncate(src.peek_u16()); | ||
|
|
||
| if flags.contains(BasicSecurityHeaderFlags::TRANSPORT_RSP) { | ||
| MultitransportResponsePdu::decode(src).map(Self::MultitransportResponse) | ||
| } else { | ||
| AutoDetectRspPdu::decode(src).map(Self::AutoDetectResponse) | ||
| } | ||
| } | ||
| } | ||
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
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
72 changes: 72 additions & 0 deletions
72
crates/ironrdp-testsuite-core/tests/pdu/message_channel.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| //! Decoding of client PDUs on the MCS message channel ([MS-RDPBCGR] 2.2.1.3.7). | ||
|
|
||
| use ironrdp_core::{decode, encode_vec}; | ||
| use ironrdp_pdu::rdp::autodetect::{AutoDetectResponse, AutoDetectRspPdu}; | ||
| use ironrdp_pdu::rdp::message_channel::ClientMessageChannelPdu; | ||
| use ironrdp_pdu::rdp::multitransport::MultitransportResponsePdu; | ||
|
|
||
| #[test] | ||
| fn autodetect_response_is_recognized() { | ||
| let pdu = AutoDetectRspPdu::new(AutoDetectResponse::RttResponse { sequence_number: 7 }); | ||
| let bytes = encode_vec(&pdu).unwrap(); | ||
|
|
||
| let decoded = decode::<ClientMessageChannelPdu>(&bytes).unwrap(); | ||
|
|
||
| assert_eq!(decoded, ClientMessageChannelPdu::AutoDetectResponse(pdu)); | ||
| } | ||
|
|
||
| /// A client that offered UDP multitransport but could not establish it answers | ||
| /// on the message channel with an Initiate Multitransport Response (MS-RDPBCGR | ||
| /// 2.2.15.2), not an auto-detect response. | ||
| #[test] | ||
| fn multitransport_response_is_recognized() { | ||
| let pdu = MultitransportResponsePdu::abort(42); | ||
| let bytes = encode_vec(&pdu).unwrap(); | ||
|
|
||
| let decoded = decode::<ClientMessageChannelPdu>(&bytes).unwrap(); | ||
|
|
||
| assert_eq!(decoded, ClientMessageChannelPdu::MultitransportResponse(pdu)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn both_variants_round_trip() { | ||
| for pdu in [ | ||
| ClientMessageChannelPdu::AutoDetectResponse(AutoDetectRspPdu::new(AutoDetectResponse::RttResponse { | ||
| sequence_number: 3, | ||
| })), | ||
| ClientMessageChannelPdu::MultitransportResponse(MultitransportResponsePdu::abort(9)), | ||
| ] { | ||
| let bytes = encode_vec(&pdu).unwrap(); | ||
| assert_eq!(decode::<ClientMessageChannelPdu>(&bytes).unwrap(), pdu); | ||
| } | ||
| } | ||
|
|
||
| /// Dispatch follows the security header: a truncated PDU whose header says | ||
| /// SEC_TRANSPORT_RSP is reported as a malformed multitransport response, not | ||
| /// as a failed auto-detect decode. | ||
| #[test] | ||
| fn truncated_multitransport_response_is_reported_as_one() { | ||
| let bytes = encode_vec(&MultitransportResponsePdu::abort(42)).unwrap(); | ||
|
|
||
| let error = decode::<ClientMessageChannelPdu>(&bytes[..8]).unwrap_err(); | ||
|
|
||
| let message = format!("{error:#}"); | ||
| assert!(message.contains("MultitransportResponsePdu"), "{message}"); | ||
| } | ||
|
|
||
| /// A header without SEC_TRANSPORT_RSP goes to the auto-detect decoder, which | ||
| /// reports the flag it expected. | ||
| #[test] | ||
| fn unrecognized_payload_is_reported_by_the_autodetect_decoder() { | ||
| let bytes = [0x00u8; 12]; | ||
|
|
||
| let error = decode::<ClientMessageChannelPdu>(&bytes).unwrap_err(); | ||
|
|
||
| let message = format!("{error:#}"); | ||
| assert!(message.contains("SEC_AUTODETECT_RSP"), "{message}"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn input_shorter_than_the_flags_field_is_rejected() { | ||
| assert!(decode::<ClientMessageChannelPdu>(&[0x04]).is_err()); | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.