-
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
Dcerpc incomplete 5699/v14 #12320
Dcerpc incomplete 5699/v14 #12320
Conversation
TCP data can be presented to the protocol parser in any way e.g. one byte at a time, single complete PDU, fragmented PDU, multiple PDUs at once. A limit of 1MB can be easily reached in some of such scenarios. Remove the check that rejects data that is more than 1MB.
to make it available for logging.
Instead of own internal mechanism of buffering in case of fragmented data, use AppLayerResult::incomplete API to let the AppLayer Parser take care of it. This makes the memory use more efficient. Remove any unneeded variables and code with the introduction of this API. Ticket 5699
With the introduction of AppLayerResult::incomplete API, fragmented data is no longer handled fully in the dcerpc code. Given that these code paths are already covered by the following s-v tests, these tests can now be safely removed. - dce-gap-handling - dcerpc-dce-iface-* Ticket 5699
- remove unneeded variables - remove unnecessary tracking of bytes in state - modify calculations as indicated by failing tests
as it is now covered by the suricata-verify test dcerpc-request-http-response.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #12320 +/- ##
==========================================
- Coverage 83.26% 83.22% -0.04%
==========================================
Files 912 912
Lines 257643 257274 -369
==========================================
- Hits 214521 214121 -400
- Misses 43122 43153 +31
Flags with carried forward coverage won't be shown. Click here to find out more. |
WARNING:
Pipeline 24047 |
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.
This is my assessment of the stats deviations.
What data do the deviations occur for?
Any incomplete data that does not follow the direction rules expected by the parser.
Behavior in master
- We define two parameters in the protocol state that control direction:
data_needed_for_dir
andprev_dir
. So, if the direction of current input data does not match the expected direction, an error is returned. ref: https://github.com/OISF/suricata/blob/master/rust/src/dcerpc/dcerpc.rs#L979 - Because the protocol parser returns an error, despite the initial detection being dcerpc, the flow counter is not incremented. Open ticket for this issue: https://redmine.openinfosecfoundation.org/issues/7238
Behavior in this branch
- There is no direction control, the data is parsed as it comes for whatever direction and if it is incomplete, it is conveyed to the common applayer parser. This is buggy as it might overwrite the common state params. But for the test data at hand, this falls in this particular case every time: https://github.com/OISF/suricata/blob/master/src/app-layer.c#L664
- As a result of this, the flow counter ends up being incremented as many times as the parser returned the data was incomplete. <- This looks like a bug to me. I think we should only once increment the flow counter in case of incomplete status of parser on the same flow or at the end of the detection. Thoughts? 👈🏽 [Answer this]
Information common to this entire situation
- The pcap is weird and all the "dcerpc" detected data seems to be trailing data in TCP sessions. Wireshark does not detect the traffic as dcerpc.
My verdict
I think that the stats deviations caused by this PR are incorrect.
- Quick fix for that is to reintroduce direction control as in master. Shall I move forward w this? 👈🏽 [Answer this]
- There is perhaps another issue being unmasked here about unnecessary flow counter increment. 👈🏽 [Answer this]
Should we not be able to support both directions having incomplete data ?
It is indeed a bug if a flow is counted multiple times.
I do not think so
I think so, what will be next in this rabbit hole ? |
I just looked at
You are right indeed. Checking the flow id shows that even though the common tuple looks the same, they're different flows. I should have done this before. Thank you! 🙇🏽♀️
ok. Then, I think we have to accept the stats deviations because:
|
Can you create a SV test that shows this behavior ? |
Let me see if I can get TLPW for this. |
TLPW or craft something with scapy entirely artificial now that you know the conditions... |
Victor believes that the behavior in master is more correct. So, added back the direction control in the new rev. |
Maybe
Not sure I agree here, but I guess we should share a pcap to discuss on it |
Got into another rabbit hole as some stats weren't matching up despite direction control and it is now again seeming to be related to issue with the flow counter update. Sharing a PR just to fix the flow counter update on a special case to get feedback. |
Link to redmine ticket: https://redmine.openinfosecfoundation.org/issues/5699
Previous PR: #12219
Changes since v13: