Security – In OpenVPN, what’s the risk of omitting the key-direction when using tls-auth

openvpnSecuritytls

In my TLS enabled OpenVPN configuration I would like to use the additional security offered by using tls-auth. The good news is, is that it works as expected. However, I have a question about the optional key-direction parameter (either as a second parameter to the tls-auth option or as key-direction option).

The configuration parameter is described in the manpage as follows (version 2.3.x, relevant snippets):

--tls-auth file [direction]
      Add  an  additional layer of HMAC authentication on top of the TLS control
      channel to protect against DoS attacks.

      In a nutshell, --tls-auth enables a kind of "HMAC firewall"  on  OpenVPN's
      TCP/UDP  port, where TLS control channel packets bearing an incorrect HMAC
      signature can be dropped immediately without response.

      file (required) is a key file which can be in one of two formats:

      (1) An OpenVPN static key file generated by --genkey (required  if  direc‐
      tion parameter is used).

      (2) A freeform passphrase file.  In this case the HMAC key will be derived
      by taking a secure  hash  of  this  file,  similar  to  the  md5sum(1)  or
      sha1sum(1) commands.

      OpenVPN  will  first  try  format (1), and if the file fails to parse as a
      static key file, format (2) will be used.

      See the --secret option for more information  on  the  optional  direction
      parameter.

      ... (snip)

--secret file [direction]
      Enable Static Key encryption mode (non-TLS).  Use pre-shared  secret  file
      which was generated with --genkey.

      The optional direction parameter enables the use of 4 distinct keys (HMAC-
      send, cipher-encrypt, HMAC-receive, cipher-decrypt),  so  that  each  data
      flow  direction  has  a different set of HMAC and cipher keys.  This has a
      number of desirable  security  properties  including  eliminating  certain
      kinds of DoS and message replay attacks.

      When  the direction parameter is omitted, 2 keys are used bidirectionally,
      one for HMAC and the other for encryption/decryption.

      The direction parameter should always be complementary on either  side  of
      the connection, i.e. one side should use "0" and the other should use "1",
      or both sides should omit it altogether.

      The direction parameter requires that file contains a 2048 bit key.  While
      pre-1.5  versions  of  OpenVPN generate 1024 bit key files, any version of
      OpenVPN which supports the direction parameter, will also support 2048 bit
      key file generation using the --genkey option.

      ... (snip)

--key-direction
      Alternative way of specifying the optional  direction  parameter  for  the
      --tls-auth  and --secret options. Useful when using inline files (See sec‐
      tion on inline files).

Note that I am not using static key encryption mode, but only showing the --secret manpage snippet because it is suggested by the --tls-auth description.

I fail to understand the explanations here. Is security improved when specifying a direction (0 for server, 1 for client) or not if omitted?

Best Answer

(This answer is specific to the use of key-direction for tls-auth keys. For static key mode, please always use key-direction.)

The advantage of using different keys for each direction is that packets originating from one peer can never be replayed back to that peer by a man-in-the-middle attacker. Of course the underlying TLS and OpenVPN protocols should never accept such packets, but the goal of tls-auth is to offer (some) protection against bugs in the protocol or implementation that cause the underlying mechanisms to fail.