Skip to content

Commit 7a0c1f5

Browse files
fix(dgw): enable SSL protocol in RDP proxy (#1576)
1 parent 0b37f40 commit 7a0c1f5

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

devolutions-gateway/src/rdp_proxy.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,8 @@ where
227227
trace!(message = ?received_connection_request, "Received Connection Request PDU from client");
228228

229229
// Choose the security protocol to use with the client.
230-
let client_security_protocol = if received_connection_request
231-
.0
232-
.protocol
233-
.contains(nego::SecurityProtocol::HYBRID_EX)
234-
{
230+
let received_connection_request_protocol = received_connection_request.0.protocol;
231+
let client_security_protocol = if received_connection_request_protocol.contains(nego::SecurityProtocol::HYBRID_EX) {
235232
nego::SecurityProtocol::HYBRID_EX
236233
} else if received_connection_request
237234
.0
@@ -254,15 +251,28 @@ where
254251
},
255252
flags: received_connection_request.0.flags,
256253
// https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/902b090b-9cb3-4efc-92bf-ee13373371e3
257-
// The spec is stating that `PROTOCOL_SSL` "SHOULD" also be set when using `PROTOCOL_HYBRID`.
254+
//
255+
// The spec states that `PROTOCOL_SSL` "SHOULD" also be set when using `PROTOCOL_HYBRID`:
256+
//
258257
// > PROTOCOL_HYBRID (0x00000002)
259258
// > Credential Security Support Provider protocol (CredSSP) (section 5.4.5.2).
260259
// > If this flag is set, then the PROTOCOL_SSL (0x00000001) flag SHOULD also be set
261260
// > because Transport Layer Security (TLS) is a subset of CredSSP.
262-
// However, crucially, it’s not strictly required (not "MUST").
263-
// In fact, we purposefully choose to not set `PROTOCOL_SSL` unless `enable_winlogon` is `true`.
264-
// This tells the server that we are not going to accept downgrading NLA to TLS security.
265-
protocol: nego::SecurityProtocol::HYBRID | nego::SecurityProtocol::HYBRID_EX,
261+
//
262+
// However, in practice `mstsc` is picky about these flags: it expects the
263+
// SupportedProtocol bits in the ConnectionRequestPDU that reach the target
264+
// server to match what the client originally sent. If the proxy modifies
265+
// them (for example, forcing HYBRID | HYBRID_EX and/or clearing SSL),
266+
// the connection can fail with an authentication error (Code: 0x609).
267+
//
268+
// We therefore *do not* synthesize a new protocol bitmask here anymore.
269+
// Instead, we forward the client's SupportedProtocol flags as-is and
270+
// enforce our policy by validating them: if HYBRID / HYBRID_EX are not
271+
// present (i.e. NLA is not negotiated), we fail the connection rather
272+
// than trying to "fix" the flags ourselves.
273+
//
274+
// See also: https://serverfault.com/a/720161
275+
protocol: received_connection_request_protocol,
266276
};
267277
trace!(?connection_request_to_send, "Send Connection Request PDU to server");
268278
send_pdu(server_framed, &x224::X224(connection_request_to_send))

0 commit comments

Comments
 (0)