-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add multi buffer matching documentation v4 #9180
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,4 @@ Suricata Rules | |
datasets | ||
lua-detection | ||
differences-from-snort | ||
multi-buffer-matching |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,92 @@ | ||||||||||
Multiple Buffer Matching | ||||||||||
======================== | ||||||||||
|
||||||||||
Suricata 7 and newer now supports matching contents in multiple | ||||||||||
buffers within the same transaction. | ||||||||||
|
||||||||||
For example a single DNS transaction that has two queries in it: | ||||||||||
|
||||||||||
query 1: example.net | ||||||||||
query 2: something.com | ||||||||||
|
||||||||||
Example rule: | ||||||||||
|
||||||||||
.. container:: example-rule | ||||||||||
|
||||||||||
`alert dns $HOME_NET any -> $EXTERNAL_NET any (msg:"DNS Multiple Question Example Rule"; dns.query; content:"example"; dns.query; content:".com"; classtype:misc-activity; sid:1; rev:1;)` | ||||||||||
|
||||||||||
Within the single DNS query transaction, there are two queries | ||||||||||
and Suricata will set up two instances of a dns.query buffer. | ||||||||||
|
||||||||||
The first ``dns.query`` buffer will look for content:"example"; | ||||||||||
|
||||||||||
The second ``dns.query`` buffer will look for content:".com"; | ||||||||||
|
||||||||||
The example rule will alert on the example query since all the | ||||||||||
content matches are satisfied for the rule. | ||||||||||
|
||||||||||
For matching multiple headers in HTTP2 traffic a rule using the | ||||||||||
new functionality would look like: | ||||||||||
|
||||||||||
.. container:: example-rule | ||||||||||
|
||||||||||
`alert http2 any any -> any any (msg:"HTTP2 Multiple Header Buffer Example"; flow:established,to_server; http.request_header; content:"method|3a 20|GET"; http.request_header; content:"authority|3a 20|example.com"; classtype:misc-activity; sid:1; rev:1;) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rule is missing closing ` |
||||||||||
|
||||||||||
With HTTP2 there are multiple headers seen in the same flow record. | ||||||||||
We now have a way to write a rule in a more efficient way using the | ||||||||||
multiple buffer capability. | ||||||||||
|
||||||||||
|
||||||||||
**Note** Existing behavior when using sticky buffers still applies: | ||||||||||
|
||||||||||
Example rule: | ||||||||||
|
||||||||||
.. container:: example-rule | ||||||||||
|
||||||||||
`alert dns $HOME_NET any -> $EXTERNAL_NET any (msg:"DNS Query Sticky Buffer Classic Example Rule"; dns.query; content:"example"; content:".net"; classtype:misc-activity; sid:1; rev:1;)` | ||||||||||
|
||||||||||
The above rule will alert on a single dns query containing | ||||||||||
"example.net" or "example.domain.net" since the rule content | ||||||||||
matches are within a single ``dns.query`` buffer and all | ||||||||||
content match requirements of the rule are met. | ||||||||||
|
||||||||||
|
||||||||||
**Note:** This is new behavior, in versions of Suricata prior to | ||||||||||
version 7 multiple statements of the same sticky buffer did not | ||||||||||
Comment on lines
+54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||||||
make a second instance of the buffer. For example: | ||||||||||
|
||||||||||
dns.query; content:"example"; dns.query; content:".com"; | ||||||||||
|
||||||||||
would be equivalent to: | ||||||||||
|
||||||||||
dns.query; content:"example"; content:".com"; | ||||||||||
|
||||||||||
Using our example from above, the first query is for example.net | ||||||||||
which matches content:"example"; but does not match content:".com"; | ||||||||||
|
||||||||||
The second query is for something.com which would match on the | ||||||||||
content:".com"; but not the content:"example"; | ||||||||||
|
||||||||||
So with the Suricata behavior prior to Suricata 7, the signature | ||||||||||
would not fire in this case since both content conditions will | ||||||||||
not be met. | ||||||||||
|
||||||||||
Multiple buffer matching is currently enabled for use with the | ||||||||||
following keywords: | ||||||||||
|
||||||||||
* ``dns.query`` | ||||||||||
* ``file.data`` | ||||||||||
* ``file.magic`` | ||||||||||
* ``file.name`` | ||||||||||
* ``http.request_header`` | ||||||||||
* ``http.response_header`` | ||||||||||
* ``http2.header_name`` | ||||||||||
* ``ike.vendor`` | ||||||||||
* ``krb5_cname`` | ||||||||||
* ``krb5_sname`` | ||||||||||
* ``mqtt.subscribe.topic`` | ||||||||||
* ``mqtt.unsubscribe.topic`` | ||||||||||
* ``quic.cyu.hash`` | ||||||||||
* ``quic.cyu.string`` | ||||||||||
* ``tls.certs`` | ||||||||||
* ``tls.cert_subject`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you list all these ? (Did you run a git grep ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the commit history for the patch set, though now I realize I would have missed any later commits. I went back and looked again and did miss something. So I will have an additional commit to this PR for review.
I do have a question about:
src/detect-quic-cyu-hash.c: DetectBufferTypeSupportsMultiInstance(BUFFER_NAME);
src/detect-quic-cyu-string.c: DetectBufferTypeSupportsMultiInstance(BUFFER_NAME);
Should () contain the respective quic buffer names instead of BUFFER_NAME?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be a macro #define BUFFER_NAME a few lines up...