0
0
mirror of https://github.com/OpenVPN/openvpn.git synced 2024-09-20 03:52:28 +02:00
Commit Graph

3233 Commits

Author SHA1 Message Date
Antonio Quartulli
5a5d11a0de man/protocol-options: add missing ending metachar
A code string terminating character (`) is missing, thus leading to the
following warning:

man-sections/protocol-options.rst:99: (WARNING/2) Inline interpreted text
or phrase reference start-string without end-string.

Add missing char at the end of the code word.

Cc: David Sommerseth <davids@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210827145656.21646-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22779.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-28 15:58:36 +02:00
Antonio Quartulli
aa0e44e235 route.c: pass the right parameter to IN6_IS_ADDR_UNSPECIFIED
IN6_IS_ADDR_UNSPECIFIED on most systems is defined as a macro that
expects a struct in6_addr* argument.

In one instance we are passing the right address but using a wrong type.
Fix this invocation by properly passing the right pointer.

This issue might become more critical on systems implementing
IN6_IS_ADDR_UNSPECIFIED as a function rather than a macro.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by:
Message-Id: <20210826061725.22169-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22767.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-28 15:32:32 +02:00
Selva Nair
6ee1a272d9 Minor doc correction: tls-crypt-v2 key generation
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210822152820.7072-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22747.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-23 20:29:57 +02:00
Arne Schwabe
42f6063f61 Introduce webauth auth pending method and deprecate openurl
The experience with openurl/OPEN_URL has shown that just sending
a URL to a client is not enough and we often need different
behaviour of the client depending on circumstances. Replace
OPEN_URL with a more flexible WEB_AUTH pending auth method.

Patch v2: use WEB_AUTH instead WEBAUTH
Patch v3: incooperate other comments from Selva

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20210813115542.2794-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22737.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-16 10:44:24 +02:00
Selva Nair
8b3ea9ea57 Fix client-pending-auth help message in management interface
- Add the missing timeout value that is required (not optional)
- Split the long line
- Also make the AUTH_PENDING state message format in
  management-notes.txt more precise.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by:
Message-Id: <20210814044834.2236-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22739.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-14 17:53:56 +02:00
Antonio Quartulli
2b9bbaadf4 mbedtls: do not define mbedtls_ctr_drbg_update_ret when not needed
The mbedtls_ctr_drbg_update_ret() function was backported to various
older branches, including 2.14 and 2.7.
To avoid making the #if guard too complex, let's detect if this function
exist at configure time.
All versions not having this function, will use our compat code.

Cc: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Message-Id: <20210812085300.4738-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22734.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-12 13:01:38 +02:00
Max Fillinger
b99fa3fd4f Replace deprecated mbedtls DRBG update function
The function mbedtls_ctr_drbg_update is deprecated as of mbedtls 2.16
and is superseded by mbedtls_ctr_drbg_update_ret, which returns an error
code. This commit replaces the call to the deprecated function with the
new one and logs a warning in case of an error.

For older versions of mbedtls, we add a compatibility function that runs
mbedtls_ctr_drbg_update and returns 0.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210810061644.20353-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22711.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-11 14:25:11 +02:00
Gert Doering
903e2cf5c1 Use more C99 initialization in add_route/add_route_ipv6().
This gets rid of a few #ifdef and also removes the need for
commit a11bea18b1 (argv is only initialized after the
early exit check on RT_DEFINED).

v2:
  use gc_new(), group gc and argv init in both add_route*() functions

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210802152619.30754-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22694.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-05 17:31:22 +02:00
Gert Doering
7953b07bf5 Ignore --explicit-exit-notify in TCP mode.
Mixed udp+tcp configs can not have --explicit-exit-notify in them
today because this option is refused in TCP mode.  At the same time,
it was always possible to push the option both in UDP and TCP mode
(with a warning logged in TCP mode, and the option reset to 0).

Do the same thing for local config - warn, and reset to 0.

(Leaving it enabled in TCP mode is harmless, but causes extra error
messages in the log which is undesired behaviour.  Maybe one should
just fix the underlying logic for TCP mode instead, but this is more
invasive)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210802133127.25000-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22690.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-05 17:29:22 +02:00
Arne Schwabe
f9dbf645fa Remove unistd.h from unit test
the unit tests do not compile under Windows since Windows does not
provide a unistd.h header. The header is still included on Unix
platforms via syshead.h

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210802100740.694474-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22685.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-02 12:36:17 +02:00
Arne Schwabe
8c72d7981c Support NCP in pure P2P VPN setups
Currently P2P mode of OpenVPN is on of the few places that cannot negotiate
modern OpenVPN features. This becomes more and more problematic since P2P
and P2MP code diverge more and more and also the lack of switching to more
advanced features like Data v2 currently blocks P2P mode from working
together with the upcoming ovpn-dco support.

This NCP support is a lot simpler and works in the following way:

- P2P peer announce an extremely limited IV_ variable set
  (IV_PROTO and IV_CIPHERS)
- Both peers check if the IV_PROTO_NCP_P2P bit is present in IV_PROTO
- if yes both sides deterministically determine according to
  IV_PROTO and IV_CIPHER what options can be used and start using these

There are no poor man's NCP or other compatibility workaround like in the
normal NCP, making this NCP leaner and more deterministic.

Patch v2: remove empty lines, add doxygen comment to push_peer_info, fix
          push_peer_info >= 2 that should be > 2

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210728123050.564595-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22671.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-02 11:33:31 +02:00
Arne Schwabe
f235b5efd6 Add detailed man page section to setup a OpenVPN setup with peer-fingerprint
This is meant to give new users a quickstart for a useable OpenVPN
setup. Our own documentation is lacking in this regard and many
tutorials that can be found online are often questionable in some
aspects.

Linking the individual RST file on github also give a tutorial
in a nicely formatted way.

Patch V2: Fix grammar/spelling mistakes (thanks tincantech), move
          to openvpn-examples(5).

Patch v3: use server.key and server.crt instead of server.pem/serverkey.pem

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210728154922.568796-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22674.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-01 19:47:44 +02:00
Lev Stipakov
7e33127d56 contrib/vcpkg-ports: remove openssl port
MSFT has merged PR to vcpkg which
added OPENSSL_NO_AUTOLOAD_CONFIG option

  https://github.com/microsoft/vcpkg/pull/18389

This means that we don't need to have our own openssl port
and instead we just add

  set(OPENSSL_NO_AUTOLOAD_CONFIG ON)

to our custom triplets.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210628080832.510-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22616.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-01 19:08:00 +02:00
Lev Stipakov
de8871f86d GitHub Actions: fix MSVC builds
By reasons remain unknown, MSVC GitHub Actions
started to fail after some irrelevant change.

While problem is also reproduced on my GitHub fork,
I couldn't reproduce it locally. Despiteadding
debug logging to GitHub Actions it is not clear
what went wrong:

 ##[debug]Exit code '3221225477' received from command
 '"D:\a\openvpn\openvpn\vcpkg\vcpkg.exe"'

Turns out that update to a newer vcpkg commit fixed the problem.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210726223920.144-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22678.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-08-01 18:53:42 +02:00
Arne Schwabe
caacd629f8 Remove --ncp-disable option
NCP has proven to be stable and apart from the one VPN Provider doing
hacky things with homebrewed NCP we have not had any reports about
ncp-disable being required. Remove ncp-disable to simplify code paths.

Note: This patch breaks client without --pull. The follow up patch
for P2P NCP will restore that. But to avoid all the NCP/non-NCP special
cases to be implemented in P2P. P2P will directly switch from always
non-NCP to always NCP.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210520151148.2565578-8-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22418.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-28 14:04:16 +02:00
Arne Schwabe
d75e0736b4 Cleanup handling of initial auth token
This changes that auth_token_initial is set when the token is
initially generated instead when pushing the token. Even I do not
know anymore why I did it in this way in the first place. Also use
multi->auth_token_initial as source for the sesssion ID since it should
now always be available. Also set auth_token_initial directly to
up->password once we verified that we have gotten a valid token from
a client. This cleans ups the logic in generating the environment and
makes the code flow clearer.

Since the change makes auth_token_initial always available we need to add
a check to only send a PUSH reply to update the token on renegotiations.
The old code relied on multi->auth_token not being set in this case.

This commit also removes the workaround for old OpenVPN clients. These
were only available as commercial OpenVPN Connect client and not in use
anymore.

Furthermore, introduce a check if the session ID has changed during a
session.  Even though this is still a valid authentication changing to
a different auth token mid session is highly irregular and should never
occur naturally.

Patch V2: rebase.
Patch V3: fix formatting, clarifying commit message, remove initial
          token workaround for old v3.
Patch v4: move sending the auth-token for renegotiations to a sane place
          and trigger it when the TLS session reaches its fully authenticated
          state.
Patch v5: Move also setting auth_token_inital from up->password to a more
          logical place, general cleanups, add session id mismatch check
Patch v6: Rework some comments and general cleanup of small things

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210719133132.128783-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22645.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-28 12:17:13 +02:00
David Korczynski
a11bea18b1 Fix argv leaks in add_route() and add_route_ipv6()
If a route structure is passed to add_route() or add_route_ipv6()
without the RT_DEFINED flag set, both functions leak an "argv"
structure allocation.

Add appropriate argv_free() calls.

Signed-off-by: David Korczynski <david@adalogics.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210714162533.10098-1-david@adalogics.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22637.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-27 15:41:54 +02:00
Arne Schwabe
b66701e5e2 Fix tls-cert-profile broken on OpenSSL 1.1+
Commit bc36d9d569 removed the autoconf detection of various OpenSSL
functions. This overlooked HAVE_SSL_CTX_SET_SECURITY_LEVEL check in
tls_ctx_set_cert_profile. Replace this also with a version number
based check.

Tested with LibreSSL on OpenBSD 6.8, OpenSSL 1.1 and wolfSSL.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210623183728.2565286-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22584.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-21 15:12:18 +02:00
Arne Schwabe
34b42549c9 Introduce S_GENERATED_KEYS state and generate keys only when authenticated
Since generating data channel keys does not happen when we have reached
the S_ACTIVE/S_GOT_KEY state anymore like it used to be before NCP, the
state that data channel keys have been created deserves its own state in
the TLS session state machine.

The changes done by this commit are rather intrusive since they
move the key generation to a completely different place and also
rely on the state machine to decide if keys should be
generated rather than on the complicated conditions that were
implemented in the key_method_2_write/read methods.

A (intended) side effect of this change is that sessions that
are still in deferred state (ks->authenticated == KS_DEFERRED)
will not have data channel keys generated. This avoids corner
cases where a not fully authenticated sessions might leak data.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>

Patch v2: rebased

Patch v3: fix crash in non TLS mode

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210705133414.3102815-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22617.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-14 13:47:13 +02:00
David Sommerseth
51d85a9d28 man: Clarify IV_HWADDR
The IV_HWADDR description was only partially correct, as there are more
implementations using other values than the MAC address of the default
gateway.

The intention of this value is to provide a unique identifier of the
client and on some platforms this is not possible to retrieve other than
to generate this information.

The 64 bytes limitation is an arbitrary value, it is not enforced by
OpenVPN 2.x.  But it was considered a good idea to at least have some
reasonable upper limit of how long this string can be, at least for
those implementing support for this information.

Signed-off-by: David Sommerseth <davids@openvpn.net>

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210709134849.161728-1-openvpn@sf.lists.topphemmelig.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22625.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-09 16:39:45 +02:00
Max Fillinger
ccee09d147 Update Fox e-mail address in copyright notices
Replace openvpn@fox-it.com with openvpn@foxcrypto.com.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210701171458.8897-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22608.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-02 14:15:45 +02:00
David Sommerseth
37cf98fa22 doc: Use generic rules for man/html generation
Prior to this patch, the Makefile.am needs to be modified multiple
places to add a new man or HTML page to be generated.  Since it is not
too often we modify this, it is easy to miss these finer details.

This changes the man and HTML generator rules to be more generic and use
variables as many places as possible.  Also moved all the lines which
should not need to be changed as much towards the bottom-half of the
file.

Signed-off-by: David Sommerseth <davids@openvpn.net>

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210630185134.144826-1-openvpn@sf.lists.topphemmelig.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22604.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-02 13:59:57 +02:00
Arne Schwabe
0c5380e906 Move examples into openvpn-examples(5) man page
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20210520150932.2565217-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22414.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-07-02 11:50:11 +02:00
Lev Stipakov
480e4cc14f Fix console prompts with redirected log
When openvpn needs to prompt user for a password
(for example, to set management interface password),
the prompt is written to standard error device.

When log is redirected to a file, that prompt is written
to that file and not to the "original" stderr. Moreover, on recent
Insider build (21390.2025) openvpn exits with fatal error

  get_console_input_win32(): unexpected error: No such device or address
  (errno=6)

while attempting to write that prompt.

When redirecting stdout/stderr, we use _dup2() to associate stderr
descriptor with a log file. This call closes file associated
with stderr descriptor, which might explain why it has stopped
working (original stderr is closed and WriteFile() fails) and on
older versions it appears to work "by accident" - not failing
but use redirected stderr instead of original one.

Fix by creating new file descriptor with _dup() for stderr
before redirect and use this descriptor for writing prompts.

While on it, make code a bit more C99-ish by moving variables
declaration from the beginning of the scope to the actual
initialisation.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210625010405.224-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=20210625010405.224-1-lstipakov@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-25 17:37:48 +02:00
Arne Schwabe
e55bedd4ea Extracting key_state deferred auth status update into function
This extract the update of a deferred key status into into own
function.

Patch v2: Do not ignore auth_deferred_expire. Minor format changes.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210520151148.2565578-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22420.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-25 17:27:21 +02:00
Gert Doering
8f283648d9 Add error reporting to get_console_input_win32().
When the function setup fails due to invalid file handles, or because
WriteFile(err, ...) fails (due to file handle corruption elsewhere),
the function used to silently "return false"

Change this to print a M_WARN|M_ERRNO message.

Also, change the function style to early-return style (= large diff, but
most are indent changes only).

v2: fix spurious "}" that was left over from change to early-return.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20210618181246.30769-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22577.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-24 17:28:57 +02:00
Arne Schwabe
87c8c081d5 Ensure tls session is authenticated before sending push reply
We ensure here that the tls session is authenticated before sending
a push_reply

This the final part of the fix for CVE-2020-15078 in the master branch.

CVE: 2020-15078
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210624130840.2583433-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22587.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-24 16:38:18 +02:00
Arne Schwabe
489c45fb37 Make waiting on auth an explicit state in the context state machine
Previously we relied on checking tls_authentication_status to check
wether to determine if the context auth state is actually valid or not.
This patch eliminates that check by introducing waiting on the
authentication as extra state in the context auth, state machine.

The simplification and reorganization of the state machine in this
and the previous patches also eliminates a number of corner cases,
including the specific one that lead to CVE-2020-15078.

Patch v3: Fix ccd config from management being ignored
Patch v4: Fix race condition, we need to accept the config from
          management if we are in CAS_WAITING_AUTH or earlier states
	  and not just in CAS_WAITING_AUTH state

CVE: 2020-15078

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210604143938.779193-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22491.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-24 15:38:40 +02:00
Arne Schwabe
d01277608a Add connection_established as state in tls_multi->context_auth
The socket_info->connection_establish is set through
link_socket_set_outgoing_addr when we reach FULL_SYNC. This patch
introduces a new state in context_auth that replaces the
connection_established state for TLS connections. This make the state
machine easier to understand.

Also, rename "enum client_connect_status" to "multi_status", re-order
states so CAS_NOT_CONNECTED (=0) is the default state, and introduce
CAS_CONNECT_DONE as numerically highest so "are we done?" can be
easily checked.

This is part of the patchset to fix CVE-2020-15078 in "master" by
reorganizing the handling of incoming new and renegotiated TLS sessions
to make the code easier to understand and less prone to "edge case"
issues.

Patch v2: fix p2p mode server without (without ncp)

CVE: 2020-15078

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210520151148.2565578-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22419.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-24 15:31:04 +02:00
Arne Schwabe
716049923e Move auth_token_state from multi to key_state
The auth-token check is tied to the username/password that is coming
via a specific SSL session, so keep the state also in the key_state
structure.

This also ensures the auth_token_state is always set to 0 on a new
session since we clear the key_state object at the start of a new
SSL session.

This is a prerequisite patch to fix 2020-15078 in the following two
commits.

This also applies the changes to the auth_token_test.c. The change of
tls_session to a pointer is necessary since before that we had tls_session
not tied to the multi and had two tls_session used in the test. One
implicitly in tls_multi and one explicit one. Merge these to one.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210520151148.2565578-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-18 15:08:54 +02:00
Lev Stipakov
84d5079b0f contrib/vcpkg-ports: add openssl port with --no-autoload-config option set (CVE-2121-3606)
In default configuration OpenSSL loads config from
certain location on disk, for example

  c:\vcpkg\packages\openssl_x64-windows\openvpn.cnf

which may pose a security risk.

There is "no-autoload-config" config option for OpenSSL
which disables this functionality:

https://github.com/openssl/openssl/pull/5959

however it is not "exported" to vcpkg.

This adds openssl port overlay which sets "no-autoload-config"
config option. Here is the diff (indented with "!" to avoid
confusing "git am"):

! diff --git a/ports/openssl/windows/portfile.cmake
! b/ports/openssl/windows/portfile.cmake
! index 7a3bf08ed..c873eb756 100644
! --- a/ports/openssl/windows/portfile.cmake
! +++ b/ports/openssl/windows/portfile.cmake
! @@ -21,6 +21,7 @@ set(CONFIGURE_OPTIONS
!      enable-capieng
!      no-ssl2
!      no-tests
! +    no-autoload-config
!      -utf-8
!      ${OPENSSL_SHARED}
! )

There is also corresponsing PR to vcpkg:

https://github.com/microsoft/vcpkg/pull/18389

When above PR is merged, this port overlay can be removed.

CVE: 2121-3606
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210617061259.297-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22569.html
2021-06-17 10:44:17 +02:00
Lev Stipakov
abd5ee9b7d crypto_openssl.c: disable explicit initialization on Windows (CVE-2121-3606)
Commit a4071b ("crypto_openssl: add initialization to pick up local
configuration") added openssl initialization to load configuration
file.  However on Windows this file is loaded from user-writable
directory, such as c:\etc\ssl for mingw builds and (for example)
c:\vcpkg\packages\openssl_x64-windows\openvpn.cnf for vcpkg
builds.  This could be a security risk.

CVE-2121-3606 has been assigned to acknowledge this risk.

Since aforementioned commit implements a niche feature which might
be better solved with CryptoAPI on Windows, make this code conditional
(for now).

CVE: 2121-3606
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210617061226.244-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22568.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-17 10:39:29 +02:00
Selva Nair
063d55afee Apply the connect-retry backoff to only one side of a connection
p2p connections with both ends backing off seldom succeed
as their connection attempt durations becomes increasingly
unlikely to overlap when the retry wait time is long.

Avoid this by applying the backoff logic only on TCP clients
or the tls_client side for UDP.

Regression warning: shared secret setups are left out of the
backoff logic.

Trac: #1010, #1384

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210602194739.29488-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22485.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-17 09:45:51 +02:00
Arne Schwabe
b398aa37ca Implement auth-token-user
When not using username and password (i.e. auth-user-pass) it can still
be desirable to provide the client with an auth-token, e.g. for allowing
a session to continue after a reconnect without requiring 2FA again.

However, without --auth-user-pass openvpn does not have a username and will
ignore any pushed auth-token command.

This patch adds support for auth-token-user to set the username that should
be used for auth-token

The spec of using auth-token-user base64-encoded-user are the ones that
OpenVPN3 already implements.

Patch V2: Improve style, fix comments and commit message

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210520151148.2565578-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22417.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15 15:53:20 +02:00
Lev Stipakov
e007cc260e GitHub actions: add MSVC build
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210615125616.344-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22556.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15 15:25:06 +02:00
Lev Stipakov
7421234982 vcpkg-ports: restore trailing whitespaces in .patch files
Commit 36b9aa "contrib/vcpkg-ports: add pkcs11-helper port"
has trimmed trailing white space in .patch files and thus corrupted them.

Restore trailing whitespaces to "uncorrupt" patches.

** applied with git am --whitespace=nowarn **

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-By: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210615104331.210-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22553.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15 13:18:43 +02:00
Selva Nair
e0f860f4b3 Improve documentation of AUTH_PENDING related directives
Also fix some typos.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210602034253.19984-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22475.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15 11:40:26 +02:00
Lev Stipakov
36b9aa0c1e contrib/vcpkg-ports: add pkcs11-helper port
pkcs11-helper is a dependency library used by OpenVPN.
So far it has been built only by mingw.

Since we're making MSVC build system a first class citizen,
we need to build depencencies with MSVC, which we do with vcpkg.
All dependencies are in vcpkg official repo, expect pkcs11-helper.

This provides vcpkg port for building pkcs11-helper.

Example usage:

 vcpkg --overlay-ports=<openvpn>\contrib\vcpkg-ports install pkcs11-helper

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210607104213.216-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22503.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15 11:17:17 +02:00
Lev Stipakov
56f775fe9d msvc: standalone building
This finally enables standalone MSVC building, without
dependency on openvpn-build/msvc. This makes MSVC build
process much simpler.

Dependencies are managed by vcpkg. To install dependencies, run:

  > vcpkg --overlay-ports=<openvpn>\contrib\vcpkg-ports
          --overlay-triplets=<openvpn>\contrib\vcpkg-triplets install
          lz4:x64-windows-ovpn lzo:x64-windows-ovpn
openssl-windows:x64-windows-ovpn pkcs11-helper:x64-windows-ovpn
tap-windows6:x64-windows-ovpn

To build for other arch, use x86-windows-ovpn or arm64-windows-ovpn.
Custom triplets are defines so that lz4 is linked statically and
other libraries dynamically.

Since we don't have CMake support yet, we cannot use vcpkg manifest
mode, since it doesn't work with overlay ports
(https://github.com/microsoft/vcpkg/issues/12289),
therefore this one-time manual dependency installation is required.

While on it, bump msvc-generate project target version to VS2019 and
cleanup leftovers from compat.vcxproj.filters.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210514045704.686-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22389.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15 10:52:51 +02:00
David Sommerseth
05271322e7 Update copyrights
- Update the update-copyright script to include more contributors as well
  as correcting a few typos

- Correct a copyright address in the source code to now used address
  (dazo)

- Update copyright year to 2021

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210609213231.22576-1-openvpn@sf.lists.topphemmelig.net>
URL: https://www.mail-archive.com/search?l=mid&q=20210609213231.22576-1-openvpn@sf.lists.topphemmelig.net
URL: https://sourceforge.net/p/openvpn/mailman/message/37299719/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15 10:41:07 +02:00
Arne Schwabe
d2e5412aa4 Silence warning about format string in check_ca_required
clang does not like if the format argument of printf like function
is not a string literal (or constant):

warning: format string is not a string literal (potentially insecure)

Make the format string constant to silence the warning.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20210609061532.12774-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22519.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-13 20:26:11 +02:00
Arne Schwabe
b4f658dfb0 Add github actions
dummy0 gives strange errors on the Ubuntu 16 runner on github actions
because
dummy already exist, so use a more unique ovpn-dummy0 name instead.

Github actions are a good alternative to travis-ci, which futrure is
questionable
at the moment without payment. The github actions also allows building on
macOS
and Windows (not included in this commit). The  matrix is a bit different
than Coverity and uses different Ubuntu version with their native OpenSSL
(1.0.2, 1.1.1)/mbed TLS instead of manually compiling different OpenSSL
versions on just Ubuntu 20.04.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20210608152434.1403999-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22511.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-09 08:26:41 +02:00
Jeff
5ebbe100df duplicate function declaration.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1623115970-9186-1-git-send-email-os.gv.ll@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=1623115970-9186-1-git-send-email-os.gv.ll@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-08 08:07:09 +02:00
Lev Stipakov
88395a8307 options.c: fix msvc build error
Commit b7fe49c ("Do not require CA when peer-fingerprint is used") broke
msvc build by adding #ifdef within msg() macro call.

    options.c(2074,1): error C2121: '#': invalid character: possibly the
result of a macro expansion
    options.c(2074,1): error C2146: syntax error: missing ')' before
identifier 'ifndef'
    options.c(2074,1): error C2059: syntax error: ')'

Fix by moving #ifdef outside of msg().

Reported-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: selva.nair@gmail.com
Message-Id: <20210607184820.343-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22506.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-07 21:41:13 +02:00
Matthias Andree
0033811e02 Fix SIGSEGV (NULL deref) receiving push "echo"
A server pushing "echo" without arguments can crash the client.
In such a situation, the code in question receives p[1] == NULL
(which was CLEAR(p)'ed above), hands it strncmp, which then
dereferences the null pointer.

Original report and analysis here:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256331

Fixes: Trac #1409
Reported-by: peo@nethead.se (to FreeBSD)
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210603123019.422644-1-matthias.andree@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22486.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-03 16:36:05 +02:00
Selva Nair
b7fe49c2f9 Do not require CA when peer-fingerprint is used
Fix --ca or --ca-path check when --pkcs11-id or --cryptoapicert
is used with --peer-fingerprint.

The multiple --ca or --capath checks are consolidated into a function

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210524184506.20582-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22443.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-02 19:48:13 +02:00
Selva Nair
28240c4a6e Fix parsing of IV_SSO string
Expect comma separated keywords

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210602034253.19984-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22474.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-02 16:13:11 +02:00
Selva Nair
890225c178 Replace TEXT(__FUNCTION__) by __FUNCTION__ in openvpnmscia.c
TEXT(__FUNCTION__) does not work in mingw as __FUNCTION__
is not a macro. Instead, use __FUNCTION__ as a narrow
string in both UNICODE and ANSI builds.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20210526224919.511-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22461.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-05-27 09:25:11 +02:00
Selva Nair
a13f6b16b2 Print format spec changes for tapctl and openvpnmscia
The tapctl and openvpnmscia codebase is written with an intent of
supporting both unicode and ansi builds.  This patch does not attempt
to change that although non-unicode support looks untested
and buggy.

The main change is to replace %s by PRIsLPTSR that is defined
as %ls or %s depending on _UNICODE is defined ot not.

v2: add missing ')' and fix whitespace

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20210525173838.3969-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22453.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-05-27 09:08:57 +02:00
Selva Nair
ea2b153c35 Use C standard compliant format specs in wprintf functions
- Use %ls for wchar_t * and %hs for char * variables

This makes it possible to build correctly with or without
__USE_MINGW_ANIS_STDIO defined. When this define is not used
all printf/scanf family functions are resolved from the windows
runtime MSVCRT.  Newer (since version 8) mingw-w64 versions have
started automatically enabling this macro under some feature
sets such as _GNU_SOURCE and C99.

The changes should not affect MSVC builds as Windows support
these format specifications.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20210522033232.20548-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22436.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-05-25 22:26:06 +02:00