🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6542

[PATCH] netfilter: nf_conntrack_sip: fix out-of-bounds read in ct_sip_parse_transport()

#6542
From: Duc Anh Luu
Date: Thu, 22 Oct 2026 17:22
60 lines
13313 bytes
ct_sip_parse_transport() compares the "transport=" parameter value against
"TCP" and "UDP" with a fixed length of 3, without first checking that the
parsed value is that long:

	if (ct_sip_parse_param(ct, dptr, dataoff, datalen, "transport=",
			       &matchoff, &matchlen)) {
		if (!strncasecmp(dptr + matchoff, "TCP", strlen("TCP")))
		...

ct_sip_parse_param() sets the value end to the surrounding limit when no
';' delimiter follows, and that limit can be the end of the SIP message
(dptr + datalen) when no ',' is present either. A Contact/Via parameter
such as "transport=tc" placed at the very end of the payload therefore
yields matchlen < 3 with matchoff + matchlen == datalen, and the
strncasecmp() reads up to two bytes past the end of the message buffer.

The value of the over-read bytes can also flip the detected transport,
so this is not purely a read: a crafted short value can make the helper
classify the transport using out-of-bounds data.

Both call sites (process_register_request() and
process_register_response()) are reached from attacker-supplied SIP
traffic when the nf_conntrack_sip helper is active.

Bound each comparison by matchlen. A value shorter than three characters
can never equal "TCP"/"UDP", so this only rejects already-malformed input
and leaves valid transports (TCP, UDP, TLS, SCTP, ...) unchanged.

Reachability and behavioural equivalence were verified with a userspace
ASan harness built from the verbatim parser functions: the over-read is
confirmed as a read past dptr + datalen, and the fix removes it while
producing identical results for all well-formed transport values.

Fixes: f5b321bd37fb ("netfilter: nf_conntrack_sip: add TCP support")
Signed-off-by: Duc Anh Luu <luuducanh05051995@gmail.com>
---
 net/netfilter/nf_conntrack_sip.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 64bc440b1181..1f9cf75c7bd5 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -701,9 +701,11 @@ static int ct_sip_parse_transport(struct nf_conn *ct, const char *dptr,
 
 	if (ct_sip_parse_param(ct, dptr, dataoff, datalen, "transport=",
 			       &matchoff, &matchlen)) {
-		if (!strncasecmp(dptr + matchoff, "TCP", strlen("TCP")))
+		if (matchlen >= 3 &&
+		    !strncasecmp(dptr + matchoff, "TCP", strlen("TCP")))
 			*proto = IPPROTO_TCP;
-		else if (!strncasecmp(dptr + matchoff, "UDP", strlen("UDP")))
+		else if (matchlen >= 3 &&
+			 !strncasecmp(dptr + matchoff, "UDP", strlen("UDP")))
 			*proto = IPPROTO_UDP;
 		else
 			return 0;
-- 
2.43.0
Technical Details
Message-ID: <20261022172248.554687-1-luuducanh05051995@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-350718-linux-kernel-netdev=dewy.ru

Show 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-350718-linux-kernel-netdev=dewy.ru
From: luuducanh05051995@gmail.com (Duc Anh Luu)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] netfilter: nf_conntrack_sip: fix out-of-bounds read in ct_sip_parse_transport()
Date: Fri, 23 Oct 2026 00:22:48 +0700
Organization: Usenet Network
Message-ID: <20261022172248.554687-1-luuducanh05051995@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="274743"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ynS/MkvCgvfNPC+Q0zJxTwXS9oM= sha256:j6ZHw3muxwh4UHZeYgrCPRwe4umlyxy1uC7Tk31Gjjw=
	sha1:SRrDyvKi69UsaddP6sc/7n14+p8= sha256:iSg0BXhMfYQi8KZgUF367pMGm10Vm0qASD1j9Q5/q7c=
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 E4C2E111310; Thu, 22 Oct 2026 20:26:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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.25,
	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 l9EZIvxspTFY;
	Thu, 22 Oct 2026 20:26:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350718-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id B8E0211130B; Thu, 22 Oct 2026 20:25:58 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id CD04C2ECB5; Thu, 22 Oct 2026 17:23:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792689783;
	b=TDi2Xig2knXANogVzjKzrn4MkNUr37rPHdrz2DRLxPiaJVG8OOvPRxZfFjxCHVBj3SO6
	 +tt6q+CHCdmKMp8mDRncMl1Rqmn0CEOBRuRC9ueZ9CyMHVyDtSnCbkudm/MRukunQ/c0f
	 N/0BAdk6AwszpetaiUbslqP88Im9QeCFAYtW+zdYI3IZEwE+jqrIA8A9lv4eGY1mgPE1J
	 q0Br+gvlQxJ1Q0124TWO1AcFGpqLkunz3ACx93fGpFCdPYohVVrFiAQyci3xIIJHWK+Bv
	 vD0dJ0rcPSQRg/4vKLyZGWB1zPNcbCpWbT6KgLukhiB2FiCNFTPRLW+Ggh9GFeRKhEA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792689783;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=3Fxnb+tmDz8vD/RCSb1yDfS8uHLVRtbiJwimxAWXwl8=;
	b=zMi9Qv81fZvs5zpDE1AWd1KGvYL3QzDK9/uIBefCJfmIzANtFNDP3xKMO6P/VRB6AtzU
	 xb9TyKwWR7BSu+SbkULj6ojWxnN30DGM40gdhjq1OXiPNk/y40vmQfmhu4wjwCSYhBYg1
	 /m3lYMVNDXPeDPzVZVuqmX1WeDNk4aOhUjqybRQu156h3BAsoyh8anTvPPxVxoL8+pZ4U
	 xtBfx8V3eZ8OrwrYhfxDRiLVTiphNPY1Ejcj7lTBSh+ed41Q04OPvWY4Zr+7m8ZObMvln
	 PLQk25H3g7sa+4D8ehoRE0XfdJlBniAsldIt6VowgRy/3LSw/6OGk9P+ouVxl5Xxw+A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=D7y+e548;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C4DF606A32C;
	Thu, 22 Oct 2026 17:23:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=D7y+e548
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.180
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792689777;
	b=IuzgFvTvbfk8fFvMBnCyILr/YDn8mEOvwL9keUp/bTGQlVPK3C6GntERknEc7kPS1r8M
	 kutPsByJg8YPMXx2d8M5m+x4WGE/GUPWiXDUHiUwEWgq9xANQNRMVfftVcy6GmkuJi+hh
	 tr2OqaRBxGJ//u+Bgy5CORQ8Eb+xlDJlbMZNe4jqSvZoIdHyt1hrzXBittTA7SiqQ1bjC
	 /ViNAOcEyVceaRjySu0NIKXloa/sK2+0rbEoZ8rg3hmA2ManW/Xnkq2rE9j/Ar+NjcCz9
	 7XMpnc95r2ubCq6xP7Wq30tKyjFDSL9rg2zPEMj/aD9gu4Ej6VB0LKZBjSg7BNwe5VA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792689777;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=3Fxnb+tmDz8vD/RCSb1yDfS8uHLVRtbiJwimxAWXwl8=;
	b=5iPmM8LhyQhKDs2zxR49Q3Y6DF9ZZc5rP1KjhwIX58E57/yOWVI98t6WZPi5ODiA5KPl
	 loGc5tp8KwZX5cI5tY7OIICTsVxMUFLrrU0baYn5gbXPGkOeHZRbnvBAsdG6tEOyiE0mV
	 qCnV5Edx6L9+dy5HGIKDY0ooGLbryusNnK550+OZnYj2LFGWP8yJ/T01B473/Kwjxypvx
	 KerBP5qIWthH5x+SW1yO8Bl1TE7fzqP/dR8rUXZw6rtcbf94ep1eTyKYJDlwbL+5bmnUn
	 UQSjPxbjnlFkMGTqUfCTO/G5r4yDR4E+5WG/eA7S73LJJ/w13auDidbZB9u80ZirpsQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=D7y+e548;
	arc=none smtp.remote-ip=209.85.214.180
X-Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A765C606A321
	for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 17:22:56 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A765C606A321
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-pl1-f180.google.com with SMTP id d9443c01a7336-2e8246b13cbso16947675ad.2
        for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 10:22:56 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792689776; x=1793294576; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=3Fxnb+tmDz8vD/RCSb1yDfS8uHLVRtbiJwimxAWXwl8=;
        b=D7y+e548RrVflPxq20p6GTx6fhtREdk3YQuLBVSgVzBv+bTswPoGTzj3iua7j9o1dk
         6YR/zzZ5fm9OmD91z2AUk2nEWIDH5+2Hv5gClEbE+knloO7Y4EiOheYnaoQc81H9Zp4B
         XWFsHK0v+nRiIcSyej8SvGnzPruFGf0D/+D6vPIJU+ZOQ32+dHKDgWBYjAnfpK4HXygv
         RzeRMc5jur2GRVX5+GDojE4Dcyy0ZLU5AHJxovZSFddDPdli05xu93cgEXlL/d0ZXMVw
         2TxF61j6SxekpAzrwUvE9mm3i8GCMX17RUE/tqzyT2Hc4OjX32M0fY2ovHrIRIHpizwn
         4S1g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792689776; x=1793294576;
        h=content-transfer-encoding:mime-version: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=3Fxnb+tmDz8vD/RCSb1yDfS8uHLVRtbiJwimxAWXwl8=;
        b=XAKAQjsJ9+VLoJZN86bqWKTHIpbZMdeEv0wRB9SouqXtiENon7UpJ0wIKeqZYvEkUI
         ZDPpINGGabgnZxDISXMYyhhIlNuMPJP9skJFg+2u6TlOWRtXUqOHTlaUx3fko4FfenjV
         1Lhc4CzhmvnMUj1uDxM/FWCgQsTLJSaHL0urxwLnFTU3CWM2wIuXrJhJqFVGpeRtqfJl
         Sp8YtgPsot6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X-Received: by 2002:a17:903:1acc:b0:2e5:cb1f:898c with SMTP id d9443c01a7336-2ea43fb8270mr49485025ad.46.1792689775940;
        Thu, 22 Oct 2026 10:22:55 -0700 (PDT)
X-Received: from test.. ([118.68.116.19])
        by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ea7b3bc816sm1217915ad.51.2026.10.22.10.22.53
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 22 Oct 2026 10:22:55 -0700 (PDT)
X-Cc: netfilter-devel@vger.kernel.org,
	phil@nwl.cc,
	coreteam@netfilter.org,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Duc Anh Luu <luuducanh05051995@gmail.com>
X-Mailer: git-send-email 2.43.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list