From: Simon Rozman Date: Mon, 16 Dec 2019 22:18:00 +0000 Message-ID: <162696E1-8F58-4B9A-A591-2622E3ADE746@...2293...> References: <20191213191634.250-1-lstipakov@...277...> <20191213191901.300-1-lstipakov@...277...> In-Reply-To: Content-Language: en-US Content-Type: multipart/signed; boundary="Apple-Mail=_84593F5D-BBAF-445D-9EB6-C9074471BE41"; protocol="application/pkcs7-signature"; micalg=sha-256 MIME-Version: 1.0 Subject: Re: [Openvpn-devel] [PATCH v6 4/7] wintun: ring buffers based I/O List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Selva Nair Cc: Lev Stipakov , Lev Stipakov , openvpn-devel --Apple-Mail=_84593F5D-BBAF-445D-9EB6-C9074471BE41 Content-Type: multipart/alternative; boundary="Apple-Mail=_3BAE6E5C-7A63-428D-9F65-243AB25CE74C" --Apple-Mail=_3BAE6E5C-7A63-428D-9F65-243AB25CE74C Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, >>> TLDR: >>> (i) stealing SYSTEM access from winlogon.exe is not a good thing to do >>=20 >>=20 >> This doesn't happen for the majority of use cases - only when iservice i= s not used. We also >> elevate only for the single DeviceIOControl call. >=20 > I understand. But stealing access token from winlogon.exe is a hack and n= ot > something I would expect to see in a trustworthy executable. Diagnostic > and forensic tools may be justified in doing such things. Wintun has a hardcoded check to allow ring registration from the SYSTEM use= r only. To be honest: I am using a Windows 10 VPC in test mode with a modified Wint= un driver installed that also allows ring registration for the members of A= dministrators group. This allows me to quickly test ideas while reviewing/u= pgrading Lev's work. I can run Visual Studio to compile openvpn.exe on my c= omputer as an unprivileged user. Then have an elevated Remote Debugger runn= ing on the VPC and Visual Studio to remotely run openvpn.exe with debugger = attached with a single F5 click. Having to use OpenVPN GUI and iservice, or running openvpn.exe as service w= ould require a lot more clicks to replace the binary, attach debugger etc. As far as I am concerned, this elevation hack may be removed from the OpenV= PN source code in the final release. However, mind that this would prevent = people from running openvpn.exe+Wintun from the command line. >>> +bool >>>=20 >>>> +impersonate_as_system() >>>> +{ >>>=20 >>> This is implemented by stealing the access token from >>> winlogon.exe. I don't think such tricks belong to OpenVPN. >>> It may also trip some anti-virus software. >>>=20 >>> That said, probably there are no "legitimate" ways of getting >>> LOCAL SYSTEM rights on Windows without running a service. >>>=20 >>> Why does wintun require SYSTEM for using it? If there is a >>> good reason for that, we should not let every admin >>> user bypass it. >>=20 >>=20 >> I'll defer it to Simon. Unfortunately, I don't do security decisions in Wintun. Wintun was originally designed for WireGuard. WireGuard is architectured to= run all its tunnels as Windows services running as the SYSTEM user. Wintun= 's security is as tight as possible so the WireGuard can barely use it. I k= now a guy who is tempted to introduce a userspace binary code signature che= ck to the Wintun. :) Given the relative ease to get SYSTEM token just by being an elevated proce= ss =E2=80=94 mind there's also a hack to get from non-elevated to elevated = completely bypassing the UAC prompt as long as you are a member of Administ= rators =E2=80=94 this SYSTEM restriction really doesn't provide considerabl= e additional security compared to being a member of Administrators group. >>> Those who really need to test OpenVPN with wintun from >>> command prompt can use diagnostic tools available to get >>> a cmd prompt as system (e.g., psexec). That also makes >>> it explicit that SYSTEM privilege is required. >>>=20 >>> In the longer run, we could provide a script to launch >>> openvpn.exe using the interactive service. Modifying the >>> automatic service to use interactive service for launching >>> looks easy to do as well. Then, all privileged operations could >>> be removed from openvpn core. >>=20 >>=20 >> I think it is good not to break user experience and allow run openvpn as >> an administrator without iservice using wintun at the expense on elevati= on >> to system for single API call. >=20 > I have already said what I think of it. As an admin I wouldn't like to see > users running processes that elevate to SYSTEM like this. Selva, Windows is full of such hacks internally. :( This is no excuse for u= s doing the same of course. Just saying Windows is far from ideal world. I am running OpenVPN on Windows using NSSM wrapper for years. I had a brief= discussion on the Hackathon with Samuli about integrating SCM support dire= ctly into openvpn.exe (imagine --daemon for Windows): sc create OpenVPN$MyTunnel binpath=3D "C:\Program Files\OpenVPN\bin\openvpn= " --daemon --config "C:\Program Files\OpenVPN\config\MyTunnel.ovpn" --log "= C:\Program Files\OpenVPN\log\MyTunnel.log" start=3D auto depend=3D dhcp sc start OpenVPN$MyTunnel This would install openvpn.exe as a Windows service and run it as the SYSTE= M user =E2=80=94 no need for iservice, no need for SYSTEM token hack. Other= than me, perhaps it could cover at least some of the users now running ope= nvpn.exe directly. Regards, Simon= --Apple-Mail=_3BAE6E5C-7A63-428D-9F65-243AB25CE74C Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi,

<= div class=3D"">
TLDR:
(i) stealing SYSTEM access from winlogon.exe is not a = good thing to do


T= his doesn't happen for the majority of use cases - only when iservice is no= t used. We also
elevate only for the single DeviceIOControl c= all.

= I understand. But stealing access token from winlogon.exe is a h= ack and not
som= ething I would expect to see in a trustworthy executable. Diagnostic=
and forensic tools ma= y be justified in doing such things.

Wintun has a h= ardcoded check to allow ring registration from the SYSTEM user only.
<= div>
To be honest: I am using a Windows 10 VPC in = test mode with a modified Wintun driver installed that also allows ring reg= istration for the members of Administrators group. This allows me to quickl= y test ideas while reviewing/upgrading Lev's work. I can run Visual St= udio to compile openvpn.exe on my computer as an unprivileged user. = Then have an elevated Remote Debugger running on the VPC and Visual Studio = to remotely run openvpn.exe with debugger attached with a = single F5 click.

Having to use OpenVPN = GUI and iservice, or running openvpn.exe as service would require a lot mor= e clicks to replace the binary, attach debugger etc.

As far as I am concerned, this elevation hack may be removed = from the OpenVPN source code in the final release. However, mind tha= t this would prevent people from running openvpn.exe+Wintun fro= m the command line.

+bool

+impersonate_as_system()
+{

This is implemented by stealing the access to= ken from
winlogon.exe. I don't think such tricks belong to Op= enVPN.
It may also trip some anti-virus software.

That said, probably there are no "legitimate" ways of get= ting
LOCAL SYSTEM rights on Windows without running a service= .

Why does wintun require SYSTEM for using it?= If there is a
good reason for that, we should not let every = admin
user bypass it.


I'll defer it to Simon.
=

Unfortunately, I don't do secur= ity decisions in Wintun.

= Wintun was originally designed for WireGuard. WireGuard is architectured to= run all its tunnels as Windows services running as the SYSTEM user. Wintun= 's security is as tight as possible so the WireGuard can barely use it. I k= now a guy who is tempted to introduce a userspace binary c= ode signature check to the Wintun. :)

G= iven the relative ease to get SYSTEM token just by being an elevated proces= s =E2=80=94 mind there's also a hack to get from n= on-elevated to elevated completely bypassing the UAC prompt a= s long as you are a member of Administrators =E2=80=94 thi= s SYSTEM restriction really doesn't provide considerable additional securit= y compared to being a member of Administrators group.

Those who really need to= test OpenVPN with wintun from
command prompt can use diagnos= tic tools available to get
a cmd prompt as system (e.g., psex= ec). That also  makes
it explicit that SYSTEM privilege = is required.

In the longer run, we could provi= de a script to launch
openvpn.exe using the interactive servi= ce. Modifying the
automatic service to use interactive servic= e for launching
looks easy to do as well. Then, all privilege= d operations could
be removed from openvpn core.


I think it is good not to brea= k user experience and allow run openvpn as
an administrator w= ithout iservice using wintun at the expense on elevation
to s= ystem for single API call.

I have already said what I think of it. As= an admin I wouldn't like to see
users running processes that elevate to SYSTEM like this.=
<= br class=3D"">
Selva, Windows is full of such hacks internally. := ( This is no excuse for us doing the same of course. Just saying Windows is= far from ideal world.

I am running Ope= nVPN on Windows using NSSM wrapper for years. I had a brief discussion on t= he Hackathon with Samuli about integrating SCM support directly into openvp= n.exe (imagine --daemon for Windows):

s= c create OpenVPN$MyTunnel binpath=3D "C:\Program Files\OpenVPN\bin\openvpn"= --daemon --config "C:\Program Files\OpenVPN\config\MyTunnel.ovpn" -= -log "C:\Program Files\OpenVPN\log\MyTunnel.log" start=3D = auto depend=3D dhcp
sc start OpenVPN$MyTunnel

This would install openvpn.exe as a Windo= ws service and run it as the SYSTEM user =E2=80=94 no need= for iservice, no need for SYSTEM token hack. Other than me, perhaps it cou= ld cover at least some of the users now running openvpn.exe directly.
=

Regards,
Simon
<= /html>= --Apple-Mail=_3BAE6E5C-7A63-428D-9F65-243AB25CE74C-- --Apple-Mail=_84593F5D-BBAF-445D-9EB6-C9074471BE41 Content-Disposition: attachment; filename="smime.p7s" Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3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