Skip to contentSkip to conversation

script-security 1

Openvpn-devel Jan Just Keijser 3 participants 5 messages Dec 2, 2010 – Dec 3, 2010

lore
Share & tools
lore
#0 lore raw

hi all,

the openvpn 2.1 man page on script-security reads:

--script-security level [method]
This directive offers policy-level control over OpenVPN's usage of
external programs and scripts. Lower level values are more restrictive, higher values are more permissive. Settings for level:

0 -- Strictly no calling of external programs.
1 -- (Default) Only call built-in executables such as ifconfig, ip,
route, or netsh.
2 -- Allow calling of built-in executables and user-defined scripts. 3 -- Allow passwords to be passed to scripts via environmental
variables (potentially unsafe).

but if I try something like
openvpn --config <serverconf> --script-security 1 --up "/sbin/ip addr show eth0" I still get

Thu Dec  2 15:52:51 2010 /sbin/ip addr show eth0 tun0 1500 1541 192.168.200.1 255.255.255.0 init
Thu Dec  2 15:52:51 2010 openvpn_execve: external program may not be called unless '--script-security 2' or higher is enabled.  Use '--script-security 3 system' for backward compatibility with 2.1_rc8 and earlier.  See --help text or man page for detailed info.
Thu Dec  2 15:52:51 2010 script failed: external program fork failed
Thu Dec  2 15:52:51 2010 Exiting

what _IS_ the list of built-in executables? I cannot find it in the source code either.

cheers,

JJK

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 30 lines · Jan Just Keijser

hi all,

the openvpn 2.1 man page on script-security reads:

--script-security level [method]
This directive offers policy-level control over OpenVPN's usage of
external programs and scripts. Lower level values are more restrictive, higher values are more permissive. Settings for level:

0 -- Strictly no calling of external programs.
1 -- (Default) Only call built-in executables such as ifconfig, ip,
route, or netsh.
2 -- Allow calling of built-in executables and user-defined scripts. 3 -- Allow passwords to be passed to scripts via environmental
variables (potentially unsafe).

but if I try something like
openvpn --config <serverconf> --script-security 1 --up "/sbin/ip addr
show eth0"
I still get

Thu Dec 2 15:52:51 2010 /sbin/ip addr show eth0 tun0 1500 1541 192.168.200.1 255.255.255.0 init
Thu Dec 2 15:52:51 2010 openvpn_execve: external program may not be called unless '--script-security 2' or higher is enabled. Use '--script-security 3 system' for backward compatibility with 2.1_rc8 and earlier. See --help text or man page for detailed info.
Thu Dec 2 15:52:51 2010 script failed: external program fork failed Thu Dec 2 15:52:51 2010 Exiting

Quoted 2 lines

what _IS_ the list of built-in executables? I cannot find it in the source code either.

My understanding of it is executables which are executed by the C code, like the programs mentioned. That further means that no external script hooks may be used, like --up, --down, --route-up, etc, etc.

You need --script-security 2 to enable the script hooks, which will enable the execve() code path for these hooks. And if '--script-security 2 system' is set, it will use system() instead of execve() to execute the scripts.

If --script-security 0 is used, the execve() calls will be completely blocked.

For Linux, I believe the list of "built-ins" are ip, ifconfig, netstat and route. I'm not sure about the Windows side.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkz3u2UACgkQDC186MBRfrq3ZQCfaww4niDxYNBHwGtf7Jv6PTQF yqEAn0ZFP3glNd7b0YBWIlUXd+FEEWNJ
=cYzj
-----END PGP SIGNATURE-----

#2 lore raw

Hi David,

Quoted 42 lines · David Sommerseth

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 20 lines · Jan Just Keijser

hi all,

the openvpn 2.1 man page on script-security reads:

--script-security level [method]
This directive offers policy-level control over OpenVPN's usage of
external programs and scripts. Lower level values are more restrictive, higher values are more permissive. Settings for level:

0 -- Strictly no calling of external programs.
1 -- (Default) Only call built-in executables such as ifconfig, ip,
route, or netsh.
2 -- Allow calling of built-in executables and user-defined scripts. 3 -- Allow passwords to be passed to scripts via environmental
variables (potentially unsafe).

but if I try something like
openvpn --config <serverconf> --script-security 1 --up "/sbin/ip addr
show eth0"
I still get

Quoted 7 lines
Thu Dec  2 15:52:51 2010 /sbin/ip addr show eth0 tun0 1500 1541 192.168.200.1 255.255.255.0 init
Thu Dec  2 15:52:51 2010 openvpn_execve: external program may not be called unless '--script-security 2' or higher is enabled.  Use '--script-security 3 system' for backward compatibility with 2.1_rc8 and earlier.  See --help text or man page for detailed info.
Thu Dec  2 15:52:51 2010 script failed: external program fork failed
Thu Dec  2 15:52:51 2010 Exiting

what _IS_ the list of built-in executables? I cannot find it in the source code either.

My understanding of it is executables which are executed by the C code, like the programs mentioned. That further means that no external script hooks may be used, like --up, --down, --route-up, etc, etc.

You need --script-security 2 to enable the script hooks, which will enable the execve() code path for these hooks. And if '--script-security 2 system' is set, it will use system() instead of execve() to execute the scripts.

Quoted 7 lines

If --script-security 0 is used, the execve() calls will be completely blocked.

For Linux, I believe the list of "built-ins" are ip, ifconfig, netstat and route. I'm not sure about the Windows side.

thanks for the clarification! and indeed, when running
openvpn --config <serverconf> --script-security 0
openvpn even refuses to start (on Linux) as it is not capable of assigning an IP address to the tun/tap interface...
I guess the only platform on which '--script-security 0' can do something useful is Windows, as the IPAPI calls are "internal", that is, they do not require an execve() to initialize things like adapters and routes.

hmmmm, come to think of it: wouldn't this be a nice feature on Linux/Mac OS too, i.e. bring up the tun/tap interface programmatically instead of using an external binary? I am not sure how portable it would be though.

cheers,

JJK

PS yes this will go into "the book" ;-)

#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/12/10 22:58, Jan Just Keijser wrote:
[...snip...]

| I guess the only platform on which '--script-security 0' can do
| something useful is Windows, as the IPAPI calls are "internal", that is,
| they do not require an execve() to initialize things like adapters and
| routes.

That sounds like reasonable conclusion for me as well.

| hmmmm, come to think of it: wouldn't this be a nice feature on Linux/Mac
| OS too, i.e. bring up the tun/tap interface programmatically instead of
| using an external binary? I am not sure how portable it would be though.

Yes, indeed. And we discussed this on the developers meeting a couple of weeks ago actually. There are possibilities to do this via a so called NETLINK API to the kernel, at least on *BSD and Linux. For Solaris I don't know how that would work out. Anyway the execve() approach would not be torn out.

The NETLINK layer, however, isn't too easy to work with, compared to just calling external binaries. Another aspect is that the API is somewhat different between Linux and *BSD. I don't know if it's different or how different it would be between the *BSD flavours (which in theory should cover OSX as well). That's not a strong argument, though, as the route and ifconfig command syntaxes differs between these OSes already.

Another advantage of this, at least in theory on Linux, is that when OpenVPN is started as root, it should be possible to assign OpenVPN some network capabilities when dropping privileges. Capabilities is a kind of ACL on the kernel layer. So that means that a nobody:nobody user running openvpn would be able to modify the routing table and tearing down and setting up the tunnel device without root privileges. This is for me a more interesting aspect of using the NETLINK API.

Implementing NETLINK API will be investigated more for sure.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkz4JRcACgkQDC186MBRfroN1wCeIJo41ksWYaS5EzWkePa1LhEj TQAAn0y8NzZGi/O318HLlUPJxkRBhYG7
=/8O2
-----END PGP SIGNATURE-----

#4 lore raw
Quoted 1 line · David Sommerseth

a so called NETLINK API

..

Quoted 1 line

isn't too easy to work with

Maybe libnl can help.

//Peter