🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7091

[PATCH nf v2] netfilter: nf_conntrack_sip: fix OOB read in ct_sip_parse_transport()

#7091
From: Joas Antonio dos Santos
Date: Sat, 24 Oct 2026 17:03
54 lines
13294 bytes
ct_sip_parse_transport() compares the value of the "transport=" header
parameter against "TCP"/"UDP" with strncasecmp(..., 3), but it never
checks that the parsed value is at least 3 bytes long.

ct_sip_parse_param() returns matchlen = end - start, where end is the
next ';' or, when there is no ';', the end of the payload buffer
(limit = dptr + datalen).  If the "transport=" value is only 1 or 2
bytes long and runs exactly to the end of the payload (e.g. a REGISTER
request whose Contact header ends in ";transport=T" with no trailing
CRLF), matchlen is less than 3 while strncasecmp() still reads up to 3
bytes, reading 1-2 bytes past the end of the linearized skb data.

Add a matchlen check before the comparison, mirroring the
sdp_media_type() pattern a few lines below, so short values cannot reach
strncasecmp().

The bug was found by LLM-assisted manual review of the SIP helper's
parsers and confirmed with a userspace ASan harness built from the
verbatim parser functions, which reports a heap-buffer-overflow read of
size 2 in strncasecmp() called from ct_sip_parse_transport().

Fixes: ea45f12a2766d ("[NETFILTER]: nf_conntrack_sip: parse SIP headers properly")
Link: https://lore.kernel.org/netfilter-devel/20260815133104.50369-1-joasantonio108@gmail.com/
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Assisted-by: Claude:claude-opus-5-5
---
v2:
- Retarget to nf, rebase on current mainline (no code change).
- Say how the bug was found, add Link: to v1 and Assisted-by:.

v1 (2026-08-15) got no review comments on the list. An equivalent fix
was posted on 2026-10-22 by Duc Anh Luu (Cc'd):
https://lore.kernel.org/netfilter-devel/20261022172248.554687-1-luuducanh05051995@gmail.com/

 net/netfilter/nf_conntrack_sip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 64bc440b1..b05dc8858 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -701,9 +701,9 @@ 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", 3))
 			*proto = IPPROTO_TCP;
-		else if (!strncasecmp(dptr + matchoff, "UDP", strlen("UDP")))
+		else if (matchlen >= 3 && !strncasecmp(dptr + matchoff, "UDP", 3))
 			*proto = IPPROTO_UDP;
 		else
 			return 0;
Technical Details
Message-ID: <179286139765.93379.986858959213810476@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-351424-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-351424-linux-kernel-netdev=dewy.ru
From: joasantonio108@gmail.com (Joas Antonio dos Santos)
Newsgroups: linux.kernel.netdev
Subject: [PATCH nf v2] netfilter: nf_conntrack_sip: fix OOB read in
 ct_sip_parse_transport()
Date: Sat, 24 Oct 2026 14:03:17 -0300
Organization: Usenet Network
Message-ID: <179286139765.93379.986858959213810476@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="812273"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ec/38RRT20eKdp1o5Uvrx7mjEpc= sha256:nXjkQ0EaSLNplxj0MICwPj5fntRwGJ7D5zQYhrN2vaA=
	sha1:s4v8Gy9Ec2PZ2jVqqWL42vxD6Ok= sha256:d4L3A3qaMg2ovw42HOARbSi4DWW2JPyIXYBx6oeeXc8=
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 08CFF111687; Sat, 24 Oct 2026 20:04:32 +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 BtsqtfLErlSq;
	Sat, 24 Oct 2026 20:04:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351424-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 0B77B11164C; Sat, 24 Oct 2026 20:04:10 +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 53662312AE; Sat, 24 Oct 2026 17:03:41 +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=1792861420;
	b=bPxaAEEC3Omp/q6++urM5rKB8GNrogPUl/DmJZQRCQW0UwgQ3ugFu81p01dvtYgNn/z/
	 xw/crKyQfmA9OSnQ8Ay5pHSQo4Ag+KETZJaUJS5E5irvhda8xivw3aj0hGT2LDbtcB5xw
	 zsNZGOsT0BCdc0w1BU/bJw41H8YjeY1rUtiDvnr/gMfIwfzQEHms7SmkoZ/iq2v925m++
	 UCeN3JjlHZokxGzrA9AF7Wl+XCCX/m3UTeSO4MQQOhf08HeGQMILMa3qCKGdnl3a6cci9
	 AbvNBPHKRsuZu7oUUcvEfyGBIoCOYmnpShH1Zb5C3Z7iQP/LBkVBprHlrcPrj7XXHXw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792861420;
	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:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=jo8gmaFEhKj3JngpBjGb7fjIKG8buSADfQD1SD8Q+M4=;
	b=JliGlquuMnce53aYZDNamUH9a8l06Fs+SDgrtuwjCkL3lO/fbJbVNng55os/MKcGh6Kd
	 c7Zzwgnwnyoj3dixtGP3M+FzvXaglY/0VqWPPFDZY3iCy6mDe1k001rJwL2btm5V5Evlx
	 +ZijWYMwU7zJJZ+se8yB3slWyAu0cswCbl7cGNh3j49a9DLHp5gn6V0LGhCo+fYzSTpqc
	 q9EONRH1z6sjMYCHJxRuL/TAlk3W09XLWpZHAzEc3PKPHNH+xfBH0OSrD2moGlTLzUkI1
	 kwZFjSoNzP6UhcuT3Bq+MbBVMmwPT+4JPdSoe4er7ljXXbbjog4JNUAK1aPIni99eAg==
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=bLV5+rK3;
	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 A2713606A321;
	Sat, 24 Oct 2026 17:03:40 +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=bLV5+rK3
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.47
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792861404;
	b=1+hnNK7zaR+xaUQosf5Wp41CKgclYdUYaJ+CSkM3qHOZHtt+MFSRWT3OoZYKnuM4ZaQf
	 mXopR6lNS7qtvIE+4zChdJ2S4C6zqhwD0aPOewcXwOQyWL80pIsVDOsnRBm91DNMebHLt
	 o1F9T5KlWtM/2brQe9y1qQ7CEWbK5ZJdpuGzSSpSlIFYPLBLKGF1ryyUj7HSUvXqfW+RC
	 P9KqyWsAdwvPisxmg8AVyWxpjSD8MiqT5c0BFDC92Bw/7ArPbUfVFAvDBuxkuf7YKmpkY
	 +z3Gki4O79iXOHmGo1yT9lDh8UdkcnrnDQ4g6zmzz5Bo5rMQtvmHh/cgAdSauCywh1w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792861404;
	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:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=jo8gmaFEhKj3JngpBjGb7fjIKG8buSADfQD1SD8Q+M4=;
	b=ncKMqhJcsr5KEcCWzCJP7tRV1KWMxlljFmFQ+Qe3BVLlHDrCYImhB3OSj7ZNr9BvTEVS
	 /DPhEYDE7L6yLJBfQgKz42CTrXlDXp4XaOGPO8ijzmF3yxlvs6/lPl1JhlQJ9TFO5B4c3
	 esXWyXVYN+8yY9UH9pFpVA0BPY2rmwFl2SCbhKr7g+u38WSTi0tjhwkd+1aMS/pAyCCsq
	 kYWyNDP9bDbB63AxENjzgweUGHeHfFWuhcV0nQaj74dRqYgbKSTIFKZtC4TRFJ1bxCpC2
	 ISsf4G0ImyAQ2QJojW+Zdw9zG4hdUIzAgdEKRFj/fLx13QV0CRUqWgivHL7I+vRk7iw==
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=bLV5+rK3;
	arc=none smtp.remote-ip=209.85.222.47
X-Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47])
	(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 1E094606A31B
	for <netdev@vger.kernel.org>; Sat, 24 Oct 2026 17:03:23 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1E094606A31B
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-ua1-f47.google.com with SMTP id a1e0cc1a2514c-99059bdcdeaso511783241.2
        for <netdev@vger.kernel.org>; Sat, 24 Oct 2026 10:03:23 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792861403; x=1793466203; 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=jo8gmaFEhKj3JngpBjGb7fjIKG8buSADfQD1SD8Q+M4=;
        b=bLV5+rK3XK4YT3V2W+IonkQsuEwFvajZnI4HZcQTFPYUff3uvQA3FjTu9QJd59qLLu
         Qt6p8wJbbIQfurLx0x7pNWMLGcwEGCnmcpl97UkPjDLgiIYPQWXVGeifujDTKCxGnAFN
         2Bbh6ANBdrNtIovjYSp2qgEJs09rnSsCLX9Sm1iIrTHRmbX3apzk4SDxqBCgnA235r9L
         +1xyXQ9J24YbQryNaMTeU97ew2Z5eVwIY4vOCNnjqEoTgqhR+r2n0z019QyRGv/+I/cK
         SYj5cOsMPjf5QMBab3y27Aygy4xhW5Y/i4+wLPPLaJhrSZplIsGPp2hAyVd4Hdt3n4La
         RKxw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792861403; x=1793466203;
        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=jo8gmaFEhKj3JngpBjGb7fjIKG8buSADfQD1SD8Q+M4=;
        b=SmZX5L7+vYMV5g1J8KEImV1egZsGTgFjB3EpQ0YqxTk0KbQ64nJuGG54nn83UIz44h
         MhTNia3G7U8PvHbheFKNCNNmgHqAdqdaivgGDcS0vdKH7m9b1ZbHspbfuDsSLhFagiM8
         ugQJKPGyiSQ3XGQB62kg+yqElv0+CN8O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gYbgrDH4GChUhN00iJ+NmbBZ9gBEBOiE6vqZGY1X
X-Received: by 2002:a05:6102:c46:b0:7cc:c7aa:106 with SMTP id ada2fe7eead31-7ce5cd91867mr658536137.18.1792861402974;
        Sat, 24 Oct 2026 10:03:22 -0700 (PDT)
X-Received: from 1.0.0.127.in-addr.arpa ([2804:7f0:b101:277b:c08d:c9f9:7c08:79c4])
        by smtp.gmail.com with ESMTPSA id ada2fe7eead31-7ce5df73970sm2525746137.1.2026.10.24.10.03.19
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sat, 24 Oct 2026 10:03:22 -0700 (PDT)
X-Cc: Phil Sutter <phil@nwl.cc>, Duc Anh Luu <luuducanh05051995@gmail.com>,
 netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org
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