| Message ID | 20251124183839.24803-1-gert@greenie.muc.de |
|---|---|
| State | New |
| Headers | show |
| Series | [Openvpn-devel,v1] Harden interactive service pipe | expand |
Thanks for the 2.6 backport.
This is basically identical to commit 05d0808ee65 in master, except
that the 2.6 code is dealing with text strings differently (TEXT() vs.
L(), and I felt that this is beyond what I should touch on cherrypicking
bugfixes).
Compile-tested by BB and on MinGW/Ubuntu 24.04.
Your patch has been applied to the release/2.6 branch.
commit a8fb9f6443cd4ce3b76b1a31738ede2db5bc45ea (release/2.6)
Author: Selva Nair
Date: Mon Nov 24 19:38:34 2025 +0100
Harden interactive service pipe
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1401
Message-Id: <20251124183839.24803-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34654.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
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 = UuidCreate(&pipe_uuid); + if (rpc_stat != RPC_S_OK) + { + ReturnError(pipe, rpc_stat, L"UuidCreate", 1, &exit_event); + goto out; + } + + RPC_WSTR pipe_uuid_str = NULL; + rpc_stat = UuidToStringW(&pipe_uuid, &pipe_uuid_str); + if (rpc_stat != 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"), service_instance, GetCurrentThreadId()); + TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service_%lu_%ls"), service_instance, + GetCurrentThreadId(), pipe_uuid_str); + RpcStringFree(&pipe_uuid_str); + ovpn_pipe = 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 == INVALID_HANDLE_VALUE) { ReturnLastError(pipe, L"CreateNamedPipe");