Skip to content

Commit 46a46e5

Browse files
catenacybervictorjulien
authored andcommitted
http2: event on mismatch between authority and host
Ticket: OISF#6425
1 parent ae72ce7 commit 46a46e5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

rules/http2-events.rules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ alert http2 any any -> any any (msg:"SURICATA HTTP2 failed decompression"; flow:
1818
alert http2 any any -> any any (msg:"SURICATA HTTP2 invalid range header"; flow:established; app-layer-event:http2.invalid_range; classtype:protocol-command-decode; sid:2290010; rev:1;)
1919
alert http2 any any -> any any (msg:"SURICATA HTTP2 variable-length integer overflow"; flow:established; app-layer-event:http2.header_integer_overflow; classtype:protocol-command-decode; sid:2290011; rev:1;)
2020
alert http2 any any -> any any (msg:"SURICATA HTTP2 too many streams"; flow:established; app-layer-event:http2.too_many_streams; classtype:protocol-command-decode; sid:2290012; rev:1;)
21+
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;)

rust/src/http2/http2.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,25 @@ impl HTTP2Transaction {
203203
}
204204

205205
fn handle_headers(&mut self, blocks: &[parser::HTTP2FrameHeaderBlock], dir: Direction) {
206+
let mut authority = None;
207+
let mut host = None;
206208
for block in blocks {
207209
if block.name == b"content-encoding" {
208210
self.decoder.http2_encoding_fromvec(&block.value, dir);
211+
} else if block.name.eq_ignore_ascii_case(b":authority") {
212+
authority = Some(&block.value);
213+
} else if block.name.eq_ignore_ascii_case(b"host") {
214+
host = Some(&block.value);
215+
}
216+
}
217+
if let Some(a) = authority {
218+
if let Some(h) = host {
219+
if !a.eq_ignore_ascii_case(h) {
220+
// The event is triggered only if both headers
221+
// are in the same frame to avoid excessive
222+
// complexity at runtime.
223+
self.set_event(HTTP2Event::AuthorityHostMismatch);
224+
}
209225
}
210226
}
211227
}
@@ -383,6 +399,7 @@ pub enum HTTP2Event {
383399
InvalidRange,
384400
HeaderIntegerOverflow,
385401
TooManyStreams,
402+
AuthorityHostMismatch,
386403
}
387404

388405
pub struct HTTP2DynTable {

0 commit comments

Comments
 (0)