From: "cron2 (Code Review)"
Date: Tue, 28 Oct 2025 16:35:39 +0000
In-Reply-To:
References:
Reply-To: gert@...1296..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net, frank@...2641...,
antonio@...2726...
Message-ID: <2f671f9d992948f379a09cdbbf8338573724f1ee-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="8n6sBPLdMZ8="; charset=UTF-8
Subject: [Openvpn-devel] [XS] Change in openvpn[master]: sitnl: set
FD_CLOEXEC on socket to prevent abuse
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: plaisthos , flichtenheld
Cc: openvpn-devel
--8n6sBPLdMZ8=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 has uploaded a new patch set (#5) to the change originally created by=
ordex. ( http://gerrit.openvpn.net/c/openvpn/+/1314?usp=3Demail )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: sitnl: set FD_CLOEXEC on socket to prevent abuse
......................................................................
sitnl: set FD_CLOEXEC on socket to prevent abuse
Since OpenVPN spawns various child processes, it is important
that sockets are closed after calling exec.
The sitnl socket didn't have the right flag set, resulting
in it surviving in, for example, connect/disconnect scripts
and giving the latter a chance to abuse the socket.
Ensure this doesn't happen by setting FD_CLOEXEC on
this socket right after creation.
Reported-by: Joshua Rogers
Found-by: ZeroPath (https://zeropath.com/)
Change-Id: I54845bf4dd17d06cfc3b402f188795f74f4b1d3e
Signed-off-by: Antonio Quartulli
Acked-by: Gert Doering
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1314
Message-Id: <20251028162843.18189-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33=
952.html
Signed-off-by: Gert Doering
---
M CMakeLists.txt
M src/openvpn/networking_sitnl.c
M tests/unit_tests/openvpn/Makefile.am
3 files changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/14/1314/5
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5954a6e..bf754f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -923,6 +923,7 @@
src/openvpn/crypto_openssl.c
src/openvpn/crypto.c
src/openvpn/crypto_epoch.c
+ src/openvpn/fdmisc.c
src/openvpn/otime.c
src/openvpn/packet_id.c
)
diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c
index b3adb16..3e20b70 100644
--- a/src/openvpn/networking_sitnl.c
+++ b/src/openvpn/networking_sitnl.c
@@ -27,6 +27,7 @@
#include "dco.h"
#include "errlevel.h"
+#include "fdmisc.h"
#include "buffer.h"
#include "misc.h"
#include "networking.h"
@@ -181,6 +182,9 @@
return fd;
}
+ /* set close on exec to avoid child processes access the socket */
+ set_cloexec(fd);
+
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)) < 0)
{
msg(M_WARN | M_ERRNO, "%s: SO_SNDBUF", __func__);
diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvp=
n/Makefile.am
index 997703a..0f13172 100644
--- a/tests/unit_tests/openvpn/Makefile.am
+++ b/tests/unit_tests/openvpn/Makefile.am
@@ -196,6 +196,7 @@
$(top_srcdir)/src/openvpn/crypto_epoch.c \
$(top_srcdir)/src/openvpn/crypto_mbedtls.c \
$(top_srcdir)/src/openvpn/crypto_openssl.c \
+ $(top_srcdir)/src/openvpn/fdmisc.c \
$(top_srcdir)/src/openvpn/otime.c \
$(top_srcdir)/src/openvpn/packet_id.c \
$(top_srcdir)/src/openvpn/platform.c
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1314?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings?usp=3Demail
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I54845bf4dd17d06cfc3b402f188795f74f4b1d3e
Gerrit-Change-Number: 1314
Gerrit-PatchSet: 5
Gerrit-Owner: ordex
Gerrit-Reviewer: cron2
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
--8n6sBPLdMZ8=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 upl=
oaded patch set #5 to the change originally created by ordex.
<=
p>View C=
hange
The following approvals got outdated and were removed:
Code-Review+2 by cron2
sitnl: set FD_CLOEXEC on socket to =
prevent abuse
Since OpenVPN spawns various child processes, it is im=
portant
that sockets are closed after calling exec.
The sitnl soc=
ket didn't have the right flag set, resulting
in it surviving in, fo=
r example, connect/disconnect scripts
and giving the latter a chance to =
abuse the socket.
Ensure this doesn't happen by setting FD_CLOEX=
EC on
this socket right after creation.
Reported-by: Joshua Roger=
s <contact@...2949...>
Found-by: ZeroPath (https://zeropath.com/)<=
br>Change-Id: I54845bf4dd17d06cfc3b402f188795f74f4b1d3e
Signed-off-by: A=
ntonio Quartulli <antonio@...2726...>
Acked-by: Gert Doering <g=
ert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/13=
14
Message-Id: <20251028162843.18189-1-gert@...1296...>
URL: ht=
tps://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33952.htm=
l
Signed-off-by: Gert Doering <gert@...1296...>
---
M CMakeL=
ists.txt
M src/openvpn/networking_sitnl.c
M tests/unit_tests/openvpn/=
Makefile.am
3 files changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/change=
s/14/1314/5
diff --git a/CMakeLists.txt b/CMakeLists.txt
=
index 5954a6e..bf754f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -923,6 +923,7 @@
src/openvpn/crypto_openssl.c
=
src/openvpn/crypto.c
src/openvpn/crypt=
o_epoch.c
+ =
src/openvpn/fdmisc.c
src/openvpn/otime.c
src/openvpn/packet_id.c
=
)
diff --git a/src/openvpn/networking_sitnl.c b/src/ope=
nvpn/networking_sitnl.c
index b3adb16..3e20b70 100644
--- a/src/openvpn/networking_sitnl.c
+++ b/src/o=
penvpn/networking_sitnl.c
@@ -27,6 +27,7 @@
#include "dco.h"
#include &q=
uot;errlevel.h"
=
+#include "fdmisc.h"
#include "buffer.h&quo=
t;
#include "misc.h"
#include &=
quot;networking.h"
@@ -181,6 +182,9 @@
return fd;
}
+ /* set close on exec to avoid=
child processes access the socket */
+ set_cloexec(fd);
+
if (setsockopt(fd, SOL_SOCKET, SO_=
SNDBUF, &sndbuf, sizeof(sndbuf)) < 0)
{<=
br> msg(M_WARN | M_ERRNO, "%s: SO_SNDBUF", __func__=
);
diff --git a/tests/unit_tests/openvpn/Makefile.am b/test=
s/unit_tests/openvpn/Makefile.am
index 997703a..0f13172 100=
644
--- a/tests/unit_tests/openvpn/Makefile.am
+++ b/tests/unit_tests/openvpn/Makefile.am
@@ -196,6 +1=
96,7 @@
$(top_srcdir)/src/openvpn/crypto_epoch.c \=
$(top_srcdir)/src/openvpn/crypto_mbedtls.c \
=
$(top_srcdir)/src/openvpn/crypto_openssl.c \
+ $(top_srcdir)/src/openvpn/fdmisc.c \
$(top_srcdir)/src/openvpn/otime.c \
$(top_srcdir)/s=
rc/openvpn/packet_id.c \
$(top_srcdir)/src/openvpn/platfo=
rm.c
To view, visit change 1314. To unsubsc=
ribe, or for help writing mail filters, visit settings.
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I54845bf4dd17d06cfc3b402f188=
795f74f4b1d3e
Gerrit-Change-Number: 1314
Gerrit-PatchSet: 5
Gerrit-Owner: ordex <antonio@...2726...>=
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
=
--8n6sBPLdMZ8=--