From 6d0b0ca48855f6f055521870a7ba6d04f7c95867 Mon Sep 17 00:00:00 2001 From: Ximon Eighteen <3304436+ximon18@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:39:54 +0200 Subject: [PATCH] FIX: Servers should drop received DNS response messages, not propagate them for processing. --- src/net/server/connection.rs | 10 ++++++++++ src/net/server/dgram.rs | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/net/server/connection.rs b/src/net/server/connection.rs index a805b1b17..b90868682 100644 --- a/src/net/server/connection.rs +++ b/src/net/server/connection.rs @@ -670,6 +670,7 @@ where match Message::from_octets(buf) { Err(err) => { + // TO DO: Count this event? tracing::warn!( "Failed while parsing request message: {err}" ); @@ -678,6 +679,15 @@ where )); } + // https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.1 + // 4.1.1. Header section format + // "QR A one bit field that specifies whether this + // message is a query (0), or a response (1)." + Ok(msg) if msg.header().qr() => { + // TO DO: Count this event? + trace!("Ignoring received message because it is a reply, not a query."); + } + Ok(msg) => { let ctx = NonUdpTransportContext::new(Some( self.config.load().idle_timeout, diff --git a/src/net/server/dgram.rs b/src/net/server/dgram.rs index 752b8f4ca..61db8be1f 100644 --- a/src/net/server/dgram.rs +++ b/src/net/server/dgram.rs @@ -511,7 +511,18 @@ where tokio::spawn(async move { match Message::from_octets(buf) { Err(err) => { - tracing::warn!("Failed while parsing request message: {err}"); + // TO DO: Count this event? + warn!("Failed while parsing request message: {err}"); + } + + // https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.1 + // 4.1.1. Header section format + // "QR A one bit field that specifies whether + // this message is a query (0), or a + // response (1)." + Ok(msg) if msg.header().qr() => { + // TO DO: Count this event? + trace!("Ignoring received message because it is a reply, not a query."); } Ok(msg) => {