Skip to content
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

Dns invalid additionals 7228 v4 #11794

Closed

Conversation

catenacyber
Copy link
Contributor

Link to ticket: https://redmine.openinfosecfoundation.org/issues/
https://redmine.openinfosecfoundation.org/issues/7228

Describe changes:

  • dns: improved handling of corrupt additionals
  • dns: improve probing parser by making it more strict to have better ground truth on QA

SV_BRANCH=OISF/suricata-verify#2032

#11785 with newer commit for the DNS probing parser improvement

@jasonish what do you think about it ?
Should we have a separate ticket and PR to handle first the probing parser ?

Ticket: 7228

That means log the rest of queries and answers, even if the
final field additionals is corrupt.
Set an event in this case.
To accomodate cases found in QA.
The case looks like a CnC channel on port 53, but not using DNS.

First request has a very big record length, but all the header
fields indicating numbers are 0.

First reply has a very big record length as well, there is one
non-zero field for number, but the flag indicates a request...
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.57%. Comparing base (d3eb656) to head (e898e77).
Report is 264 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11794      +/-   ##
==========================================
+ Coverage   82.53%   82.57%   +0.03%     
==========================================
  Files         919      919              
  Lines      248979   249012      +33     
==========================================
+ Hits       205506   205624     +118     
+ Misses      43473    43388      -85     
Flag Coverage Δ
fuzzcorpus 60.41% <100.00%> (+0.08%) ⬆️
livemode 18.71% <0.00%> (-0.01%) ⬇️
pcap 44.16% <83.67%> (+<0.01%) ⬆️
suricata-verify 61.88% <85.71%> (+<0.01%) ⬆️
unittests 58.99% <65.30%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 649 627 96.61%
.app_layer.error.dns_tcp.parser 30 3 10.0%

Pipeline 22741

let is_request = header.flags & 0x8000 == 0;
if dir == Direction::ToClient && is_request && rlen > 0x1000 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use a number here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean ?

Copy link
Member

@jasonish jasonish Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rlen > 4096? Or is there some reason to use the hex value here?

let is_request = header.flags & 0x8000 == 0;
if dir == Direction::ToClient && is_request && rlen > 0x1000 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, shoud we check the direction here? The direction could be flipped based on the return value of this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good question :
My point is to gather 2 hints that this is not DNS : direction is flipped, and record length is big (as the comment states below)

Do you have real cases in DNS where the direction is actually flipped ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess my question to you is how would you handle the private pcaps ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have real cases in DNS where the direction is actually flipped ?

This can happen when there is packet loss and the request is lost, the response will be picked up as a request I believe. The S-V test dns-reversed-udp-1 shows this "flow" flipping in action - however, lacks the test to test it, which should probably be added.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -718,7 +734,7 @@ impl DNSState {

const DNS_HEADER_SIZE: usize = 12;

fn probe_header_validity(header: &DNSHeader, rlen: usize) -> (bool, bool, bool) {
fn probe_header_validity(header: &DNSHeader, rlen: usize, dir: Direction) -> (bool, bool, bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think its time this function get some proper documentation as its no longer trivial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, but do you mean you agree with the changes ? (if there is nothing to change, should we document it ? )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the changes, but as its got more complex I think it should now contain what all the constraints are as function documentation.

@jasonish
Copy link
Member

Should we have a separate ticket and PR to handle first the probing parser ?

Needs a ticket for sure.

@catenacyber
Copy link
Contributor Author

Should we have a separate ticket and PR to handle first the probing parser ?

Needs a ticket for sure.

Will do

@catenacyber
Copy link
Contributor Author

Created https://redmine.openinfosecfoundation.org/issues/7279 how does it look ?

@catenacyber catenacyber marked this pull request as draft September 26, 2024 13:55
@catenacyber
Copy link
Contributor Author

Status : to be rebased after merge of #11859 or later

@catenacyber catenacyber added needs rebase Needs rebase to master and removed needs baseline update QA will need a new base line labels Dec 20, 2024
@catenacyber
Copy link
Contributor Author

catenacyber commented Jan 7, 2025

Rebased in #12349

@catenacyber catenacyber closed this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase Needs rebase to master
Development

Successfully merging this pull request may close these issues.

3 participants