QUIC: fix an integer overflow (#1337)
Long standing bug: credits to @lnslbrty for digging into it and to @aouinizied for the CI improvements
This commit is contained in:
+10
-12
@@ -1348,14 +1348,14 @@ static void process_chlo(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
if(prev_offset > offset)
|
if(prev_offset > offset)
|
||||||
break;
|
break;
|
||||||
len = offset - prev_offset;
|
len = offset - prev_offset;
|
||||||
if(tag_offset_start + prev_offset + len > crypto_data_len)
|
/* Promote to uint64_t to avoid unsigned wrapping */
|
||||||
|
if((uint64_t)tag_offset_start + prev_offset + len > (uint64_t)crypto_data_len)
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
printf("crypto_data_len %u prev_offset %u offset %u len %d\n",
|
printf("crypto_data_len %u tag_offset_start %u prev_offset %u offset %u len %u\n",
|
||||||
crypto_data_len, prev_offset, offset, len);
|
crypto_data_len, tag_offset_start, prev_offset, offset, len);
|
||||||
#endif
|
#endif
|
||||||
if((memcmp(tag, "SNI\0", 4) == 0) &&
|
if(memcmp(tag, "SNI\0", 4) == 0) {
|
||||||
(tag_offset_start + prev_offset + len < crypto_data_len)) {
|
|
||||||
sni_len = MIN(len, sizeof(flow->protos.tls_quic_stun.tls_quic.client_requested_server_name) - 1);
|
sni_len = MIN(len, sizeof(flow->protos.tls_quic_stun.tls_quic.client_requested_server_name) - 1);
|
||||||
memcpy(flow->protos.tls_quic_stun.tls_quic.client_requested_server_name,
|
memcpy(flow->protos.tls_quic_stun.tls_quic.client_requested_server_name,
|
||||||
&crypto_data[tag_offset_start + prev_offset], sni_len);
|
&crypto_data[tag_offset_start + prev_offset], sni_len);
|
||||||
@@ -1381,15 +1381,13 @@ static void process_chlo(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
if(memcmp(tag, "UAID", 4) == 0) {
|
if(memcmp(tag, "UAID", 4) == 0) {
|
||||||
u_int uaid_offset = tag_offset_start + prev_offset;
|
u_int uaid_offset = tag_offset_start + prev_offset;
|
||||||
|
|
||||||
if((uaid_offset + len) < crypto_data_len) {
|
NDPI_LOG_DBG2(ndpi_struct, "UA: [%.*s]\n", len, &crypto_data[uaid_offset]);
|
||||||
NDPI_LOG_DBG2(ndpi_struct, "UA: [%.*s]\n", len, &crypto_data[uaid_offset]);
|
|
||||||
|
|
||||||
http_process_user_agent(ndpi_struct, flow, &crypto_data[uaid_offset], len); /* http.c */
|
http_process_user_agent(ndpi_struct, flow, &crypto_data[uaid_offset], len); /* http.c */
|
||||||
ua_found = 1;
|
ua_found = 1;
|
||||||
|
|
||||||
if (sni_found)
|
if (sni_found)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_offset = offset;
|
prev_offset = offset;
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
Guessed flow protos: 0
|
||||||
|
|
||||||
|
DPI Packets (UDP): 1 (1.00 pkts/flow)
|
||||||
|
|
||||||
|
QUIC 1 1280 1
|
||||||
|
|
||||||
|
1 UDP 255.255.255.255:8224 -> 255.255.255.32:8224 [proto: 188/QUIC][Encrypted][cat: Web/5][1 pkts/1280 bytes -> 0 pkts/0 bytes][Goodput ratio: 98/0][< 1 sec][Risk: ** Known protocol on non standard port **** SNI TLS extension was missing **][Risk Score: 60][PLAIN TEXT ( )][Plen Bins: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0]
|
||||||
Reference in New Issue
Block a user