]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
protodetect: be more tolerant
authorPhilippe Antoine <contact@catenacyber.fr>
Wed, 17 Jul 2019 13:19:30 +0000 (15:19 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 17 May 2022 08:41:24 +0000 (10:41 +0200)
Do not mask protocols on both directions with only first packet

For instance :
When the first packet is no valid DNS but on port 53 (a junk request)
second packet (error response from server) does not get checked for DNS
as first packet bit masked away DNS for both directions

Ticket: #2757

src/app-layer-detect-proto.c

index b61d3c924d5b13d009e0a49cba057da77818db65..3eb2752850e3a97557f2b52bfe435941bf1e797e 100644 (file)
@@ -556,7 +556,11 @@ again_midstream:
     } else {
         /* first try the destination port */
         pp_port_dp = AppLayerProtoDetectGetProbingParsers(alpd_ctx.ctx_pp, ipproto, dp);
-        alproto_masks = &f->probing_parser_toclient_alproto_masks;
+        if (dir == idir) {
+            // do not update alproto_masks to let a chance to second packet
+            // for instance when sending a junk packet to a DNS server
+            alproto_masks = &f->probing_parser_toclient_alproto_masks;
+        }
         if (pp_port_dp != NULL) {
             SCLogDebug("toclient - Probing parser found for destination port %"PRIu16, dp);