From 596f2e31ae7cee26e4f39f300cc69605f4ba512f Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 22 Dec 2022 15:58:27 +0100 Subject: nft: Reject tcp/udp extension without proper protocol match Internally, 'th' expression is used, which works but matches both protocols. Since users won't expect '-m tcp --dport 1' to match UDP packets, catch missing/wrong '-p' argument. Fixes: c034cf31dd1a9 ("nft: prefer native expressions instead of udp match") Signed-off-by: Phil Sutter --- extensions/libxt_udp.t | 3 +++ 1 file changed, 3 insertions(+) (limited to 'extensions/libxt_udp.t') diff --git a/extensions/libxt_udp.t b/extensions/libxt_udp.t index 1b4d3dd6..f5347701 100644 --- a/extensions/libxt_udp.t +++ b/extensions/libxt_udp.t @@ -18,5 +18,8 @@ # -p udp -m udp --sport 65536;;FAIL -p udp -m udp --sport -1;;FAIL -p udp -m udp --dport -1;;FAIL +-m udp --dport 1;;FAIL +-m udp --dport 1 -p udp;-p udp -m udp --dport 1;OK +-m udp --dport 1 -p 17;-p udp -m udp --dport 1;OK # should we accept this below? -p udp -m udp;=;OK -- cgit v1.2.3