Altering routing Tables as non-admin on Windows
I've recently come back to looking at openvpn, after discovering that it now handles most things 'out of the box' for non-admins on Windows a requirement on our managed machines).
The one problem I've discovered is that as openvpn starts, it tries to alter the routing tables on the client to route through the VPN. However, these routing rules can only be changed by an admin - or more specifically by a member of the 'Network Configuration Operators' group, This group gives more rights to the user than are necessary for just routing, and may create security problems.
I've come up with a solution for this, for which I've written a 'proof-of-concept' script - please don't use this in service, as its not really been tested!
The idea is that a Windows Service runs and in some way monitors the VPN connection (tailing a log file, having a socket which it can be connected to on, etc). the routing rules that are normally implemented by the openvpn command itself are moved to this service, and when 'triggered' it runs the routing commands. The service runs as an account with appropriate privileges to make these changes. There is no need to 'undo' these rules, since when the vpn is disconnected, and the tun device disappears, the network stack tidies up the routing table accordingly.
I've implemented this as a test using a VBS script, which watches the OpenVPN log file for successful connections.
The script is here:
http://www.see.ed.ac.uk/~mrichar1/openvpn-routing/
And relies on the srvany/instsrv tools from Microsoft. download all the files to c:\openvpn-routing\
To install:
instsrv.exe OPENVPN-Routing c:\openvpn-routing\srvany.exe
then edit the registry:
HKLM\CurrentControlSet\Services\OPENVPN-Routing\Parameters\
Create String 'Application' - value of:
cscript c:\openvpn-routing\monitor.vbs
At the moment the script doesn't change the routing tables - instead it launches notepad to show its working - change the notepad line to the appropriate route commands to actually use it.
All of the above is really provided as a demonstration of a possible solution for this problem - its written in vbs for simplicity, but I imagine (not being familiar with the openvpn code-base) that it would be possible to reproduce in a more suitable language and bundle as part of the openvpn package, and use a better mechanism than tailing the log file to make the call to the service to change the routing table.
Just a thought on solving this problem. Comments etc welcome!
Matthew
Signature · 9 lines
===================================================== Matthew Richardson School of Engineering and Electronics, The University of Edinburgh, King's Buildings, Mayfield Rd, Edinburgh EH9 3JL ----------------------------------------------------- 0131 650 8747, FAX: 0131 650 6554 [email protected]... =====================================================
Hello Matthew,
Quoted 3 lines
specifically by a member of the 'Network Configuration Operators' group, This group gives more rights to the user than are necessary for just routing, and may create security problems.
Which problems? They can't do harmfull things:
http://support.microsoft.com/kb/297938/en-us
Quoted 2 lines
All of the above is really provided as a demonstration of a possible solution for this problem
Why not run openvpn as a service?
greetings
Carsten
A message that is not in the archive (sent off-list or not yet received): [email protected]...
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Quoted 6 lines
MR> If this has changed, and there is a way
MR> to interact with the service as non-admin then I will certainly look MR> into this...take subinacl to change the ACL of the openvpn-service
http://www.microsoft.com/downloads/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&displaylang=en
users need the right to start/stop the service
I just replied to Carsten to thank him for pointing me to this, and then discovered something which is a show-stopper for me - if run as a service, OpenVPN can only do certificate authentication, not user/password auth, since there is no way to pass the auth details to the service:
http://www.openvpn.se/files/howto/openvpn-howto_run_openvpn_as_nonadmin-Rev1.1.html
We would prefer to use password auth instead of certificate distribution in our environment.
However, the page given above states:
"There is work in progress to enhance the OpenVPN Service so it can be controlled via a TCP socket. This will allow individual tunnels to started and stopped at will, as well as supplying OpenVPN with the password used to encrypt the private key. OpenVPN GUI 2.0 will be rewritten to make use of this service."
which seems to cover what I would like to see in OpenVPN. Can anyone shed any more light on this?
Matthew