From 45f40bac4cd256935d3157cd03f9434609d7a36a Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 22 May 2024 14:21:16 +0200 Subject: [PATCH] MEDIUM: config: prevent communication with privileged ports This commit introduces a new global setting named harden.reject_privileged_ports.{tcp|quic}. When active, communications with clients which use privileged source ports are forbidden. Such behavior is considered suspicious as it can be used as spoofing or DNS/NTP amplication attack. Value is configured per transport protocol. For each TCP and QUIC distinct code locations are impacted by this setting. The first one is in sock_accept_conn() which acts as a filter for all TCP based communications just after accept() returns a new connection. The second one is dedicated for QUIC communication in quic_recv(). In both cases, if a privileged source port is used and setting is disabled, received message is silently dropped. By default, protection are disabled for both protocols. This is to be able to backport it without breaking changes on stable release. This should be backported as it is an interesting security feature yet relatively simple to implement. --- doc/configuration.txt | 8 ++++++ include/haproxy/global-t.h | 2 ++ include/haproxy/protocol-t.h | 11 ++++++++ include/haproxy/tools.h | 16 +++++++++++ src/cfgparse-global.c | 51 ++++++++++++++++++++++++++++++++++++ src/haproxy.c | 2 ++ src/quic_sock.c | 6 +++++ src/sock.c | 4 +++ 8 files changed, 100 insertions(+) diff --git a/doc/configuration.txt b/doc/configuration.txt index 804a77e98..ef0cf8ea2 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -1276,6 +1276,8 @@ The following keywords are supported in the "global" section : - h1-case-adjust-file - h2-workaround-bogus-websocket-clients - hard-stop-after + - harden.reject-privileged-ports.tcp + - harden.reject-privileged-ports.quic - insecure-fork-wanted - insecure-setuid-wanted - issuers-chain-path @@ -1944,6 +1946,12 @@ hard-stop-after