Commit Graph
4271 Commits
Author SHA1 Message Date
Nikos Mavrogiannopoulos 14b5295e8f ocserv-core-dev: added root-cause-analysis protocol from promptkit
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-06-06 12:05:59 +02:00
Dimitri Papadopoulos 29cf2c93fb Handle RADIUS Access-Challenge State as bytes
`state` is a string we receive from the RADIUS server and we do not
parse but echo back.

According to RFC 2866, all strings we receive from the RADIUS server
are octet strings, not null-terminated strings:
	Note that none of the types in RADIUS terminate with a NUL (hex
	00).  In particular, types "text" and "string" in RADIUS do not
	terminate with a NUL (hex 00).  The Attribute has a length field
	and does not use a terminator.  Text contains UTF-8 encoded 10646
	characters and String contains 8-bit binary data.  Servers and
	servers and clients MUST be able to deal with embedded nulls.
	RADIUS implementers using C are cautioned not to use strcpy()
	when handling strings.

Therefore, ensure we treat `state` as a proper octet string rather
than a null-terminated string.

Resolves: #729

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-06-06 10:45:05 +02:00
Nikos Mavrogiannopoulos 0dafa7b005 tests: add regression test for pam_auth_deinit coroutine safety
Add test-pam-abort, which verifies that pam_auth_deinit() correctly
resumes a suspended PAM coroutine before calling pam_end().

The test posts a username-only HTTP request to trigger SEC_AUTH_INIT,
leaving the PAM coroutine suspended in PAM_S_WAIT_FOR_PASS while the
worker exits without sending a password.  The stale pre-auth entry is
cleaned up by the sec-mod maintenance cycle (driven by the new
sec-mod-db-cleanup-time config knob, set to 3 s in the test config).

Bug detection is provided by pam_abort_test.so, a small PAM module that
registers a pam_set_data() cleanup which calls abort() if pam_end() fires
while conv->conv() has not yet returned.  Without the fix, sec-mod would
abort and the subsequent authentication check would fail.

Relates: #741

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-06-06 08:12:13 +02:00
Nikos Mavrogiannopoulos bdb69162b4 pam: cleanup PAM session if user aborts during conversation
When a PAM conversation is open and the worker terminates, then
depending on the PAM module in use resources can remain in use
even after cleaning up of the used by coroutines memory. Address
this by gracefully terminating the conversation prior to cleaning
up.

Resolves: #741

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-06-06 08:12:13 +02:00
Nikos Mavrogiannopoulos 74ec165316 pam: increase coroutine stack to 8 MB and add guard page
Certain pam modules such as pam_sss with AD/Kerberos and multi-factor
authentication requires significantly more stack than the previous
1 MB limit.

On Linux, allocate the coroutine stack with mmap and place a PROT_NONE
guard page immediately below it.  This turns a stack overflow into an
immediate SIGSEGV rather than silent corruption of adjacent heap memory
to better detect similar cases.

Fixes: #657
Relates: #619

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-06-06 08:12:13 +02:00
Nikos Mavrogiannopoulos 0b11fdc5bf Merge branch 'tmp-fix-691' into 'master'
config: add syslog-facility option to allow routing logs independently

Closes #691

See merge request openconnect/ocserv!574
2026-06-05 12:50:03 +00:00
Nikos Mavrogiannopoulos f906b9cfbc ocserv.8.md: document that pid-file is available in config
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-06-03 19:53:21 +02:00
Nikos Mavrogiannopoulos 0f5c628048 config: add syslog-facility option to allow routing logs independently
ocserv always logged to the syslog daemon(3) facility, making it
impossible to route its messages separately from other daemons.
Adds a syslog-facility config key (and --syslog-facility CLI flag)
accepting daemon/user/auth/authpriv/local0-local7; defaults to daemon.

Resolves: #691

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-06-03 19:52:36 +02:00
Nikos Mavrogiannopoulos 708f42a455 CONTRIBUTING.md/AGENTS.md: require tests to be self-diagnosing
This is to enable agents bring good tests that can be debugged
easily.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-31 22:33:53 +02:00
Nikos Mavrogiannopoulos e01968060b ocserv: exit with error code on error
Relates: #615

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-31 22:32:20 +02:00
Dimitri Papadopoulos Orfanos 1d381c8c9b Merge branch 'tmp-which' into 'master'
tests: `which` → `command -v`

See merge request openconnect/ocserv!573
2026-05-31 19:05:28 +03:00
Dimitri Papadopoulos 34be9e368e tests: whichcommand -v
Use `command -v` instead of `which` because:
* It's built into the shell, avoiding an external dependency on the
  `which` package on Fedora 44.
* It works across all POSIX-compliant shells.
* It's standard across Linux distributions. For example, Fedora 44
  lacks the `which` package by default.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-31 14:17:33 +02:00
Nikos Mavrogiannopoulos 0e74eeffcc .triage-policies.yml: apply the wontfix label if closing automatically [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-31 13:11:20 +02:00
Nikos Mavrogiannopoulos 86fe12e989 .gitlab-ci.yml: removed unnecessary jobs from schedules [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-31 00:14:34 +02:00
Nikos Mavrogiannopoulos f0406217eb .gitlab-ci.yml: run and print debugging information [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-31 00:08:02 +02:00
Nikos Mavrogiannopoulos 7bf968617b .gitlab-ci.yml: do not depend our schedules on the coverity job
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-30 23:42:19 +02:00
Nikos Mavrogiannopoulos 9e46c9714e Merge branch 'tmp-LICENSE' into 'master'
Add LICENSE files of bundled sotware

See merge request openconnect/ocserv!562
2026-05-30 21:36:22 +00:00
Nikos Mavrogiannopoulos ce350a17e5 Merge branch 'tmp-llhttp' into 'master'
llhttp: updated to latest version 9.4.1

Closes #736

See merge request openconnect/ocserv!564
2026-05-30 21:28:00 +00:00
Nikos Mavrogiannopoulos bcc9d3bff7 .triage-policies.yml: close stale and unassigned issues
Automatically close issues that have been open for more than 6 months
without an assignee and without a linked merge request. Security-labeled
issues are excluded.

The motivation:

- Issues tend to stay open indefinitely under the implicit assumption that
  someone will eventually pick them up. In practice this rarely happens.
- The backlog keeps growing, making it harder to see what is actually
  being worked on.
- The number of contributors who turn an issue into a merge request is
  very small relative to the number of issues filed.
- The goal is to keep the issue tracker focused on work that is actively
  in progress, not as a wishlist.
- Hopefully this encourages a more active contribution culture: instead
  of "I have reported it, someone will pick it up", reporters are nudged
  to either own the fix or accept that it may not happen.

Resolves: #740
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-30 22:51:16 +02:00
Nikos Mavrogiannopoulos 0727bdbe1f worker: detect and handle errors in socket from main
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-30 22:49:07 +02:00
Nikos Mavrogiannopoulos 30f33ac9d1 tun_write/read were made macros in linux for write and read
This avoids an unnecessary function call.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-30 22:49:07 +02:00
Nikos Mavrogiannopoulos 2be9af605b tlslib: simplified by requiring gnutls 3.3.5
This removes the (unconditional) ZERO_COPY conditional.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-30 22:49:07 +02:00
Nikos Mavrogiannopoulos d3372cbcb4 worker: drain TUN in a burst loop to avoid per-packet epoll_wait()
Previously tun_watcher_cb() called tun_mainloop() exactly once per
libev wakeup and then returned, causing ev_run() to call epoll_wait()
again before the next packet.  At high packet rates the TUN device
stays continuously readable, so this wastes one epoll_wait() syscall
per packet (~20-30 µs each in the report) and keeps the worker nearly
idle while the TUN queue grows.  The result is severe packet loss on the
TUN→client path (74% loss reported at 900 Mbps in issue #423).

Fix by looping in tun_watcher_cb() up to TUN_BURST_MAX iterations before
yielding back to the event loop and making the tun fd non-blocking. That
resulted to a reorganization of tls_mainloop() / dtls_mainloop() via
parse_data() to queue packet when the tunfd isn't writeable.

Resolves: #423

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-30 22:49:07 +02:00
Nikos Mavrogiannopoulos f5231eab10 CONTRIBUTING.md: added rule on patches
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-26 13:06:55 +02:00
Dimitri Papadopoulos Orfanos f8ab3518f7 Merge branch 'tmp-733' into 'master'
Avoid infinite loop in BSD TUN fallback

Closes #733

See merge request openconnect/ocserv!557
2026-05-24 20:49:23 +03:00
Dimitri Papadopoulos d51e5b55c4 Avoid infinite loop in BSD TUN fallback
Fixes #733.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-24 18:10:24 +02:00
Nikos MavrogiannopoulosandDimitri Papadopoulos 8faa35d67a Merge branch 'tmp-736' into 'master'
Fix calculation of avg_auth_time acros sec-mod instances

Closes #736

See merge request openconnect/ocserv!560
2026-05-24 16:09:20 +02:00
Nikos Mavrogiannopoulos 0eb7313bca Merge branch 'tmp-736' into 'master'
Fix calculation of avg_auth_time acros sec-mod instances

Closes #736

See merge request openconnect/ocserv!560
2026-05-24 11:24:14 +00:00
Dimitri Papadopoulos 4b216473d5 Fix calculation of avg_auth_time across sec-mod instances
Resolves: #736

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-24 11:47:26 +02:00
Nikos Mavrogiannopoulos efd41d300f Merge branch 'tmp-711' into 'master'
Set `sa` before attempting to set `sa->sin6_family`

Closes #711

See merge request openconnect/ocserv!554
2026-05-24 09:22:08 +00:00
Nikos Mavrogiannopoulos 6b74546a1b Merge branch 'tmp-pcl' into 'master'
Always use the bundled PCL library

Closes #663

See merge request openconnect/ocserv!565
2026-05-24 09:21:42 +00:00
Dimitri Papadopoulos d91ace7c1d Always use the bundled PCL library
Linux distributions have stopped shipping the Portable Coroutine Library.
There always used the vendored code.

Fixes #663.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-23 17:43:36 +02:00
Nikos Mavrogiannopoulos 1b6e22246d Test proxy protocol parser with IPv6 packet
Relates: #711

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-23 14:52:01 +00:00
Nikos Mavrogiannopoulos ae021ecf58 Merge branch 'anyconnect-bye-packet' into 'master'
Handle AnyConnect BYE packet with reconnect intention (0x91)

Closes #732

See merge request openconnect/ocserv!555
2026-05-23 14:25:22 +00:00
Dimitri Papadopoulos cdfdc5b495 Add LICENSE files of bundled sotware
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-23 16:16:35 +02:00
Grigory Trenin 2ff4154159 Distinguish reason codes in AnyConnect BYE packets
Cisco AnyConnect clients may send a BYE packet with a 0x91 payload,
followed by ASCII text "Reconnecting the VPN tunnel."

Resolves: #732

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-05-23 08:36:18 -04:00
Nikos Mavrogiannopoulos e5894dba7d NEWS: doc update
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-23 07:43:46 +02:00
Nikos Mavrogiannopoulos 2dd5956317 dtls_send: fix hang and buffer overread on persistent GNUTLS_E_AGAIN
Same two bugs as cstp_send (issue #638): the retry passed the original
data_size instead of the remaining byte count, and GNUTLS_E_AGAIN caused
an unbounded sleep loop.  Apply the same poll()-based fix bounded by
DEFAULT_SOCKET_TIMEOUT.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-23 07:39:51 +02:00
Nikos Mavrogiannopoulos d2b78d48ca tests: add live reproducer for cstp_send() hang on frozen peer (issue #638)
Connects an openconnect client, floods ICMP traffic so the server
accumulates ICMP replies in cstp_send(), then freezes the client with
SIGSTOP to prevent the TCP receive buffer from draining.  Asserts that
the worker session disappears from occtl within DEFAULT_SOCKET_TIMEOUT
plus margin, which would never happen with the old infinite retry loop.

Relates: #638

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-23 07:39:51 +02:00
Nikos Mavrogiannopoulos 35e3d15a11 cstp_send: fix worker hang and buffer overread on TLS send
A worker could get permanently stuck when a client disappeared silently
(e.g. iOS roaming between WiFi and cellular): the TLS send loop retried
indefinitely on GNUTLS_E_AGAIN with no deadline, requiring SIGKILL to
recover.

A separate bug caused a buffer overread on partial sends: the retry used
the original data_size instead of the remaining byte count, so the send
pointer advanced past the end of the caller's buffer.

Resolves: #638

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-23 07:39:51 +02:00
Nikos Mavrogiannopoulos bb9bcd7461 main: remove cgroup support in favour of systemd resource controls
Native cgroup placement is removed. Delegating resource enforcement
to systemd eliminates the privileged /sys/fs/cgroup writes from
the main process and simplifies the code.

Administrators who previously relied on the 'cgroup' option should use
the [Service] section of the ocserv unit file instead; see
systemd.resource-control(5) for details.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-23 07:09:23 +02:00
Nikos Mavrogiannopoulos 25861ab602 Merge branch 'tmp-nettle4' into 'master'
Build against GNU Nettle 4

Closes #697

See merge request openconnect/ocserv!553
2026-05-21 06:35:54 +00:00
Nikos Mavrogiannopoulos 788b1a2b30 Merge branch 'tmp-fix-716' into 'master'
worker: stop HTTP parser at message boundary to prevent request pipelining confusion

Closes #716

See merge request openconnect/ocserv!549
2026-05-21 06:34:06 +00:00
Dimitri Papadopoulos d95d1ac53e Consistency for readability
Consistency across IPv4 and IPv6 paths. Set `sin_addr` first and then `sin_port`.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-19 23:22:37 +02:00
Dimitri Papadopoulos 550e9327cc Set sa before attempting to set sa->sin6_family
Fixes #711.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-19 23:22:34 +02:00
Dimitri Papadopoulos b97aa4d97f Build against GNU Nettle 4
Fixes #697. Follow-up of !535 / 82572986.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-19 21:23:03 +02:00
Nikos Mavrogiannopoulos 583f0c0be5 worker: fix ICMPv6 misclassification as data traffic affecting idle-timeout
ICMPv6 was never excluded from idle-timeout accounting because is_data()
inspected data[9] for both IPv4 and IPv6.  Offset 9 is the Protocol field
in the IPv4 fixed header (RFC 791), but the Next Header field in the IPv6
fixed header sits at offset 6 (RFC 8200 §3).  As a result, the idle timer
was reset on every ICMPv6 packet, preventing the server from disconnecting
clients that were sending only control traffic.

Resolves: #724
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-19 20:14:21 +02:00
Nikos Mavrogiannopoulos bf23e0d549 /svc handler: add the owasp headers for consistency
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-19 20:11:33 +02:00
Nikos Mavrogiannopoulos e567f92e64 Removed unnecessary CA and certificate handlers
This removes certificate and CA handlers not used by the openconnect
client. This is a hardening measure to further reduce the attack surface
of the worker process.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-19 20:11:33 +02:00
Nikos Mavrogiannopoulos 2dfb9acec5 Updated instructions for AI agents reporting vulnerabilities
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-19 16:57:44 +02:00