-
Notifications
You must be signed in to change notification settings - Fork 375
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
Fix default reject rule to correctly handle packets that should be assembled #6857
base: main
Are you sure you want to change the base?
Conversation
…assembled When using an L7 NetworkPolicy that allows egress HTTP requests, the corresponding Suricata rules may look like the following example: ``` reject ip any any -> any any (msg: "Reject by AntreaNetworkPolicy:default/egress-allow-http"; flow: to_server, established; sid: 1;) pass http any any -> any any (msg: "Allow http by AntreaNetworkPolicy:default/egress-allow-http"; http.method; content:"GET"; sid: 2;)` ``` If an HTTP request exceeds the MTU, it will be split into multiple packets. The packets should be reassembled and allowed by the corresponding Suricata rule for the L7 NetworkPolicy. However, there is a default reject rule which is to reject packets which are not matched by the `pass` rule, which will take effect before packets are reassembled and matched by the `pass` rule, causing the connection to fail. To address the issue, the keyword `only_stream` is added to the default reject rule. This ensures that only reassembled packets are matched, preventing premature rejection of packets that should be allowed after reassembly. Signed-off-by: Hongliang Liu <[email protected]>
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.
Great finding.
But does it fix a new issue or #6806?
I have read about the We definitely need to test the case where request packets (to_server) exceed the MTU, with a new e2e test. The e2e tests are currently failing with this change:
BTW, I have found that testing Suricata rules is much more convenient when using a pcap file and running Suricata in offline mode. While we still need e2e tests, I wonder if we could have some extra tests (maybe with input pcap and expected JSON logs) to quickly evaluate our Suricata rules. Maybe the best approach would be to have a separate repo where we can keep some reference pcaps that people can use when working on L7NP (bug fixing, support for new protocols, etc.). What do you think @tnqn @hongliangl? |
I don't know if the current patch is correct because tests are failing. |
This PR cannot fix #6876 since the keyword |
When using an L7 NetworkPolicy that allows egress HTTP requests, the corresponding Suricata rules may look like the following example:
If an HTTP request exceeds the MTU, it will be split into multiple packets. The packets should be reassembled and allowed by the corresponding Suricata rule for the L7 NetworkPolicy.
However, there is a default reject rule which is to reject packets which are not matched by the
pass
rule, which will take effect before packets are reassembled and matched by thepass
rule, causing the connection to fail.To address the issue, the keyword
only_stream
is added to the default reject rule. This ensures that only reassembled packets are matched, preventing premature rejection of packets that should be allowed after reassembly.