Skip to content

Commit

Permalink
doh2: really enforce 65K dns message limit
Browse files Browse the repository at this point in the history
Ticket: #7464
  • Loading branch information
catenacyber committed Dec 17, 2024
1 parent 2c0d3b8 commit d2faa82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions rules/http2-events.rules
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ alert http2 any any -> any any (msg:"SURICATA HTTP2 too many streams"; flow:esta
alert http2 any any -> any any (msg:"SURICATA HTTP2 authority host mismatch"; flow:established,to_server; app-layer-event:http2.authority_host_mismatch; classtype:protocol-command-decode; sid:2290013; rev:1;)
alert http2 any any -> any any (msg:"SURICATA HTTP2 user info in uri"; flow:established,to_server; app-layer-event:http2.userinfo_in_uri; classtype:protocol-command-decode; sid:2290014; rev:1;)
alert http2 any any -> any any (msg:"SURICATA HTTP2 reassembly limit reached"; flow:established; app-layer-event:http2.reassembly_limit_reached; classtype:protocol-command-decode; sid:2290015; rev:1;)
alert http2 any any -> any any (msg:"SURICATA HTTP2 dns too long"; flow:established; app-layer-event:http2.dns_too_long; classtype:protocol-command-decode; sid:2290016; rev:1;)
11 changes: 8 additions & 3 deletions rust/src/http2/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,13 @@ impl HTTP2Transaction {
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 {
// a DNS message is U16_MAX
doh.data_buf[dir.index()].extend_from_slice(decompressed);
if doh.is_doh_data[dir.index()] {
if doh.data_buf[dir.index()].len() + decompressed.len() <= 0xFFFF {
// a DNS message is U16_MAX
doh.data_buf[dir.index()].extend_from_slice(decompressed);
} else {
self.set_event(HTTP2Event::DnsTooLong);
}
}
}
}
Expand Down Expand Up @@ -506,6 +510,7 @@ pub enum HTTP2Event {
AuthorityHostMismatch,
UserinfoInUri,
ReassemblyLimitReached,
DnsTooLong,
}

pub struct HTTP2DynTable {
Expand Down

0 comments on commit d2faa82

Please sign in to comment.