From: "selvanair (Code Review)" Date: Sun, 23 Nov 2025 18:35:47 +0000 References: Reply-To: selva.nair@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/y8WS/5RiR0="; 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: plaisthos Cc: openvpn-devel --/y8WS/5RiR0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1396?usp=3Demail to review the following change. 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. Addresses OpenVPN/openvpn-private-issues#83 Reported-by: Marc Heuse Change-Id: Ie66a142751354e421d48b273784fc79bcb9f7208 Signed-off-by: Selva Nair --- M src/openvpnserv/interactive.c 1 file changed, 20 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/96/1396/1 diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 0712986..7a0a075 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -3398,12 +3398,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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie66a142751354e421d48b273784fc79bcb9f7208 Gerrit-Change-Number: 1396 Gerrit-PatchSet: 1 Gerrit-Owner: selvanair Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --/y8WS/5RiR0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

selvanair would like plaisthos to review this change.

V= iew Change

Harden interactive service pipe

- Ap= pend 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 p= ossibility of a rogue process racing to
open the pipe before CreateFile(= ) is called in the worker thread.

Addresses OpenVPN/openvpn-private-= issues#83

Reported-by: Marc Heuse <marc@...2953...>
Change-= Id: Ie66a142751354e421d48b273784fc79bcb9f7208
Signed-off-by: Selva Nair = <selva.nair@...277...>
---
M src/openvpnserv/interactive.c
1= file changed, 20 insertions(+), 3 deletions(-)

=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/96/1396/1
diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactiv=
e.c
index 0712986..7a0a075 100644
--- a/src= /openvpnserv/interactive.c
+++ b/src/openvpnserv/interactiv= e.c
@@ -3398,12 +3398,29 @@
goto o= ut;
}

+ UUID pipe_uuid;
+ RPC_STATUS rpc_stat =3D UuidCreate(&pipe_u= uid);
+ if (rpc_st= at !=3D RPC_S_OK)
+ = {
+ ReturnEr= ror(pipe, rpc_stat, L"UuidCreate", 1, &exit_event);+ goto out;
<= span style=3D"color: hsl(120, 100%, 40%);">+ }
+
+ 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),
<= span style=3D"color: hsl(0, 100%, 40%);">- L"\\\\.\\pipe\\= " _L(PACKAGE) L"%ls\\service_%lu", service_instance,<= br>- GetCurrentThread= Id());
+ = L"\\\\.\\pipe\\" _L(PACKAGE) L"%ls\\service_%lu_%ls", s= ervice_instance,
+ = GetCurrentThreadId(), pipe_uuid_str);
+ RpcStringFree(&pipe_uuid_str);+
ovpn_p= ipe =3D CreateNamedPipe(
ovpn_pipe_name, PIPE_ACCE= SS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE | FILE_FLAG_OVERLAPPED,- PIPE_TYPE_MESSAGE | PIP= E_READMODE_MESSAGE | PIPE_WAIT, 1, 128, 128, 0, NULL);
+ PIPE_TYPE_MESSAGE | PIPE_READMOD= E_MESSAGE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS, 1, 128, 128, 0, NULL);<= /span>
if (ovpn_pipe =3D=3D INVALID_HANDLE_VALUE)
<= span> {

ReturnLastError(pipe, L"CreateNam= edPipe");

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie66a142751354e421d48b273784= fc79bcb9f7208
Gerrit-Change-Number: 1396
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <selva.nair@...1354...= ..>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --/y8WS/5RiR0=--