Skip to content

Commit 9a0881b

Browse files
committed
detect/parse: limit pkthdr proto to decoder event rules
`alert pkthdr` was initially just an alias for `alert ip`, as that was really just a way of stating that "any" should be matched. However with the Ethernet matching in place, it no long makes sense to treat `alert ip` as "any". Since `pkthdr` is used to match on decoder events, also for packets that completely failed to parse, it should no longer be treated as `alert ip` but rather as it's own distinct logic.
1 parent db4ede4 commit 9a0881b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/detect-parse.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,16 @@ static bool SigValidateEthernet(const Signature *s)
28222822
return true;
28232823
}
28242824

2825+
/* `pkthdr` is meant to allow matching on "any" packet with a decoder event. */
2826+
static bool SigValidateProtoPkthdr(const Signature *s)
2827+
{
2828+
if ((s->init_data->proto.flags & DETECT_PROTO_L2_ANY) && s->type != SIG_TYPE_DEONLY) {
2829+
SCLogError("protocol 'pkthdr' is for decoder-events only");
2830+
return false;
2831+
}
2832+
return true;
2833+
}
2834+
28252835
/**
28262836
* \internal
28272837
* \brief validate and consolidate parsed signature
@@ -2865,6 +2875,10 @@ static int SigValidateConsolidate(
28652875
SignatureSetType(de_ctx, s);
28662876
DetectRuleSetTable(s);
28672877

2878+
if (!SigValidateProtoPkthdr(s)) {
2879+
SCReturnInt(0);
2880+
}
2881+
28682882
if (DetectProtoFinalizeSignature(s) != 0)
28692883
SCReturnInt(0);
28702884

0 commit comments

Comments
 (0)