From: "cron2 (Code Review)" Date: Tue, 25 Nov 2025 08:58:41 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net, lstipakov@...277... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="3MRLklfVJeQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[release/2.6]: Harden interactive service pipe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: selvanair , plaisthos , stipa Cc: openvpn-devel --3MRLklfVJeQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/1401?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Harden interactive service pipe ...................................................................... Harden interactive service pipe - Append a version 4 uuid to ovpn_pipe_name to make it less predictable - Do not allow remote access to the pipe This greatly reduces the possibility of a rogue process racing to open the pipe before CreateFile() is called in the worker thread. Reported-by: Marc Heuse Change-Id: Ie66a142751354e421d48b273784fc79bcb9f7208 Signed-off-by: Selva Nair Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1401 Message-Id: <20251124183839.24803-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 654.html Signed-off-by: Gert Doering --- M src/openvpnserv/interactive.c 1 file changed, 21 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/1401/2 diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index c717e99..2dc865e 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -1955,11 +1955,30 @@ goto out; } + UUID pipe_uuid; + RPC_STATUS rpc_stat =3D UuidCreate(&pipe_uuid); + if (rpc_stat !=3D RPC_S_OK) + { + ReturnError(pipe, rpc_stat, L"UuidCreate", 1, &exit_event); + goto out; + } + + RPC_WSTR pipe_uuid_str =3D NULL; + rpc_stat =3D UuidToStringW(&pipe_uuid, &pipe_uuid_str); + if (rpc_stat !=3D RPC_S_OK) + { + ReturnError(pipe, rpc_stat, L"UuidToString", 1, &exit_event); + goto out; + } openvpn_swprintf(ovpn_pipe_name, _countof(ovpn_pipe_name), - TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service_%lu"), ser= vice_instance, GetCurrentThreadId()); + TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service_%lu_%ls"),= service_instance, + GetCurrentThreadId(), pipe_uuid_str); + RpcStringFree(&pipe_uuid_str); + ovpn_pipe =3D CreateNamedPipe(ovpn_pipe_name, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_= INSTANCE | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE = | PIPE_WAIT, 1, 128, 128, 0, NULL); + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE = | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS, + 1, 128, 128, 0, NULL); if (ovpn_pipe =3D=3D INVALID_HANDLE_VALUE) { ReturnLastError(pipe, L"CreateNamedPipe"); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1401?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: release/2.6 Gerrit-Change-Id: Ie66a142751354e421d48b273784fc79bcb9f7208 Gerrit-Change-Number: 1401 Gerrit-PatchSet: 2 Gerrit-Owner: selvanair Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-Reviewer: stipa Gerrit-CC: openvpn-devel --3MRLklfVJeQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #2 to the change originally created by selvanair.<= /p>

Vi= ew Change

The following approvals got outdated and were removed: Code-Review+2 by cron2

Harden interactive service pipe
=
- Append a version 4 uuid to ovpn_pipe_name to make it less
predic= table
- Do not allow remote access to the pipe

This greatly reduc= es the possibility of a rogue process racing to
open the pipe before Cre= ateFile() is called in the worker thread.

Reported-by: Marc Heuse &l= t;marc@...2953...>
Change-Id: Ie66a142751354e421d48b273784fc79bcb9f72= 08
Signed-off-by: Selva Nair <selva.nair@...277...>
Acked-by: G= ert Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.n= et/c/openvpn/+/1401
Message-Id: <20251124183839.24803-1-gert@...1725...= ..>
URL: https://www.mail-archive.com/openvpn-devel@...282...= .net/msg34654.html
Signed-off-by: Gert Doering <gert@...1296...>---
M src/openvpnserv/interactive.c
1 file changed, 21 insertions(+= ), 2 deletions(-)

git pull ssh://gerrit.openvpn.=
net:29418/openvpn refs/changes/01/1401/2
diff --git a/src/openvpnse=
rv/interactive.c b/src/openvpnserv/interactive.c
index c717= e99..2dc865e 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -1955,1= 1 +1955,30 @@
goto out;
}

+ U= UID pipe_uuid;
+ R= PC_STATUS rpc_stat =3D UuidCreate(&pipe_uuid);
+ if (rpc_stat !=3D RPC_S_OK)
+ {

+ ReturnError(pipe, rpc_stat, L"Uui= dCreate", 1, &exit_event);
+ goto out;
+ }
+=
+ RPC_WSTR pipe_u= uid_str =3D NULL;
+ = rpc_stat =3D UuidToStringW(&pipe_uuid, &pipe_uuid_str);+ if (rpc_stat !=3D RPC_S_O= K)
+ {
<= span style=3D"color: hsl(120, 100%, 40%);">+ ReturnError(pipe, rpc_s= tat, L"UuidToString", 1, &exit_event);

+ goto out;
+ }
openvpn_swprin= tf(ovpn_pipe_name, _countof(ovpn_pipe_name),
- TEXT("\\\\.\\pipe\\" = PACKAGE "%ls\\service_%lu"), service_instance, GetCurrentThreadId= ());
+ = TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service_%lu_%ls&quo= t;), service_instance,
+ RpcStringFree(&pipe_uuid_= str);
+
ovpn_pipe =3D CreateNamedPipe(ovpn_pipe_name,
= PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTA= NCE | FILE_FLAG_OVERLAPPED,
- PIPE_TYPE_MESSAGE | PIPE_READMODE_MES= SAGE | PIPE_WAIT, 1, 128, 128, 0, NULL);
+ PIPE_TYPE_MESSAGE | PI= PE_READMODE_MESSAGE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS,
+ 1= , 128, 128, 0, NULL);
if (ovpn_pipe =3D=3D INVALID_HAN= DLE_VALUE)
{
ReturnLastError(= pipe, L"CreateNamedPipe");

To= view, visit change 1401. To unsubscribe, or for help writing mail filters, vis= it settings.=

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Ie66a142751354e421d48b273784= fc79bcb9f7208
Gerrit-Change-Number: 1401
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <selva.nair@...1354...= ..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-Reviewer: stipa <lstipakov@...277...= >
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --3MRLklfVJeQ=--