]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
quic: handle retry packets
authorPhilippe Antoine <pantoine@oisf.net>
Wed, 19 Feb 2025 12:01:36 +0000 (13:01 +0100)
committerPhilippe Antoine <pantoine@oisf.net>
Sun, 23 Feb 2025 20:24:04 +0000 (21:24 +0100)
Ticket: 7556
(cherry picked from commit 6d8910d2455adcfd92c5970a3654d0bf90546489)

rust/src/quic/parser.rs
rust/src/quic/quic.rs

index 25527439941333c14d23e2818b7ff0e0d00457cc..3fba85040b375a6554e2b84a09874677e0b1fd6f 100644 (file)
@@ -357,6 +357,10 @@ impl QuicHeader {
                         rest
                     }
                 }
+                QuicType::Retry => {
+                    // opaque retry token and 16 bytes retry integrity tag
+                    &rest[rest.len()..]
+                }
                 _ => rest,
             };
             let (rest, length) = if has_length {
index 6063ac65386d1267649e718155c8a9fc5c80a1d4..f0e40f72a2bf52be44106492d65c7ec32adb37bb 100644 (file)
@@ -334,12 +334,16 @@ impl QuicState {
                     // unprotect/decrypt packet
                     if self.keys.is_none() && header.ty == QuicType::Initial {
                         self.keys = quic_keys_initial(u32::from(header.version), &header.dcid);
+                    } else if !to_server && self.keys.is_some() && header.ty == QuicType::Retry {
+                        // a retry packet discards the current keys, client will resend an initial packet with new keys
+                        self.hello_ts = false;
+                        self.keys = None;
                     }
                     // header.length was checked against rest.len() during parsing
                     let (mut framebuf, next_buf) = rest.split_at(header.length.into());
                     let hlen = buf.len() - rest.len();
                     let mut output;
-                    if self.keys.is_some() {
+                    if self.keys.is_some() && !framebuf.is_empty() {
                         output = Vec::with_capacity(framebuf.len() + 4);
                         if let Ok(dlen) =
                             self.decrypt(to_server, &header, framebuf, buf, hlen, &mut output)