From 1536f08d819601554dfc6bb1edb08f58e21c354e Mon Sep 17 00:00:00 2001 From: strawberry Date: Wed, 24 Jan 2024 18:34:41 -0500 Subject: [PATCH] use both is_ip_literal and IPAddress is_valid checks Signed-off-by: strawberry --- src/api/server_server.rs | 4 +++- src/service/sending/mod.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 3ab5709c..58db059f 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -132,7 +132,9 @@ where )); } - if destination.is_ip_literal() { + // rust's built in parsing does not consider things like octal addresses valid + // so we should check both just to be safe. + if destination.is_ip_literal() || IPAddress::is_valid(destination.host()) { info!( "Destination {} is an IP literal, checking against IP range denylist.", destination diff --git a/src/service/sending/mod.rs b/src/service/sending/mod.rs index b05bef2b..3bf18aac 100644 --- a/src/service/sending/mod.rs +++ b/src/service/sending/mod.rs @@ -717,7 +717,9 @@ impl Service { where T: Debug, { - if destination.is_ip_literal() { + // rust's built in parsing does not consider things like octal addresses valid + // so we should check both just to be safe. + if destination.is_ip_literal() || IPAddress::is_valid(destination.host()) { info!( "Destination {} is an IP literal, checking against IP range denylist.", destination