TLS: avoid setting NDPI_TLS_SELFSIGNED_CERTIFICATE for webrtc traffic (#2417)

See RFC8122: it is quite likely that STUN/DTLS/SRTP flows use
self-signed certificates

Follow-up of b287d6ec8
This commit is contained in:
Ivan Nardi
2024-05-06 10:20:07 +02:00
committed by GitHub
parent 266af02752
commit e31ef00715
6 changed files with 13 additions and 11 deletions
+1 -1
View File
@@ -1336,7 +1336,7 @@ struct ndpi_flow_struct {
char ja3_client[33], ja3_server[33], ja4_client[37];
u_int16_t server_cipher;
u_int8_t sha1_certificate_fingerprint[20];
u_int8_t hello_processed:1, ch_direction:1, subprotocol_detected:1, fingerprint_set:1, _pad:4;
u_int8_t hello_processed:1, ch_direction:1, subprotocol_detected:1, fingerprint_set:1, webrtc:1, _pad:3;
#ifdef TLS_HANDLE_SIGNATURE_ALGORITMS
/* Under #ifdef to save memory for those who do not need them */
+7 -5
View File
@@ -755,7 +755,8 @@ void processCertificateElements(struct ndpi_detection_module_struct *ndpi_struct
if(ndpi_check_issuerdn_risk_exception(ndpi_struct, flow->protos.tls_quic.issuerDN))
return; /* This is a trusted DN */
ndpi_set_risk(flow, NDPI_TLS_SELFSIGNED_CERTIFICATE, flow->protos.tls_quic.subjectDN);
if(!flow->protos.tls_quic.webrtc)
ndpi_set_risk(flow, NDPI_TLS_SELFSIGNED_CERTIFICATE, flow->protos.tls_quic.subjectDN);
}
#if DEBUG_TLS
@@ -1795,7 +1796,6 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
u_int8_t handshake_type;
bool is_quic = (quic_version != 0);
bool is_dtls = packet->udp && (!is_quic);
bool use_srtp = 0;
#ifdef DEBUG_TLS
printf("TLS %s() called\n", __FUNCTION__);
@@ -2539,7 +2539,9 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
printf("Client TLS [SIGNATURE_ALGORITHMS: %s]\n", ja.client.signature_algorithms_str);
#endif
} else if(extension_id == 14 /* use_srtp */) {
use_srtp = 1;
/* This is likely a werbrtc flow */
if(flow->stun.maybe_dtls || flow->detected_protocol_stack[0] == NDPI_PROTOCOL_DTLS)
flow->protos.tls_quic.webrtc = 1;
#ifdef DEBUG_TLS
printf("Client TLS: use_srtp\n");
#endif
@@ -2867,7 +2869,7 @@ compute_ja3c:
/* Before returning to the caller we need to make a final check */
if((flow->protos.tls_quic.ssl_version >= 0x0303) /* >= TLSv1.2 */
&& !(flow->stun.maybe_dtls == 1 && is_dtls && use_srtp) /* Webrtc traffic */
&& !flow->protos.tls_quic.webrtc
&& (flow->protos.tls_quic.advertised_alpns == NULL) /* No ALPN */) {
ndpi_set_risk(flow, NDPI_TLS_NOT_CARRYING_HTTPS, "No ALPN");
}
@@ -2882,7 +2884,7 @@ compute_ja3c:
/* Add check for missing SNI */
if(flow->host_server_name[0] == '\0'
&& (flow->protos.tls_quic.ssl_version >= 0x0302) /* TLSv1.1 */
&& !(flow->stun.maybe_dtls == 1 && is_dtls && use_srtp) /* Webrtc traffic */
&& !flow->protos.tls_quic.webrtc
&& (flow->protos.tls_quic.encrypted_sni.esni == NULL) /* No ESNI */
) {
/* This is a bit suspicious */