From: "cron2 (Code Review)" Date: Mon, 24 Nov 2025 17:51:14 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., heiko@...515..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net, lstipakov@...277... Message-ID: <748e7300f0a55494d83621de2dad798e184ca7e7-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ErXf8Kch+PI="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Harden interactive service pipe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: selvanair , plaisthos , stipa Cc: d12fk , openvpn-devel --ErXf8Kch+PI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#3) to the change originally created by= selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/1396?usp=3Demail ) 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 Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1396 Message-Id: <20251124165311.14859-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 638.html Signed-off-by: Gert Doering --- M src/openvpnserv/interactive.c 1 file changed, 20 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/96/1396/3 diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 07ca7c9..afa8047 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -3397,12 +3397,29 @@ 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; + } swprintf(ovpn_pipe_name, _countof(ovpn_pipe_name), - L"\\\\.\\pipe\\" _L(PACKAGE) L"%ls\\service_%lu", service_ins= tance, - GetCurrentThreadId()); + L"\\\\.\\pipe\\" _L(PACKAGE) L"%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_REJEC= T_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/+/1396?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: Ie66a142751354e421d48b273784fc79bcb9f7208 Gerrit-Change-Number: 1396 Gerrit-PatchSet: 3 Gerrit-Owner: selvanair Gerrit-Reviewer: plaisthos Gerrit-Reviewer: stipa Gerrit-CC: d12fk Gerrit-CC: openvpn-devel --ErXf8Kch+PI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

Vi= ew Change

Harden interactive service pipe

- App= end 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 po= ssibility of a rogue process racing to
open the pipe before CreateFile()= is called in the worker thread.

Reported-by: Marc Heuse <marc@...1186...= .2953...>
Change-Id: Ie66a142751354e421d48b273784fc79bcb9f7208
Sig= ned-off-by: Selva Nair <selva.nair@...277...>
Gerrit URL: https://= gerrit.openvpn.net/c/openvpn/+/1396
Message-Id: <20251124165311.14859= -1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...465...= ists.sourceforge.net/msg34638.html
Signed-off-by: Gert Doering <gert@= ...1296...>
---
M src/openvpnserv/interactive.c
1 file changed,= 20 insertions(+), 3 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/96/1396/3
diff --=
git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c<=
br>index 07ca7c9..afa8047 100644
--- a/src/openvpnser= v/interactive.c
+++ b/src/openvpnserv/interactive.c<= br>@@ -3397,12 +3397,29 @@
goto out;<= br> }

+ UUID pipe_uuid;
+ RPC_STATUS rpc_stat =3D UuidCreate(&pipe_uuid);
+ if (rpc_stat !=3D RPC= _S_OK)
+ {<= br>+ ReturnError(pipe, r= pc_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 (r= pc_stat !=3D RPC_S_OK)
+ Ret= urnError(pipe, rpc_stat, L"UuidToString", 1, &exit_event);
+ goto out;
+ }
= swprintf(ovpn_pipe_name, _countof(ovpn_pipe_name),
- L"\\\\.\\pipe\\" _L(= PACKAGE) L"%ls\\service_%lu", service_instance,
- GetCurrentThreadId());
+ L"\\\= \.\\pipe\\" _L(PACKAGE) L"%ls\\service_%lu_%ls", service_ins= tance,
+ = GetCurrentThreadId(), pipe_uuid_str);
+ RpcStringFree(&pipe_uuid_str);
+
ovpn_pipe =3D Cr= eateNamedPipe(
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&quo= t;);

To view, visit change 1396. To unsubsc= ribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie66a142751354e421d48b273784= fc79bcb9f7208
Gerrit-Change-Number: 1396
Gerrit-PatchSet: 3
Gerrit-Owner: selvanair <selva.nair@...1354...= ..>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-Reviewer: stipa <lstipakov@...277...= >
Gerrit-CC: d12fk <heiko@...515...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --ErXf8Kch+PI=--