Project

General

Profile

Actions

Bug #7390

open

byte_extract: issue with saved 'name' in distance keyword

Added by Minuk Cha 6 days ago. Updated 5 days ago.

Status:
Assigned
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

No Difference Rule
1
content:!"|38|"; distance:option_len; within:1; //option_len == 7
alert tcp any any -> any 8080 (msg:"distance name"; flow:to_server; content:"Authorization:"; content:"5f71ycy"; distance:0; byte_extract:1,0,option_len,string,relative; content:!"|38|"; distance:option_len; within:1; content:"|37|"; distance:-1; within:1; content:"|49|"; distance:option_len; within:1; sid:1;)
2
content:!"|38|"; distance:7; within:1;
alert tcp any any -> any 8080 (msg:"distance number"; flow:to_server; content:"Authorization:"; content:"5f71ycy"; distance:0; byte_extract:1,0,option_len,string,relative; content:!"|38|"; distance:7; within:1; content:"|37|"; distance:-1; within:1; content:"|49|"; distance:option_len; within:1; sid:2;)

In theory, the two detection rules mentioned above are identical. However, during detection testing, Rule 1 does not trigger any detections, while only Rule 2 is being detected.

Upon reviewing and analyzing the debug logs, it appears that the following code in 'detect-engine-content-inspection.c' may be the cause:

// Line : 254-256
if (cd->flags & (DETECT_CONTENT_DISTANCE_VAR|DETECT_CONTENT_OFFSET_VAR|DETECT_CONTENT_DEPTH_VAR)) {
    depth += offset;
}

Since the analysis was conducted briefly, it may not be the definitive cause, so please consider this as a reference only.

If you need any further assistance, feel free to ask!

P.S. The tests were conducted on the latest version, 7.0.7, and I have also attached the PCAP file used for the detection test.


Files

rule_test.pcap (1.38 KB) rule_test.pcap PCAP file used for the detection test Minuk Cha, 11/12/2024 12:43 AM
Actions #1

Updated by Minuk Cha 6 days ago

  • Priority changed from High to Urgent
Actions #2

Updated by Minuk Cha 6 days ago

It has been confirmed that the same issue occurs when using the 'name' value saved with the 'byte_math' option

Actions #3

Updated by Victor Julien 6 days ago

  • Subject changed from Bug Occurs When Using 'name' Saved with 'byte_extract' Option as Value for 'distance' Option to byte_extract: issue with saved 'name' in distance keyword
  • Status changed from New to Assigned
  • Assignee changed from OISF Dev to Jeff Lucovsky
  • Priority changed from Urgent to Normal
  • Target version changed from TBD to 8.0.0-beta1

@Minuk Cha can you create a Suricata Verify test for this at https://github.com/OISF/suricata-verify

Actions #4

Updated by Minuk Cha 5 days ago

@Victor Julien After downloading the files from 'https://github.com/OISF/suricata-verify', should I refer to the 'README' to proceed?

I haven't done a Suricata Verify test before, so I'm not sure what to do...

Actions

Also available in: Atom PDF