Hello,
I’m analyzing rules and feel a bit scratched about the behavior described below
Say a simple rule is setup:
alert tcp any any → any any (msg:“MY TEST RULE”; flow:established; content:"|43 41 50 20|"; classtype:trojan-activity; sid:2103272; rev:3; metadata:created_at 2010_09_23, updated_at 2010_09_23;)
So I’m expecting this is a tcp stream rule which is applied to a reassembled stream
Running suricata with --engine-analysis option confirms that:
Rule matches on reassembled stream
Adding “depth: xxx” option to this rule make the rule to be applied to packets also
I checked some source and found that SIG_FLAG_REQUIRE_PACKET is not set in detect-depth.c. However, it is set in detect-parse::SigValidate
This case is explicitly processed here:
sm = s->init_data->smlists[DETECT_SM_LIST_PMATCH];
while (sm != NULL) {
if (sm->type == DETECT_CONTENT &&
(((DetectContentData *)(sm->ctx))->flags &
(DETECT_CONTENT_DEPTH | DETECT_CONTENT_OFFSET))) {
s->flags |= SIG_FLAG_REQUIRE_PACKET;
break;
}
sm = sm->next;
}
Could someone clarify why this behavior is applied? From the user point of view if tcp is applied to reassembled stream, then the tcp + “distance or offset” should also be applied to it as there is no tip that one of those keywords apply to packet payload (e.g. like for dsize keyword)
PS:
Explicitly putting tcp-stream instead of “tcp” make the rule to match to reassembled stream only
Thanks in advance for your answers!