Skip to content

Commit

Permalink
protodetect: be more tolerant
Browse files Browse the repository at this point in the history
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: OISF#2757
  • Loading branch information
catenacyber committed Apr 27, 2022
1 parent ddf9c9d commit b51c79e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app-layer-detect-proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,11 @@ static AppProto AppLayerProtoDetectPPGetProto(Flow *f, const uint8_t *buf, uint3
} 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);

Expand Down

0 comments on commit b51c79e

Please sign in to comment.