From 623b7e236f52af5447beae39f97f2fd0feaf65e2 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:15:03 +0200 Subject: TLS: detect abnormal padding usage (#2579) Padding is usually some hundreds byte long. Longer padding might be used as obfuscation technique to force unusual CH fragmentation --- src/lib/protocols/tls.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/lib/protocols/tls.c') diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c index 44736a3a2..b42d200fc 100644 --- a/src/lib/protocols/tls.c +++ b/src/lib/protocols/tls.c @@ -3197,6 +3197,15 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct, } s_offset += param_len; } + } else if(extension_id == 21) { /* Padding */ + /* Padding is usually some hundreds byte long. Longer padding + might be used as obfuscation technique to force unusual CH fragmentation */ + if(extension_len > 500 /* Arbitrary value */) { +#ifdef DEBUG_TLS + printf("Padding length: %d\n", extension_len); +#endif + ndpi_set_risk(flow, NDPI_OBFUSCATED_TRAFFIC, "Abnormal Client Hello/Padding length"); + } } extension_offset += extension_len; /* Move to the next extension */ -- cgit v1.2.3