[Openvpn-devel,v1] socket: check the address family in addrlist_match()

Message ID 20261123112558.15625-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] socket: check the address family in addrlist_match() |

Commit Message

Gert Doering Nov. 23, 2026, 11:25 a.m. UTC
  From: Razvan Cojocaru <razvanc@mailbox.org>

addrlist_match() cast each remote list entry to the peer's address
family without checking ai_family. With a dual-stack remote list, an
IPv6 peer compared against an IPv4 entry read past the end of its
sockaddr_in, and 0.0.0.0 matched any IPv6 entry. Skip entries of the
other family, as addrlist_port_match() already does.

Change-Id: Ic3efcdb7bc4e60a81b9292adfe7f8e22b86e274a
(cherry picked from commit 756d140aca1958f71a701b4179e2e59fd3d86ead)
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2326
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to release/2.6.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2326
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>
  

Comments

Gert Doering Nov. 23, 2026, 5:43 p.m. UTC | #1
Direct backport of commit 756d140aca1, just taking the not-yet-rearranged
socket* source files into account.

This is a bug that could possibly lead to a heap memory over-read of
12 bytes, so it needed fixing.  We haven't been able to make anything
crash or otherwise "interesting", so no CVE.

BB tested this (and failed on some combinations of platform and TLS 
library, "because 2.6", and on others because "t_client.rc and 2.6"),
and GHA tested this as well.

Your patch has been applied to the release/2.6 branch.

commit 3256f39106ad04d744f8db6633e42b616891a242
Author: Razvan Cojocaru
Date:   Mon Nov 23 12:25:52 2026 +0100

     socket: check the address family in addrlist_match()

     Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2326
     Message-Id: <20261123112558.15625-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg41809.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
  

Patch

diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h
index 47083ad..80f09a3 100644
--- a/src/openvpn/socket.h
+++ b/src/openvpn/socket.h
@@ -736,6 +736,10 @@ 
     const struct addrinfo *curele;
     for (curele = addrlist; curele; curele = curele->ai_next)
     {
+        if (a1->addr.sa.sa_family != curele->ai_family)
+        {
+            continue;
+        }
         switch (a1->addr.sa.sa_family)
         {
             case AF_INET: