Commit Graph
608 Commits
Author SHA1 Message Date
Nikos Mavrogiannopoulos 9c44e09356 ocserv-fw-nftables: replace ipcalc with pure-shell mask_to_prefix
ipcalc was used only to convert dotted-decimal subnet masks to CIDR
prefix lengths (e.g. 255.255.0.0 -> 16), replaced with a POSIX shell
script.

Relates: #709

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-02 17:21:38 +02:00
Nikos Mavrogiannopoulos e7d79e232d radius-auth: fix Framed-IPv6-Prefix routes being silently dropped
When processing a RADIUS Access-Accept with Framed-IPv6-Prefix, the code
passed the wrong value for it. Corrected by passing the actual prefix.

Fixes: #710

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-01 16:31:38 +02:00
Grigory Trenin a79e2f1cd5 Respect tunnel-all-dns in per-user/group config
Ensure that 'tunnel-all-dns' setting is honoured when overridden
in user or group-specific configuration files.

Resolves: #708

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-26 21:05:06 -04:00
Nikos Mavrogiannopoulos 139ff827d9 config: restructure per-vhost configuration for clarity and maintainability
Introduce a protobuf-generated ReloadableConfig (cfg.proto) to hold all
fields that reload on SIGHUP, and separate them from static_cfg_st, which
holds fields that require a server restart.  Named vhosts inherit from the
default vhost via a pack/unpack round-trip. Adding a new config field
only requires editing cfg.proto.  Struct and accessor names (ReloadableConfig,
static_cfg_st, GETRCONFIG, GETSCONFIG) now reflect each field's lifetime.
A new unit test covers the full inheritance path.

Resolves: #705

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-22 20:29:15 +02:00
Grigory Trenin eddd29f59b Do not forward UDP until client is authenticated
Do not forward DTLS packets until the client is authenticated to
prevent the race between AUTH_COOKIE_REP and CMD_UDP_FD messages
on the command socket.

Closes #706

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-21 07:06:59 -04:00
Nikos Mavrogiannopoulos da90b76b07 bumped versions
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-17 00:08:27 +02:00
Nikos Mavrogiannopoulos c520accb84 Released 1.4.2
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-16 23:27:59 +02:00
Nikos Mavrogiannopoulos 5d0a4dadc4 NEWS: documented updates
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-16 22:53:37 +02:00
Nikos Mavrogiannopoulos d3eceef085 Merge branch '64bit-timestamps' into 'master'
protobuf: use 64-bit signed integers for timestamp fields

See merge request openconnect/ocserv!506
2026-04-14 19:03:05 +00:00
Grigory Trenin cde58c22be protobuf: use 64-bit signed integers for timestamp fields
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-14 13:59:05 -04:00
Grigory Trenin db125634b8 Allow using no-udp option in vhosts
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-14 13:26:32 -04:00
Nikos Mavrogiannopoulos 4a0a087996 config: align default values with sample.config
Several options had hardcoded or named defaults in apply_default_conf()
that diverged from the values documented in doc/sample.config, leading
to silent behaviour differences for servers running without explicit
configuration.

Relates: #680

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-14 18:57:45 +02:00
Nikos Mavrogiannopoulos 611eb00527 config: add scope annotations and validation script
Add machine-readable [scope: X] annotations to doc/sample.config and
src/vpn.h struct fields to document which config options are permanent,
global-only, per-vhost, or per-user/group overridable.

Scope vocabulary:
  global (non-reloadable)  -- in perm_cfg_st; requires restart; cannot differ per vhost
  vhost (non-reloadable)   -- in perm_cfg_st; requires restart; can differ per vhost
  global            -- in cfg_st; reloadable; cannot be set in [vhost:] sections
  vhost             -- in cfg_st; reloadable; can differ per vhost
  vhost user        -- in cfg_st; reloadable; also overridable per user/group

Add tests/check-config-scope.py: a script that cross-checks the annotations
against the actual code:
  (a) every option in sample.config has a [scope:] annotation
  (b-c) [global] options match error_on_vhost() calls in config.c
  (d-e) [vhost user] options match handlers in src/sup-config/file.c
  (f) every field in cfg_st and perm_cfg_st has a [scope:] comment

Also fix a pre-existing bug in src/sup-config/file.c: the tunnel-all-dns
option was compared using an underscore ("tunnel_all_dns") instead of
the correct dash ("tunnel-all-dns"), silently ignoring the per-user
setting.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-14 18:57:45 +02:00
Nikos Mavrogiannopoulos 62a5f72864 DPD time: corrected duplicate assignment and set value for mobile-dpd
Resolves: #680

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-14 18:57:45 +02:00
Nikos Mavrogiannopoulos db50c02cbd Merge branch 'tmp-radius-group-separator' into 'master'
radius: add group-separator option for OU= Class attributes

Closes #428

See merge request openconnect/ocserv!513
2026-04-10 04:29:39 +00:00
Grigory Trenin bf12b9fe9c Fix global option inheritance for virtual hosts
Ensure global options are properly copied to virtual hosts when not
explicitly specified.

This change also:
- Documents global options that cannot be overridden in virtual hosts.
- Adds a 'VIRTUAL HOSTS' section to the man page to clarify behavior.

Closes #698

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-09 20:20:45 -04:00
Nikos Mavrogiannopoulos 828fca691e radius: add group-separator option for OU= Class attributes
Freeradius deployments may send groups in the Class attribute using a
comma as separator (e.g. "OU=group1,group2") rather than the semicolon
that ocserv expects by default. Add a group-separator option to the
radius auth configuration to allow this to be changed:

  auth = "radius[config=...,group-separator=comma]"

Accepted values are 'semicolon' (default) and 'comma'. The literal
character is not accepted in the config syntax as it conflicts with the
key=value pair delimiter.

Resolves: #428

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-06 21:27:28 +02:00
Nikos Mavrogiannopoulos ebb34f6787 auth/plain: fix password retry and prevent username enumeration via timing
Corrected bugs that prevented a correct password from being accepted after
a wrong one in the same session:

- worker-auth.c: a stale webvpncontext SID cookie caused a reconnecting
  client to skip SEC_AUTH_INIT and jump directly to SEC_AUTH_CONT with
  a PS_AUTH_FAILED session, which sec-mod rejects.

- auth/plain.c: the 'failed' flag was sticky across retry attempts, so a
  correct password following a wrong one was still treated as failure.
  Refactored into 'unknown_user' (sticky, for timing protection) and a
  local 'wrong_pass' (fresh each call). crypt() is now always called
  regardless of whether the user exists to normalise response timing and
  prevent username enumeration.

Resolves: #323

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-03 13:55:07 +02:00
Nikos Mavrogiannopoulos 598bcf405e Added ocserv-fw for nftables
This also introduces a basic functional test for ocserv-fw.

Resolves: #397

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-29 16:55:12 +02:00
Nikos Mavrogiannopoulos 18401eb298 Replaced autoconf with meson build files
Resolves: #699

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-20 20:47:27 +01:00
Ivan Verbin a8730a6997 occtl: add terminate commands for session cookie invalidation
Add 'terminate user', 'terminate id' and 'terminate session' commands
to occtl that disconnect users and invalidate their session cookies,
preventing reconnection with cached credentials.

Short session IDs are resolved to full safe_id by fetching the cookie
list from sec-mod via CTL_CMD_LIST_COOKIES with prefix matching and
ambiguity detection. Active sessions trigger a warning before
invalidation.

Add integration tests for all three terminate commands.

Signed-off-by: Ivan Verbin <verbinivan@gmail.com>
2026-03-15 17:05:29 +03:00
Dimitri PapadopoulosandNikos Mavrogiannopoulos a309ecead0 llhttp: updated to latest version 9.3.1
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-03-02 08:19:50 +01:00
Nikos Mavrogiannopoulos 1cb1e5706f NEWS: clarified fix on authentication bypass
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-02 08:13:54 +01:00
Nikos Mavrogiannopoulos 38458a8305 prepare for 1.4.2
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-01 19:19:06 +01:00
Nikos Mavrogiannopoulos 7477c32ba5 NEWS: updated
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-02-28 11:47:15 +01:00
Dimitri Papadopoulos 32979e6519 updated to protobuf 1.5.2
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-01-30 00:55:46 +01:00
Dimitri Papadopoulos Orfanos ba19dcd3be Merge branch 'tmp-NEWS' into 'master'
Fix NEWS file

See merge request openconnect/ocserv!501
2026-01-30 01:53:08 +02:00
Nikos Mavrogiannopoulos e05485f008 Merge branch 'issue599' into 'master'
Fix session timeout bypass

Closes #599

See merge request openconnect/ocserv!489
2026-01-29 18:47:55 +00:00
Dimitri Papadopoulos Orfanos 360e4714e3 Merge branch 'bugfix/ban-json' into 'master'
occtl: Fix 'show ip bans' may produce invalid JSON (#683)

Closes #683

See merge request openconnect/ocserv!495
2026-01-26 09:16:47 +02:00
Dimitri Papadopoulos 842bccc283 Fix NEWS file
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-01-26 08:15:23 +01:00
Grigory Trenin fb41d4203d Fix session timeout bypass
- Fixes an issue #599 where the session timeout could be bypassed
  by reconnecting, such as through a laptop lid close/open cycle.
- Adds 'Session started at:' field to 'occtl show user' output.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-25 18:59:13 -05:00
Nikos Mavrogiannopoulos 882759092c Merge branch 'tmp-udp_port' into 'master'
Initialise udp_port using vhost config section

Closes #612

See merge request openconnect/ocserv!431
2026-01-25 17:30:35 +00:00
Nikos Mavrogiannopoulos d06e67d102 Merge branch 'tmp-inih' into 'master'
inih: updated to latest version r62

See merge request openconnect/ocserv!437
2026-01-25 17:01:47 +00:00
Grigory Trenin a644718fd7 Fix worker process title not being set
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-25 07:33:21 -05:00
Dimitri Papadopoulos 44d58a049c inih: updated to latest version r62
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-01-25 13:22:37 +01:00
Grigory Trenin 9cc0191236 occtl: Fix 'show ip bans' may produce invalid JSON (#683)
Modified the printing logic to use a 'comma-before' approach instead of
'comma-after'.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-23 12:54:43 -05:00
Grigory Trenin b080d7dd2b Rename min-reauth-time to ban-time (#676)
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-23 05:44:05 -05:00
Grigory TreninandNikos Mavrogiannopoulos 74ebc5ec8a Strip domain suffix from hostname
The hostname validation was rejecting any hostname containg a '.'
character (eg: 'MacBook-Air.local'). This was overly restrictive and
prevented the HOSTNAME environment variable from being populated for
a signifficant number of clients, particularly on macOS.

Strip the domain suffix from such hostnames instead of discarding them.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-11 09:15:14 +01:00
Grigory Trenin e40d735316 occtl: Fix column misalignment in ban command outputs
- Increase the width from 14 to 15 characters for 'show bans' and
'show ban points' commands. This ensures proper column alignment
for all valid IPv4 addresses.

- Reduce Score column to 10 characters since UINT_MAX is typically
10 digits.

- Remove unnecessary (unsinged int) cast since 'score' is an actual
unsigned int.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-04 13:32:51 -05:00
Nikos Mavrogiannopoulos 1837b5877d NEWS: updated for 1.4.1
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-01-04 15:11:37 +01:00
Nikos Mavrogiannopoulos 5f5ac6fe65 Released 1.4.0
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-01-04 14:41:44 +01:00
Dimitri Papadopoulos 79f8eb35f8 Don't forget to initialise udp_port for vhost
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-01-03 11:11:36 +02:00
Grigory Trenin 98015b1b24 Fix max_mtu calculation in server stats
proc->mtu was incorrectly compared against min_mtu instead of max_mtu

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-02 16:34:59 -05:00
Nikos Mavrogiannopoulos ef075f6b83 get_auth_handler2: update to reflect username and password ask
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-01-01 20:14:20 +01:00
Nikos Mavrogiannopoulos e12b278260 fixed typo
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-01-01 17:38:10 +01:00
Grigory TreninandNikos Mavrogiannopoulos 1893047e8f Fix irregular stats-report-time
Currently 'ocserv' sends session accounting statistics at irregular intervals.
For example, if 'stats-report-time' is set to 60, the actual intervals may vary
between 50, 60, 70, or even 80 seconds.  Moreover, these intervals are not
constant - they fluctuate arbitrarily with each statistics update.

This behavior was intentionally introduced to avoid worker processes acting
simultaneously in scenarios like server restarts, where all clients reconnect
at the same time, which could impose heavy load on the secmod process.

However, it causes issues for RADIUS servers that require accurate and
consistent timing.

Summary of changes:
 - Apply randomization only once when the timer is initially set up, affecting
   only the first timer firing.  All subsequent firings will occur at regular
   intervals relative to the first one.
 - Remove fuzzing from 'interim_update_secs'. This value originates either from
   RADIUS or from 'stats-report-time' and should not be altered.

Closes: #630

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-01 17:31:01 +01:00
Grigory TreninandNikos Mavrogiannopoulos 0f53e0d6d9 Communicate secmod address to worker after successful authentication
This ensures all subsequent worker communications reach the original
secmod instance that authenticated the client, enabling correct session
accounting after IP address changes.

Closes: #674

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 11:41:51 +01:00
Grigory TreninandNikos Mavrogiannopoulos afa34bbd10 Fix ban score reset logic
The previous condition for resetting a ban score was insufficient.
It failed to reset the score for a client that had just exited a ban,
and also incorrectly reset the score of a currently banned client,
causing premature unbans.

Closes: #678

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 11:24:19 +01:00
Grigory TreninandNikos Mavrogiannopoulos d15b2af4b2 Fix 'occtl show ip bans' showing expired ban entries
Added current timestamp comparison to ensure only active bans
are shown by 'occtl show ip bans'.

Closes: #675.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 10:54:16 +01:00
Grigory TreninandNikos Mavrogiannopoulos 1c31314df4 occtl: Fix missing column headers in 'show ip bans' output
Existing code used the loop index 'i == 0' to determine when to print
column headers. However, a 'continue' statement inside the loop could
skip the 'i = 0' iteration, causing the headers to never be printed.

Introduced a separate boolean 'header_printed' variable to track
whether headers have been printed.

Closes: #677

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 10:52:20 +01:00