Commit Graph

2183 Commits

Author SHA1 Message Date
Nikos Mavrogiannopoulos
3a8e280a92 translate labels to groups when provided by client
This addresses issues with anyconnect clients which send back the descriptive labels.

Resolves #267

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-05-21 22:24:17 +02:00
Michael Brown
a227d6d66d tun: Bring up interface before setting IPv6 route on Linux
Linux kernel commit 955ec4c ("net/ipv6: Do not allow route add with a
device that is down") rejects attempts to install an IPv6 route on an
interface that is not yet up.  This commit is first included in kernel
4.16.

The current code in os_set_ipv6_addr brings up the interface only
after attempting to install the IPv6 route.  On kernel 4.16 or later,
this fails with the error "Error setting route to remote IPv6: Network
is down".

Fix by switching the order of code blocks to bring the interface up
before attempting to configure the route.

Resolves: #301
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2020-05-13 06:16:30 +02:00
Nikos Mavrogiannopoulos
f9d8b3afc8 worker: enable all system calls used by worker
This allows the set of non-blocking sockets in worker processes.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-05-10 21:45:18 +02:00
Nikos Mavrogiannopoulos
350250ea82 worker: allow filtered calls to fail with a trap
This adds a fedora CI run to with filtered calls failing
with a signal in order to detect missing syscalls from our filters.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-05-10 21:45:05 +02:00
Nikos Mavrogiannopoulos
783c240998 ocsigaltstack: posix_memaligns does not return negative on failure
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-05-02 06:09:16 +02:00
Nikos Mavrogiannopoulos
7d4190a0a3 seccomp: fail with ENOSYS instead of EPERM
When new calls are introduced in the kernel a libc may
chose to move to them. Having our filter return ENOSYS
will signal libc to fallback to the previous call which
exists in the filter.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-05-02 06:03:53 +02:00
Alan Jowett
75470d99c3 When setting up the DTLS session, close the previous DTLS session if it exists.
Resolves: #293

Signed-off-by: Alan Jowett alanjo@microsoft.com
2020-04-29 13:39:28 +02:00
Alan Jowett
7e5052782e Remove unused code when --disable-compression is set.
Resolves: #291

Singed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-04-27 09:18:09 -06:00
Alan Jowett
8cac05dac2 Remove unused code when --disable-anyconnect-compat is set.
Resolves: #290

Signed-off-by: Alan Jowett alanjo@microsoft.com
2020-04-26 13:10:10 -06:00
Alan Jowett
b63ecb7717 Kill ocserv workers before ocserv-main or ocserv-secmod
On systems that are running low on memory, the ocserv worker processes
should be killed before the ocserv-main or ocserv-sm process.

To achieve this, we set /proc/self/oom_score_adj to 1000

Resolves: #283

Signed-off-by: Alan TG Jowett <alan.jowett@microsoft.com>
2020-04-22 12:59:07 +02:00
Nikos Mavrogiannopoulos
deef4603a0 Merge branch 'issue284' into 'master'
Attempt to download updated JWKs if the client presents an unknown key.

Closes #284

See merge request openconnect/ocserv!168
2020-04-22 10:56:55 +00:00
Alan Jowett
9d9907ef5e Attempt to download updated JWKs if the client presents an unknown key.
Limit the download of keys to every 900s.

Resolves: #284
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-04-19 16:30:12 -06:00
Nikos Mavrogiannopoulos
e79348a154 corrected typo
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-04-17 22:14:58 +02:00
Nikos Mavrogiannopoulos
a63164e182 Disable TCP queuing on the TLS port.
This makes the CSTP connection more interactive for clients that
cannot run over UDP.

See openconnect#122 for discussion.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-04-10 21:15:39 +02:00
Nikos Mavrogiannopoulos
fca41e2fa2 Distinguish the bye packet interpretation
In openconnect client the BYE packet indicates an explicit
user disconnect by sending 0x0b as payload. In anyconnect clients it
may indicate an intention to reconnect (e.g., because network was changed).
We introduce a check for 0x0b to identify the user disconnect and
add debugging output for other disconnect reasons.

Relates: #281

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2020-04-08 21:07:36 +02:00
Nikos Mavrogiannopoulos
1e657a618a Cleanup get_cert_names()
Ensure that we do not recognize unsupported names as
supported.

Relates: #822

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2020-04-06 16:21:04 +02:00
Nikos Mavrogiannopoulos
2d9bc11f59 occtl: list actual banned entries
This fixes the ban entries listing from printing all the items in
the database, to all the items that are actually banned from
connecting.

Resolves: #272

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2020-04-03 22:09:14 +02:00
Nikos Mavrogiannopoulos
79cb3cb7ff occtl: avoid division by zero
Resolves: #278

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2020-04-03 13:45:36 +02:00
Nikos Mavrogiannopoulos
c34b84e0d1 Merge branch 'tmp-ignore-broken-dtls' into 'master'
Prevent clients with a broken GnuTLS version from connecting using DTLS

Closes #277

See merge request openconnect/ocserv!157
2020-04-03 11:39:28 +00:00
Nikos Mavrogiannopoulos
aa9c401cac Prevent clients with a broken GnuTLS version from connecting using DTLS
That prevents clients that send an all-zero DTLS client hello from being
able to establish a connection.

That also introduces the OCSERV_ALLOW_BROKEN_CLIENTS environment variable
which when set to 1 it allows broken clients to connect. This is used
mainly to allow test cases to pass to existing vulnerable systems in our
CI.

Resolves: #277

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-04-03 12:51:22 +02:00
Nikos Mavrogiannopoulos
d551b8badc cstp_send_file: fixed handling of syscall interrupts
This also increases the buffer size.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2020-04-02 15:05:29 +02:00
sunnyqeen
899a1323a9 Fix hmac hash problem for time_t and unit64_t, they may have different size in 32bit/64bit systems 2020-03-31 09:58:09 +00:00
Stefan Bühler
0e6a791a40 occtl show status: produce machine-readable output for json
This adds additional variables to include machine-readable output
in json form.

Resolves: #271

Signed-off-by: Stefan Bühler <stbuehler@web.de>
2020-03-27 08:20:34 +01:00
Nikos Mavrogiannopoulos
07948320ad Merge branch 'fix_compilation_warnings_in_pcl' into 'master'
Fixed minor compilation warnings

See merge request openconnect/ocserv!153
2020-03-25 09:24:39 +00:00
Pierre Souchay
f19c3f7d23 Fixed minor compilation warnings
Warnings outputed by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

* pcl/pcl.c:385:17: warning: unused variable ‘r’ [-Wunused-variable]

* Use pre-compilation directive to avoid defining unused function when not needed:

  * pcl/pcl.c:62:12: warning: ‘co_ctx_stackdir’ defined but not used [-Wunused-function]
    static int co_ctx_stackdir(void)

  * pcl/pcl.c:54:12: warning: ‘co_ctx_sdir’ defined but not used [-Wunused-function]
    static int co_ctx_sdir(unsigned long psp)

Signed-off-by: Pierre Souchay <pierre@souchay.net>
2020-03-23 18:20:08 +01:00
Stefan Bühler
23430d1118 ban log: only log once when adding, not when increasing score when already banned
Signed-off-by: Stefan Bühler <stbuehler@web.de>
2020-03-22 16:01:03 +01:00
Nikos Mavrogiannopoulos
cf0bca2cae radius: do not include NAS-Port via rc_aaa()
We were previously asking rc_aaa() to include NAS-Port pair to
the request which has undesirable results.

Resolves: #269

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-03-19 22:20:40 +01:00
Nikos Mavrogiannopoulos
3475e2b0fc Provide a special IPv6 route for iOS
When IPv6 is requested by iphone we provide a special route that is
necessary by these clients to use IPv6.

Resolves: #254

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-03-15 13:23:37 +01:00
Nikos Mavrogiannopoulos
881953c293 Merge branch 'tmp-test-psk-negotiate' into 'master'
Fix PSK-NEGOTIATE ciphers

Closes #262

See merge request openconnect/ocserv!147
2020-03-12 19:40:32 +00:00
Nikos Mavrogiannopoulos
f14385e1b4 worker-proxyproto: corrected type of data_size to avoid warnings in comparisons
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-03-12 19:47:50 +01:00
Nikos Mavrogiannopoulos
fb07fcca87 vpn.h: made sign of max_ban_score more appropriate
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-03-12 19:47:50 +01:00
Nikos Mavrogiannopoulos
449e608f86 str_replace_str: ensure types match for comparison
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2020-03-12 19:47:50 +01:00
Nikos Mavrogiannopoulos
370cc7cdf7 disable_system_calls: ensure gettimeofday is not a macro
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2020-03-12 19:47:50 +01:00
Nikos Mavrogiannopoulos
6b84d7e681 eliminate warnings when used for unit testing tests
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2020-03-12 19:47:50 +01:00
Nikos Mavrogiannopoulos
b0c885ca63 ocserv: fix PSK negotiation
This fixes a regression which prevented DTLS-PSK (or PSK-NEGOTIATE)
from being negotiated.

Resolves: #262

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2020-03-12 16:14:22 +01:00
Alan Jowett
780fbb89a0 Script needs access to additional client metadata.
Export more information to the script, including client device platform,
type and user agent.

Resolves: #256

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-03-11 09:13:55 +01:00
Alan Jowett
b43e782b12 Add support for RFC6750 bearer tokens to ocserv
This permits the validation of OpenID Connect auth tokens OpenID
Connect is an OAuth 2.0 protocol used to identify a resource owner
(VPN client end-user) to a resource server (VPN server) intermediated
by an Authorization server.

Resolves: #240

Signed-off-by: Alan TG Jowett <alan.jowett@microsoft.com>
2020-03-09 21:48:04 +01:00
Nikos Mavrogiannopoulos
a6c2d36952 Merge branch 'coverity_scan_defects' into 'master'
Fix issues flag by Coverity:

See merge request openconnect/ocserv!144
2020-03-05 19:26:32 +00:00
Alan Jowett
6d3b295b12 Fix issues flag by Coverity:
288530 Dereference after null check
288529 Array compared against 0

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-03-04 09:49:24 -07:00
Nikos Mavrogiannopoulos
31719b2cec main: no need to check nullity on an array
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2020-03-04 12:14:54 +01:00
Nikos Mavrogiannopoulos
e70573d9fc new_client_entry: prevent null pointer dereference
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2020-03-04 12:14:29 +01:00
Nikos Mavrogiannopoulos
85912c705e Fixed incorrect pointer arithmetic on configuration error
This addresses a crash on incorrect configuration.
Reported by Zero King <l2dy@icloud.com>

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-02-29 19:43:57 +01:00
Nikos Mavrogiannopoulos
31104c4de9 Merge branch 'issue251' into 'master'
ocserv-worker that fails to complete it's authentication should be killed

Closes #251

See merge request openconnect/ocserv!141
2020-02-28 21:41:39 +00:00
Alan Jowett
c9662282a1 Prevent tampering of our_ip, ip, session_start_time in SEC_AUTH_INIT from ocserv-worker to ocserv->sm and reject replay of auth_init_messages from old sessions.
Resolves: #252

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-02-28 11:20:30 -07:00
Alan Jowett
6518965129 CMD_BAN_IP should not use the IP address provided by worker process as it is not verified.
Resolves: #245

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-02-27 12:18:09 -07:00
Alan Jowett
bfa442379d ocserv-worker that fails to complete it's authentication should be killed
Resolves: #251

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-02-27 12:17:45 -07:00
Nikos Mavrogiannopoulos
12c69171a8 steal_ip_leases: reorg to avoid null pointer dereference
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2020-02-25 08:25:24 +01:00
Nikos Mavrogiannopoulos
cc651b9de5 Ensure scripts have all the information on all disconnection types
When a client re-uses a cookie and takes over a previous connection
previously the disconnect script of the old connection wouldn't receive
the IP information. Ensure that all information is provided to scripts
at this case.

Resolves: #231

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-02-23 13:44:19 +01:00
Nikos Mavrogiannopoulos
2932043dd9 Merge branch 'issue244' into 'master'
ocserv-main should limit the maximum message size a client can send

Closes #244

See merge request openconnect/ocserv!132
2020-02-20 16:47:52 +00:00
Nikos Mavrogiannopoulos
f333e600b5 Merge branch 'issue247' into 'master'
Resolves: #247 - Bound negotiated MTU between RFC 791 defined minimum and configured maximum.

Closes #247

See merge request openconnect/ocserv!135
2020-02-20 16:46:07 +00:00