Skip to content

Commit ceba4ec

Browse files
authored
Added Transport parameters extension validation in openssl (#6225)
## Description Validate peer transport parameters during client handshake completion in the OpenSSL QUIC TLS path before accepting the connection. This preserves the required RFC behavior for QUIC transport parameter handling and ensures the peer transport parameter callback is only invoked after successful validation. https://microsoft.visualstudio.com/OS/_workitems/edit/62258561/ ## Testing ## Documentation
1 parent 36994f9 commit ceba4ec

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

src/generated/linux/tls_openssl.c.clog.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,24 @@ tracepoint(CLOG_TLS_OPENSSL_C, OpenSslNoMatchingAlpn , arg1);\
153153

154154

155155

156+
/*----------------------------------------------------------
157+
// Decoder Ring for OpenSslMissingTransportParameters
158+
// [conn][%p] No transport parameters received
159+
// QuicTraceLogConnError(
160+
OpenSslMissingTransportParameters,
161+
TlsContext->Connection,
162+
"No transport parameters received");
163+
// arg1 = arg1 = TlsContext->Connection = arg1
164+
----------------------------------------------------------*/
165+
#ifndef _clog_3_ARGS_TRACE_OpenSslMissingTransportParameters
166+
#define _clog_3_ARGS_TRACE_OpenSslMissingTransportParameters(uniqueId, arg1, encoded_arg_string)\
167+
tracepoint(CLOG_TLS_OPENSSL_C, OpenSslMissingTransportParameters , arg1);\
168+
169+
#endif
170+
171+
172+
173+
156174
/*----------------------------------------------------------
157175
// Decoder Ring for OpenSslHandshakeDataStart
158176
// [conn][%p] Writing Handshake data starts at %u

src/generated/linux/tls_openssl.c.clog.h.lttng.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@ TRACEPOINT_EVENT(CLOG_TLS_OPENSSL_C, OpenSslNoMatchingAlpn,
139139

140140

141141

142+
/*----------------------------------------------------------
143+
// Decoder Ring for OpenSslMissingTransportParameters
144+
// [conn][%p] No transport parameters received
145+
// QuicTraceLogConnError(
146+
OpenSslMissingTransportParameters,
147+
TlsContext->Connection,
148+
"No transport parameters received");
149+
// arg1 = arg1 = TlsContext->Connection = arg1
150+
----------------------------------------------------------*/
151+
TRACEPOINT_EVENT(CLOG_TLS_OPENSSL_C, OpenSslMissingTransportParameters,
152+
TP_ARGS(
153+
const void *, arg1),
154+
TP_FIELDS(
155+
ctf_integer_hex(uint64_t, arg1, (uint64_t)arg1)
156+
)
157+
)
158+
159+
160+
142161
/*----------------------------------------------------------
143162
// Decoder Ring for OpenSslHandshakeDataStart
144163
// [conn][%p] Writing Handshake data starts at %u

src/platform/tls_openssl.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,15 @@ static int QuicTlsGotTp(SSL *S, const unsigned char *Params,
747747

748748
UNREFERENCED_PARAMETER(Arg);
749749

750+
if (ParamsLen == 0 || Params == NULL) {
751+
return 0;
752+
}
753+
754+
if (AData->PeerTp != NULL) {
755+
return AData->PeerTpLen == ParamsLen &&
756+
memcmp(AData->PeerTp, Params, ParamsLen) == 0;
757+
}
758+
750759
AData->PeerTp = CXPLAT_ALLOC_NONPAGED(ParamsLen,
751760
QUIC_POOL_TLS_TRANSPARAMS);
752761
if (AData->PeerTp == NULL) {
@@ -3309,6 +3318,20 @@ CxPlatTlsProcessData(
33093318
TlsContext->ResultFlags |= CXPLAT_TLS_RESULT_ERROR;
33103319
goto Exit;
33113320
}
3321+
3322+
//
3323+
// By this point, OpenSSL should have called QuicTlsGotTp, which stores
3324+
// a non-NULL PeerTp and sets PeerTPReceived. Fail the handshake if the
3325+
// required transport parameters were not processed.
3326+
//
3327+
if (!TlsContext->PeerTPReceived) {
3328+
QuicTraceLogConnError(
3329+
OpenSslMissingTransportParameters,
3330+
TlsContext->Connection,
3331+
"No transport parameters received");
3332+
TlsContext->ResultFlags |= CXPLAT_TLS_RESULT_ERROR;
3333+
goto Exit;
3334+
}
33123335
} else if ((TlsContext->SecConfig->Flags & QUIC_CREDENTIAL_FLAG_INDICATE_CERTIFICATE_RECEIVED) &&
33133336
!TlsContext->PeerCertReceived) {
33143337
QUIC_STATUS ValidationResult =

0 commit comments

Comments
 (0)