]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: forbid data on stream 0
authorPhilippe Antoine <pantoine@oisf.net>
Tue, 15 Apr 2025 10:34:37 +0000 (12:34 +0200)
committerVictor Julien <vjulien@oisf.net>
Thu, 3 Jul 2025 10:16:22 +0000 (12:16 +0200)
Ticket: 7658

Suricata will not handle well if we open a file for this tx,
do not close it, but set the transaction state to completed.

RFC 9113 section 6.1 states:

If a DATA frame is received whose Stream Identifier field is 0x00,
the recipient MUST respond with a connection error (Section 5.4.1)
 of type PROTOCOL_ERROR.

rules/http2-events.rules
rust/src/http2/http2.rs

index 7509eb0ea6e34805bcb90dbced45fba26160f21b..019e3feff141ceff197807cf2304bbde827ec59b 100644 (file)
@@ -23,3 +23,4 @@ alert http2 any any -> any any (msg:"SURICATA HTTP2 user info in uri"; flow:esta
 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 request too long"; flow:established,to_server; app-layer-event:http2.dns_request_too_long; classtype:protocol-command-decode; sid:2290016; rev:1;)
 alert http2 any any -> any any (msg:"SURICATA HTTP2 dns response too long"; flow:established,to_client; app-layer-event:http2.dns_response_too_long; classtype:protocol-command-decode; sid:2290017; rev:1;)
+alert http2 any any -> any any (msg:"SURICATA HTTP2 data on stream zero"; flow:established; app-layer-event:http2.data_stream_zero; classtype:protocol-command-decode; sid:2290018; rev:1;)
index 5b7797551362f221105bc426375cccaff57d64f8..7f178d18bd30f50af0c7d58961c3e19a18890355 100644 (file)
@@ -528,6 +528,7 @@ pub enum HTTP2Event {
     ReassemblyLimitReached,
     DnsRequestTooLong,
     DnsResponseTooLong,
+    DataStreamZero,
 }
 
 pub struct HTTP2DynTable {
@@ -1248,7 +1249,9 @@ impl HTTP2State {
                             data: txdata,
                         });
                     }
-                    if ftype == parser::HTTP2FrameType::Data as u8 {
+                    if ftype == parser::HTTP2FrameType::Data as u8 && sid == 0 {
+                        tx.tx_data.set_event(HTTP2Event::DataStreamZero as u8);
+                    } else if ftype == parser::HTTP2FrameType::Data as u8 && sid > 0 {
                         match unsafe { SURICATA_HTTP2_FILE_CONFIG } {
                             Some(sfcm) => {
                                 //borrow checker forbids to reuse directly tx