Skip to content

Comments

Dns over http2 5773 v18.1#11533

Closed
catenacyber wants to merge 9 commits intoOISF:masterfrom
catenacyber:dns-over-http2-5773-v18.1
Closed

Dns over http2 5773 v18.1#11533
catenacyber wants to merge 9 commits intoOISF:masterfrom
catenacyber:dns-over-http2-5773-v18.1

Conversation

@catenacyber
Copy link
Contributor

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

Describe changes:

  • analyze DNS over HTTP2

SV_BRANCH=OISF/suricata-verify#1980

#11498 with needed rebase

Should there be a squash up of commits ?

@jasonish still same question : here for a DOH2 tx, we log a bidirectional HTTP2 transaction, and then if any, a DNS transaction, preferring the answer... What do you think about it ? This allows to keep the same format as for regular dns.
Another option would be to log two doh2 events : one for the DNS request and one for the DNS answer, with HTTP2 getting logged twice... not sure how it would work out for alerts...

by making tx parsing and creation more easily available,
without needing a dns state.

Dns event NotResponse is now set on the right tx, and not the one
before.

Also debug log for Z-flag on request says "request" instead of
"response"

Also rustfmt dns.rs
Now a flow alproto can be changed by a call to AppLayerParserParse
when HTTP2 forces the flow to turn into DOH2.
Ticket: 5773

Handles both directions the same way for data if content type is
application/dns-message
So as to consume less memory for HTTP2Transaction
@codecov
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 92.80000% with 27 lines in your changes missing coverage. Please review.

Project coverage is 82.51%. Comparing base (6598a69) to head (466038b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11533      +/-   ##
==========================================
- Coverage   82.54%   82.51%   -0.03%     
==========================================
  Files         923      923              
  Lines      248460   248696     +236     
==========================================
+ Hits       205083   205209     +126     
- Misses      43377    43487     +110     
Flag Coverage Δ
fuzzcorpus 60.37% <64.26%> (-0.15%) ⬇️
livemode 18.63% <6.13%> (-0.02%) ⬇️
pcap 44.12% <79.73%> (+0.13%) ⬆️
suricata-verify 61.75% <85.06%> (+0.02%) ⬆️
unittests 59.07% <33.33%> (-0.04%) ⬇️

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

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 21626

Copy link
Member

@victorjulien victorjulien left a comment

Choose a reason for hiding this comment

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

Some nits and minor questions inline.

if unsafe { ALPROTO_DOH2 } != ALPROTO_UNKNOWN {
// we store DNS response, and process it when complete
if let Some(doh) = &mut self.doh {
if doh.is_doh_data[dir.index()] && doh.data_buf[dir.index()].len() < 0xFFFF {
Copy link
Member

Choose a reason for hiding this comment

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

should there be an event if we exceed this?

}

// doh2 is just http2 wrapped in another name
parser.name = b"doh2\0".as_ptr() as *const std::os::raw::c_char;
Copy link
Member

Choose a reason for hiding this comment

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

should there be a check that http2 is enabled?

ssh:
enabled: yes
#hassh: yes
doh2:
Copy link
Member

Choose a reason for hiding this comment

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

comment to explain it is dns over http2, depends on http2 parsing

}
bool r2 = false;
if (tx_dns) {
// mix of JsonDnsLogger
Copy link
Member

Choose a reason for hiding this comment

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

don't understand this comment

#endif

// Get inner transaction for engine
void *DetectGetInnerTx(void *tx_ptr, AppProto alproto, AppProto engine_alproto, uint8_t flow_flags)
Copy link
Member

Choose a reason for hiding this comment

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

could be inline since its called a lot?

@victorjulien
Copy link
Member

Wrt the logging, I think we can sort this out after merge.

{ ALPROTO_TELNET, "telnet" },
{ ALPROTO_WEBSOCKET, "websocket" },
{ ALPROTO_LDAP, "ldap" },
{ ALPROTO_DOH2, "doh2" },
Copy link
Member

Choose a reason for hiding this comment

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

is this an generally used name for DNS over HTTP/2? Or are ppl just using doh? could perhaps use dns-http2 or similar

@victorjulien victorjulien added this to the 8.0 milestone Jul 20, 2024

#define PACKET_PROFILING_APP_END(dp, id) \
if (profiling_packets_enabled) { \
BUG_ON((id) != (dp)->alproto); \
Copy link
Member

Choose a reason for hiding this comment

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

what about the other protocols where this should still hold?

pub doh_data_buf: [Vec<u8>; 2],
pub dns_request_tx: Option<DNSTransaction>,
pub dns_response_tx: Option<DNSTransaction>,
pub doh: Option<DohHttp2Tx>,
Copy link
Member

Choose a reason for hiding this comment

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

noice :)

@victorjulien
Copy link
Member

Merged in #11536, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants