From: "ordex (Code Review)" Date: Mon, 27 Oct 2025 13:55:19 +0000 References: Reply-To: antonio@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <2c1b617e73c8f8777050bce9b1ab4fbb9617fc1c-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="zl/XcvBJWD4="; 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 --zl/XcvBJWD4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1314?usp=3Demail to review the following change. 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: ZeroPath (https://zeropath.com/) Change-Id: I54845bf4dd17d06cfc3b402f188795f74f4b1d3e Signed-off-by: Antonio Quartulli --- M src/openvpn/networking_sitnl.c 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/14/1314/1 diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index b3adb16..a959fa8 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -181,6 +181,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__); -- 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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I54845bf4dd17d06cfc3b402f188795f74f4b1d3e Gerrit-Change-Number: 1314 Gerrit-PatchSet: 1 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --zl/XcvBJWD4= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

ordex would like plaisthos and flichtenheld to review t= his change.

V= iew Change

sitnl: set FD_CLOEXEC on socket to prevent =
abuse

Since OpenVPN spawns various child processes, it is important<= br>that sockets are closed after calling exec.

The sitnl socket didn= 't have the right flag set, resulting
in it surviving in, for exampl= e, connect/disconnect scripts
and giving the latter a chance to abuse th= e socket.

Ensure this doesn't happen by setting FD_CLOEXEC onthis socket right after creation.

Reported-by: ZeroPath (https://ze= ropath.com/)
Change-Id: I54845bf4dd17d06cfc3b402f188795f74f4b1d3e
Sig= ned-off-by: Antonio Quartulli <antonio@...2726...>
---
M src/op= envpn/networking_sitnl.c
1 file changed, 3 insertions(+), 0 deletions(-)=

git pull ssh://gerrit.openvpn.net:29418/openvpn=
 refs/changes/14/1314/1
diff --git a/src/openvpn/networking_sitnl.c=
 b/src/openvpn/networking_sitnl.c
index b3adb16..a959fa8 10= 0644
--- a/src/openvpn/networking_sitnl.c
+= ++ b/src/openvpn/networking_sitnl.c
@@ -181,6 +181,9 @@
return fd;
}

+ /* set close on e= xec 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&quo= t;, __func__);

To view, visit change 1314= . To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I54845bf4dd17d06cfc3b402f188= 795f74f4b1d3e
Gerrit-Change-Number: 1314
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <antonio@...2726...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --zl/XcvBJWD4=--