NetBSD Problem Report #60232

From www@netbsd.org  Wed May  6 16:52:33 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "R13" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E06031A9239
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  6 May 2026 16:52:32 +0000 (UTC)
Message-Id: <20260506165232.1CDB61A923A@mollari.NetBSD.org>
Date: Wed,  6 May 2026 16:52:32 +0000 (UTC)
From: cmeerw@cmeerw.org
Reply-To: cmeerw@cmeerw.org
To: gnats-bugs@NetBSD.org
Subject: kernel panic when adding a wireguard peer with too many allowed IP addresses
X-Send-Pr-Version: www-1.0
X-From4GNATS: "cmeerw@cmeerw.org via gnats" <gnats-admin@NetBSD.org>

>Number:         60232
>Category:       kern
>Synopsis:       kernel panic when adding a wireguard peer with too many allowed IP addresses
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 06 16:55:01 +0000 2026
>Closed-Date:    Sat Jun 27 16:31:18 +0000 2026
>Last-Modified:  Sat Jun 27 16:31:18 +0000 2026
>Originator:     Christof Meerwald
>Release:        11.0_RC3
>Organization:
>Environment:
NetBSD linveo.cmeerw.net 11.0_RC3 NetBSD 11.0_RC3 (GENERIC) #0: Sat Apr  4 06:08:56 UTC 2026  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
if_wg.c wg_handle_prop_peer happily adds all the IP addresses provided without checking that it's overflowing a fixed-size buffer (WG_ALLOWEDIPS 16)

>How-To-Repeat:
# wgconfig wg0 add peer test HdnnT5tllAxOKuil8l+KZeLPL8V12r/8UXlhvzeWzRU= --endpoint=127.0.0.1:12345 --allowed-ips=127.0.0.2/32,127.0.0.3/32,127.0.0.4/32,127.0.0.5/32,127.0.0.6/32,127.0.0.7/32,127.0.0.8/32,127.0.0.9/32,127.0.0.10/32,127.0.0.11/32,127.0.0.12/32,127.0.0.13/32,127.0.0.14/32,127.0.0.15/32,127.0.0.16/32,127.0.0.17/32,127.0.0.18/32,127.0.0.19/32,127.0.0.20/32,127.0.0.21/32,127.0.0.22/32,127.0.0.23/32

>Fix:
Check that we are not adding more than WG_ALLOWEDIPS IP addresses.

>Release-Note:

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60232 CVS commit: src/tests/net/if_wg
Date: Mon, 22 Jun 2026 22:27:17 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Mon Jun 22 22:27:17 UTC 2026

 Modified Files:
 	src/tests/net/if_wg: t_misc.sh

 Log Message:
 wg(4): Add a test case for too many allowed IP address ranges.

 PR kern/60232: kernel panic when adding a wireguard peer with too
 many allowed IP addresses


 To generate a diff of this commit:
 cvs rdiff -u -r1.16 -r1.17 src/tests/net/if_wg/t_misc.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60232 CVS commit: src
Date: Tue, 23 Jun 2026 04:12:20 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Jun 23 04:12:20 UTC 2026

 Modified Files:
 	src/sys/net: if_wg.c
 	src/tests/net/if_wg: t_misc.sh

 Log Message:
 wg(4): Gracefully refuse excess allowed IP address ranges.

 PR kern/60232: kernel panic when adding a wireguard peer with too
 many allowed IP addresses


 To generate a diff of this commit:
 cvs rdiff -u -r1.136 -r1.137 src/sys/net/if_wg.c
 cvs rdiff -u -r1.17 -r1.18 src/tests/net/if_wg/t_misc.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Tue, 23 Jun 2026 04:17:07 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-11, pullup-10


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Fri, 26 Jun 2026 01:14:43 +0000
State-Changed-Why:
pullup-10 #1277 https://releng.netbsd.org/cgi-bin/req-10.cgi?show=1277
pullup-11 #329 https://releng.netbsd.org/cgi-bin/req-11.cgi?show=329


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60232 CVS commit: [netbsd-11] src
Date: Sat, 27 Jun 2026 14:54:26 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Jun 27 14:54:25 UTC 2026

 Modified Files:
 	src/sys/net [netbsd-11]: if_wg.c
 	src/tests/net/if_wg [netbsd-11]: common.sh t_basic.sh t_misc.sh

 Log Message:
 Pull up following revision(s) (requested by riastradh in ticket #329):

 	tests/net/if_wg/t_misc.sh: revision 1.17
 	tests/net/if_wg/t_misc.sh: revision 1.18
 	sys/net/if_wg.c: revision 1.136
 	tests/net/if_wg/t_basic.sh: revision 1.7
 	sys/net/if_wg.c: revision 1.137
 	tests/net/if_wg/t_basic.sh: revision 1.8
 	sys/net/if_wg.c: revision 1.138
 	tests/net/if_wg/t_basic.sh: revision 1.9
 	tests/net/if_wg/common.sh: revision 1.2

 wg(4): Add test case for bad peer public keys.

 wg(4) should not crash on an assertion if they are used -- it should
 just gracefully accept them, with degraded security, since a peer
 that maliciously provides an invalid public key is no worse than a
 peer that voluntarily exposes all its plaintext anyway.
 PR kern/60106: wg(4) should properly handle invalid or insecure
 ephemeral Curve25119 public keys

 wg(4): Add test case for bad ephemeral handshake public keys.

 wg(4) should not crash on an assertion if they appear on the network;
 it should just gracefully drop them as forgeries, if a MITM attempted
 to send them without knowledge of a peer's public key, or accept
 them, if a peer legitimately sent them, since that peer could just as
 well simply forward the plaintext of the session on to the NSA.
 PR kern/60106: wg(4) should properly handle invalid or insecure
 ephemeral Curve25119 public keys

 wg(4): Add a test case for too many allowed IP address ranges.
 PR kern/60232: kernel panic when adding a wireguard peer with too
 many allowed IP addresses

 wg(4): Drop KASSERT on result of crypto_scalarmult.
 The result of this check is not relevant to security of the protocol,
 either for static peer identity keys or for ephemeral handshake keys.

 See comments for details.

 We can't simply write
         (void)crypto_scalarmult(...);
 because the function was tagged with warn_unused_result.  And
 apparently libsodium may leave the output uninitialized if the check
 fails.  So just yield zero instead of stack garbage / UB -- stack
 garbage is probably actually fine since it is immediately hashed into
 something that won't match anything so downstream logic will just drop
 it, but UB might invite nefarious compilers to cause trouble.
 PR security/60106: wg(4) should properly handle invalid or insecure
 ephemeral Curve25119 public keys

 wg(4): Gracefully refuse excess allowed IP address ranges.
 PR kern/60232: kernel panic when adding a wireguard peer with too
 many allowed IP addresses

 wg(4): Don't leak a prop_dictionary_t on every ioctl!
 PR kern/60349: experimental wg(4) leaks memory on ioctl


 To generate a diff of this commit:
 cvs rdiff -u -r1.135 -r1.135.2.1 src/sys/net/if_wg.c
 cvs rdiff -u -r1.1 -r1.1.10.1 src/tests/net/if_wg/common.sh
 cvs rdiff -u -r1.6 -r1.6.2.1 src/tests/net/if_wg/t_basic.sh
 cvs rdiff -u -r1.16 -r1.16.2.1 src/tests/net/if_wg/t_misc.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60232 CVS commit: [netbsd-10] src
Date: Sat, 27 Jun 2026 14:56:18 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Jun 27 14:56:18 UTC 2026

 Modified Files:
 	src/sys/net [netbsd-10]: if_wg.c
 	src/tests/net/if_wg [netbsd-10]: common.sh t_basic.sh t_misc.sh

 Log Message:
 Pull up following revision(s) (requested by riastradh in ticket #1277):

 	tests/net/if_wg/t_misc.sh: revision 1.17
 	tests/net/if_wg/t_misc.sh: revision 1.18
 	sys/net/if_wg.c: revision 1.136
 	tests/net/if_wg/t_basic.sh: revision 1.7
 	sys/net/if_wg.c: revision 1.137
 	tests/net/if_wg/t_basic.sh: revision 1.8
 	sys/net/if_wg.c: revision 1.138
 	tests/net/if_wg/t_basic.sh: revision 1.9
 	tests/net/if_wg/common.sh: revision 1.2

 wg(4): Add test case for bad peer public keys.

 wg(4) should not crash on an assertion if they are used -- it should
 just gracefully accept them, with degraded security, since a peer
 that maliciously provides an invalid public key is no worse than a
 peer that voluntarily exposes all its plaintext anyway.
 PR kern/60106: wg(4) should properly handle invalid or insecure
 ephemeral Curve25119 public keys

 wg(4): Add test case for bad ephemeral handshake public keys.

 wg(4) should not crash on an assertion if they appear on the network;
 it should just gracefully drop them as forgeries, if a MITM attempted
 to send them without knowledge of a peer's public key, or accept
 them, if a peer legitimately sent them, since that peer could just as
 well simply forward the plaintext of the session on to the NSA.
 PR kern/60106: wg(4) should properly handle invalid or insecure
 ephemeral Curve25119 public keys

 wg(4): Add a test case for too many allowed IP address ranges.
 PR kern/60232: kernel panic when adding a wireguard peer with too
 many allowed IP addresses

 wg(4): Drop KASSERT on result of crypto_scalarmult.
 The result of this check is not relevant to security of the protocol,
 either for static peer identity keys or for ephemeral handshake keys.

 See comments for details.

 We can't simply write
         (void)crypto_scalarmult(...);
 because the function was tagged with warn_unused_result.  And
 apparently libsodium may leave the output uninitialized if the check
 fails.  So just yield zero instead of stack garbage / UB -- stack
 garbage is probably actually fine since it is immediately hashed into
 something that won't match anything so downstream logic will just drop
 it, but UB might invite nefarious compilers to cause trouble.
 PR security/60106: wg(4) should properly handle invalid or insecure
 ephemeral Curve25119 public keys

 wg(4): Gracefully refuse excess allowed IP address ranges.
 PR kern/60232: kernel panic when adding a wireguard peer with too
 many allowed IP addresses

 wg(4): Don't leak a prop_dictionary_t on every ioctl!
 PR kern/60349: experimental wg(4) leaks memory on ioctl


 To generate a diff of this commit:
 cvs rdiff -u -r1.71.2.5 -r1.71.2.6 src/sys/net/if_wg.c
 cvs rdiff -u -r1.1 -r1.1.6.1 src/tests/net/if_wg/common.sh
 cvs rdiff -u -r1.4.6.1 -r1.4.6.2 src/tests/net/if_wg/t_basic.sh
 cvs rdiff -u -r1.12.2.1 -r1.12.2.2 src/tests/net/if_wg/t_misc.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 27 Jun 2026 16:31:18 +0000
State-Changed-Why:
fixed in HEAD, pulled up to 11 and 10, inapplicable <10


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.