Article View: linux.kernel.netdev
Article #741[PATCH nf-next v2] netfilter: nf_conntrack_sip: only honour Via: port in original direction
From: Joas Antonio dos Santos
Date: Thu, 08 Oct 2026 15:28
Date: Thu, 08 Oct 2026 15:28
57 lines
10848 bytes
10848 bytes
The Cisco phone workaround in process_sip_request() records the port
from the topmost Via: header in ct_sip_info->forced_dport whenever the
Via address matches the sender of the current request and the port
differs from the sender's source port. nf_nat_sip() then rewrites the
UDP destination port of every reply-direction packet to that value.
The workaround is meant for phones behind the NAT, i.e. requests in the
original direction, but the check is done in both directions. For a
request arriving in the reply direction, ct->tuplehash[dir].tuple.src
is the remote peer itself, so the peer meets the condition with a Via:
line carrying its own address and any port >= 1024. From then on its
datagrams on that flow are delivered to the NATed host on the port it
chose rather than the mapped one. No spoofing is needed, but the peer
has to be the SIP server or proxy the client talks to, and the effect
is limited to that flow.
Only honour the Via: port for requests in the original direction.
Found by manual inspection of nf_conntrack_sip.c and nf_nat_sip.c,
assisted by an LLM, and confirmed at runtime with client, router and
server network namespaces (nft masquerade plus a "sip" ct helper on the
router): the server's request and a following UDP payload reached the
client on the Via: port before this change, and the mapped port after.
Fixes: 7266507d8999 ("netfilter: nf_ct_sip: support Cisco 7941/7945 IP phones")
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Assisted-by: Claude:claude-opus-5-5
---
Changes in v2:
- Retarget to nf-next as a correctness fix (Pablo).
- Describe the precondition (rogue SIP peer, no spoofing) and how the
issue was found in the commit message.
net/netfilter/nf_conntrack_sip.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 64bc440b1..ef655a0bb 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -1586,8 +1586,14 @@ static int process_sip_request(struct sk_buff *skb, unsigned int protoff,
* router for one of these phones, save the port number from the
* Via: header so that nf_nat_sip can redirect the responses to
* the correct port.
+ *
+ * Only honour the Via: port for requests coming from the phone,
+ * i.e. in the original direction. The remote peer must not be
+ * able to pick the destination port of packets delivered to the
+ * NATed host.
*/
- if (ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen,
+ if (dir == IP_CT_DIR_ORIGINAL &&
+ ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen,
SIP_HDR_VIA_UDP, NULL, &matchoff,
&matchlen, &addr, &port) > 0 &&
port != ct->tuplehash[dir].tuple.src.u.udp.port &&
Technical Details
Message-ID:
<179147331732.58100.8577886696698663796@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343073-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343073-linux-kernel-netdev=dewy.ru
From: joasantonio108@gmail.com (Joas Antonio dos Santos)
Newsgroups: linux.kernel.netdev
Subject: [PATCH nf-next v2] netfilter: nf_conntrack_sip: only honour Via: port
in original direction
Date: Thu, 08 Oct 2026 12:28:37 -0300
Organization: Usenet Network
Message-ID: <179147331732.58100.8577886696698663796@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="909913"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:37oTvnGkg/8hmDXLkXP3F6Zfla4= sha256:nv8RW00AgMLAP2pPIeMhhxDIu2nMQh/cDldEv4n8v0E=
sha1:gIqTJn0cASaMwHOiuWN7oa3zM2Q= sha256:s0FIM0L1RD6fz3U0/lK6uZkEQMXB8oMdWmVfqJg1Adk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 6C2D310F443; Thu, 8 Oct 2026 18:33:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 1lZipaM239ND;
Thu, 8 Oct 2026 18:33:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-343073-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 6055F10F3E4; Thu, 8 Oct 2026 18:33:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id BF969365F5; Thu, 8 Oct 2026 15:29:14 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 5922A4D487E;
Thu, 8 Oct 2026 15:28:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NfXIMqsN"
X-Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF0834E36D7
for <netdev@vger.kernel.org>; Thu, 8 Oct 2026 15:28:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791473338; cv=none; b=qcoXBG+WYiRIZQfMowPzbyiHIupAbQGpKgZJH2ibGvZ8anAmEIcD3FL73imXwEHZJgfum6sDmOgWRXHTLxXTxTluTYGf3FfZTTvRgVF1eG7BTZYJSL1T7SOAMBguugCHjsyTtHBfqfzCnR2XSExSt9B98WmXfoMR6WSqq93AyfA=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791473338; c=relaxed/simple;
bh=9IArv5E0HDoDgrm+EOLj8lDAwLd2ErbcWCrSvCceLBw=;
h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=SZQJh/kft4fnQzmiUK2PRiEBfMfsj9UE4RHlHsrfS4kznA8oT49id2hSO7hp/ixDf3SivU6qG+LxZ2nzesqKtw3u7V9CRMwzPFT/9BxCNwsry+e8L85gJspiIhl6MuEN+A/X3Vjw/j4ntPI/0wCZoqSyIo1h4VmE/C2ti3RYZnA=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NfXIMqsN; arc=none smtp.client-ip=209.85.210.54
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-823545ce223so4533704a34.2
for <netdev@vger.kernel.org>; Thu, 08 Oct 2026 08:28:47 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1791473326; x=1792078126; darn=vger.kernel.org;
h=mime-version:content-transfer-encoding:content-type:message-id:date
:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=oQ/GaoOi8qfcW0im1RCBWVWH2WffDR373jza/mtw0gw=;
b=NfXIMqsNGbw+vfpL75dXTzLc7fqvSAbsJjc0ESuyn/LJ7Vne/+1t85oReQgCzVV7tK
L4Ji2k4CgmqzXdu5jFxVkLWY9Ujb3HpCjAUhbLnvZ6NBm8egTetndOMzAyqyF0WFVlCI
Jyx/zMCaI4ahhDdVIwotYc1kCXMdH7SGwuUvJVlanRz0+eRDBjpwF/uoV/P7DxCua1jS
s9m/SvkWMrus27hfoe2rcX/gYPNYQ8AaLpcySURnayhUSnvG0ecq3ToaVdzVPN4ZoJn2
+cjMa99sDICTA8NF4tpOSYJvY+NqpcTc+be2yLq97VwXvy3L9+7V123p9iof+C6ykb0Y
LX+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791473326; x=1792078126;
h=mime-version:content-transfer-encoding:content-type:message-id:date
:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=oQ/GaoOi8qfcW0im1RCBWVWH2WffDR373jza/mtw0gw=;
b=yg1MoSzzoKzTXSsWnafWkU7sVn7+4ZFcMUN1KRXOATYiQ6WtNrdSaWeso8DlC8fqfS
kGxjIuJA0pjludFj3W5XVCJHBiXMk2CDPnhsz1/E5drWOC+5hjB8paokrzbXCOfK1YNe
NFSMvnVq2RteHdXltDqmU4O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SvI5rVrw==
X-Received: by 2002:a05:6830:349e:b0:800:d883:9988 with SMTP id 46e09a7af769-82ac9d8f975mr7498436a34.0.1791473326271;
Thu, 08 Oct 2026 08:28:46 -0700 (PDT)
X-Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa ([2804:7f0:b100:655c:c517:c6a0:13b2:a6e1])
by smtp.gmail.com with ESMTPSA id 46e09a7af769-82adcd0f5d7sm5853429a34.27.2026.10.08.08.28.43
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 08 Oct 2026 08:28:45 -0700 (PDT)
X-Cc: Phil Sutter <phil@nwl.cc>, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, netdev@vger.kernel.org
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>