20067 Commits
Author SHA1 Message Date
Tobias Brunner 45b2f8d91f revocation: Avoid that a skipped CRL lookup/fetch prevents fetching delta CRLs
If we find a stale CRL in the cache and finding a newer one via
CRLIssuer fails for some reason, the validation state would get
overwritten with VALIDATION_SKIPPED.  This would then prevent
fetching delta CRLs.

Fixes: 7d7beaa1fa ("Use certificate CRLIssuer information to look up cacched CRLs or CDPs")
2026-07-23 10:26:08 +02:00
Tobias Brunner 8323fbaee7 eap-peap: Don't allow authenticated client to skip EAP-TNC with unexpected EAP-SUCCESS
EAP-PEAP transports results as separate AVPs, we expect one after the
first phase 2 authentication (if not using certificates).  However, with
the previous caching of the result of that, the client could then send
another confirmation as response to the EAP-TNC request to skip it.
Since no group membership is set if EAP-TNC is not complete, it shouldn't
really affect its outcome, though.

Fixes: 1be296dfb2 ("implemented the PEAP tunneling protocol as an EAP plugin")
2026-07-23 10:26:08 +02:00
Tobias Brunner 4110d2795a windows: Avoid unnecessarily locking the global thread lock when removing TLS
Holding the lock could potentially cause a deadlock depending the
behavior of the called cleanup functions.  The TLS removal happens in
the context of the respective thread, so no locking is necessary.

Looks like removing these lines was missed when the referenced commit
partly reverted 204098a752 ("thread-value: Immediately cleanup all
Windows TLS values on destroy"), which added the locking originally.

Fixes: 23750961d5 ("thread-value: Defer cleanup handling to thread termination on Windows")
2026-07-23 10:26:08 +02:00
Tobias Brunner 097c7a1e0a process: Correctly read last path character on Windows
Fixes: 7dd06d274d ("process: Add a wrapper to invoke a command under the system default shell")
2026-07-23 10:26:08 +02:00
Tobias Brunner 6dfebcede5 radius-socket: Fix timeout handling when waiting for responses
In case messages with unexpected IDs are received, the previous code
would always wait for the full timeout again.
2026-07-23 10:26:08 +02:00
Tobias Brunner 67bf0051c4 android: Fix memory leaks in DNS proxy
Fixes: 2dc26c557e ("android: Add DNS proxy implementation")
2026-07-23 10:26:08 +02:00
Tobias Brunner 5e51fc7902 tnc-pdp: Fix lock type when adding/replacing a connection
The entry was updated and the previous EAP method and IKE SA destroyed
under a read lock, which is not safe (there could be threads in
get_state(), or even some that called it before and now still hold
that read lock while interacting with the EAP method).

Fixes: 37884ab10f ("Add locking to TNC-PDP connections")
2026-07-23 10:26:08 +02:00
Tobias Brunner dc8fa5fea5 tnc-pdp: Don't remove watcher callbacks on failures 2026-07-23 10:26:08 +02:00
Tobias Brunner 2cea90423a ipsec-sa-mgr: Delete pre-allocated SPI if creating CHILD_SA fails
Fixes: 914479370e ("Added IPsec SA manager")
2026-07-23 10:26:08 +02:00
Tobias Brunner 87f0bc2a6c cert-cache: Fix race conditions when inserting CRL/OCSP
Because no lock was held while comparing the type of the already stored
cache entry, it was theoretically possible that a NULL-pointer dereference
or use-after-free was caused if another thread concurrently replaced the
stored certificate.

While the cached type is also read without lock, the worst that can
happen is that we acquire the lock of an entry that doesn't match
eventually.  The double check actually uses the stored certificate,
just in case the cached value gets out of sync due to a future
refactoring.

Fixes: 2271ebb325 ("Newer CRLs replace older versions of the CRL in the cache")
Fixes: 47e8b21c76 ("cert_cache: Replace cached stale OCSP responses in-place")
2026-07-23 10:26:08 +02:00
Tobias Brunner bff18d9048 tls-protection: Reject unencrypted TLS 1.3 records
We only allow unencrypted change_cipher_spec records (as before), which
are handled by the upper layers accordingly.  Without the check, we
also accepted unprotected alerts and handshake records that could
potentially cause state confusion.

Fixes: 7a2b02667c ("libtls: Implement TLS 1.3 handshake on client-side")
2026-07-23 10:26:08 +02:00
Tobias Brunner cfc72fe901 eap-aka-3gpp2: Fix SQN generation
Same as the previous commit.

Fixes: 424ddf801c ("Do not use monotonic time for AKA sequence numbers, it has an undefined starting point")
2026-07-23 10:26:08 +02:00
Tobias Brunner 371c35612c eap-aka-3gpp: Fix SQN generation
As `tv_sec` is a `time_t`, i.e. typically 64 bits, assigning the result
of `htonl()` leaves the upper 32 bits zero.  Copying from the
`sizeof(time_t) - 4` offset then copies those zeroes on little-endian
systems, which is not what was intended according to the comments.
Another issue was that the type of `tv_usec`, `suseconds_t`, is typically
a `long`, i.e. signed, so shifting the maximum value 0x000f423f (999'999)
by 12 bits technically overflows this.  The cast fixes that.

Fixes: 1aba82bfd7 ("eap-aka-3gpp: Add plugin that implements 3GPP MILENAGE algorithm in software")
2026-07-23 10:26:08 +02:00
Tobias Brunner eec3164b41 xauth-pam: Avoid race for multiple concurrent authentication attempts
The previously static pam_conv instance could get reused by multiple
threads, causing one to use the password of the other.
2026-07-23 10:26:08 +02:00
Tobias Brunner 4bef380ce0 eap-simaka-reauth: Prevent corrupting hashtables during concurrent accesses
Basically the same as the previous commit.

Fixes: edcb2dd35b ("Moved reauth/pseudonym functionality from eap-sim-file to separate plugins, usable by any SIM/AKA backend")
2026-07-23 10:26:08 +02:00
Tobias Brunner 0b5143ae04 eap-simaka-pseudonym: Prevent corrupting hashtables during concurrent accesses
This also protects access to the RNG, which is not always thread-safe.

Fixes: edcb2dd35b ("Moved reauth/pseudonym functionality from eap-sim-file to separate plugins, usable by any SIM/AKA backend")
2026-07-23 10:26:08 +02:00
Tobias Brunner e53e2c7ff6 eap-mschapv2: Remove retry after failed attempts
Due to the `sleep()` call, a continuous stream of failed authentication
attempts can potentially exhaust the thread pool.  While delays can also
happen due to RADIUS or DHCP on the server side, this can directly be
triggered by clients.  It's questionable whether the delay ever had the
intended effect.  But since the retry functionality is also quite
strange, let's just remove it so retries will require creating an IKE_SA
from scratch.  To avoid leaking much of a timing difference if no secret
is found now that the two second delay is gone, we do the calculations
with a dummy NT hash.

Fixes: f98cdf7a47 ("adding plugin for EAP-MS-CHAPv2")
2026-07-23 10:26:08 +02:00
Tobias Brunner 163e7bd6db tnccs_11: Fix memory leak if multiple Base64 tags are found 2026-07-23 10:26:08 +02:00
Tobias Brunner 0a9445a7c1 pt-tls-server: Fix leak if SASL authentication failed 2026-07-23 10:26:08 +02:00
Tobias Brunner dbaca2dffe pt-tls-server: Properly fail if processing PB-TNC batches failed
Because `assess()` returns a `status_t`, `FALSE` is interpreted as
`SUCCESS`. So a failure while processing PB-TNC batches terminated
the process successfully.

Fixes: 1e92d5f114 ("Process PB-TNC batches received via PT-TLS asynchronously")
2026-07-23 10:26:08 +02:00
Tobias Brunner 355d591967 openssl: Fix memory leak if HMAC instantiation fails late
Fixes: db0c53c207 ("openssl: Fixes for HMAC with OpenSSL 3.0")
2026-07-23 10:26:08 +02:00
Tobias Brunner 3a30390d91 kernel-wfp: Fix remote port in traffic selectors in acquires
Fixes: c6f189e448 ("kernel-wfp: Add support for trap policies and acquires")
2026-07-23 10:26:08 +02:00
Tobias Brunner 9598de465c unit-tests: Add tests to ensure our Curve25519/448 implementations don't return all-zero secrets
Note that wolfSSL before 5.9.2 required building with
WOLFSSL_ECDHX_SHARED_NOT_ZERO, which was added with 5.3.0, to get and
explicit check.  Since the plugin validates the public key, the test case
fails nonetheless.
2026-07-23 10:26:08 +02:00
Tobias Brunner 589a3a6729 curve25519: Reject all-zero shared secrets
While RFC 7748 states implementations MAY perform such a check, e.g.
TLS 1.3 explicitly requires it (RFC 8446, section 7.4.2).

Fixes: 7f9bfacd5a ("curve25519: Add a plugin providing Curve25519 DH using backend drivers")
2026-07-23 10:26:08 +02:00
Tobias Brunner 4436c12183 coupling: Avoid potential access by multiple threads to shared hasher
Using the same `hasher_t` instance from different threads concurrently
is not safe.  The underlying implementation might e.g. use a single
shared state for multiple API calls within `get_hash()` (e.g. the openssl
plugin does that).

Fixes: 007c47088c ("Implemented permanent certificate coupling plugin")
2026-07-23 10:26:08 +02:00
Tobias Brunner 0a53da7cd8 ita-comp-ima: Handle missing validation URI gracefully
Fixes: ab957aacce ("transport IMA file info via PTS Component Evidence Policy URI")
2026-07-23 10:26:08 +02:00
Tobias Brunner d9cf1b0bff wolfssl: Avoid potential RNG state corruption during RSA/ECDSA operations
The WC_RNG instances are potentially shared between different threads
as private key objects are refcounted.  This may corrupt their internal
state as they are not thread-safe.

For ECDSA, using separate instances for each signing operation has some
performance impact, but for signature operations that should be fine.

The implementation for RSA uses mutexes.  That's due to the weird API.
While RNG instances can be passed for signing and encryption (probably
because they are also required for padding/salt besides blinding), they
can't for verifying and decryption.  The latter use an RNG instance that
has to be set on the key object before calling these operations.  So we
could potentially split the strategy, but to keep this consistent within
the RSA implementation, just continue with the shared RNG but use a
mutex around the API calls.

Fixes: c92eade82c ("wolfssl: Add wolfSSL plugin for cryptographic implementations")
2026-07-23 10:26:07 +02:00
Tobias Brunner 05625acc2a wolfssl: Ensure X25519/X448 public key is valid 2026-07-22 18:20:12 +02:00
Tobias Brunner 1fe813f05e wolfssl: Fix memory leak on failed ICV verification if not using in-place decryption
Fixes: c92eade82c ("wolfssl: Add wolfSSL plugin for cryptographic implementations")
2026-07-22 18:20:12 +02:00
Tobias Brunner 023c626525 openssl: Fix memory leak on failed ICV verification if not using in-place decryption
Fixes: 81f9cd39fd ("openssl: Provide AES-GCM implementation")
2026-07-22 18:20:12 +02:00
Tobias Brunner c6adb20ec7 chapoly: Fix memory leak on failed ICV verification if not using in-place decryption
Fixes: 370fb3feb0 ("chapoly: Provide a generic ChaCha20/Poly1305 AEAD supporting driver backends")
2026-07-22 18:20:12 +02:00
Tobias Brunner 85c02dc16c ccm: Fix memory leak on failed ICV verification if not using in-place decryption
Fixes: 80a93a1335 ("Implemented a ccm plugin providing CCM mode based on CBC crypters")
2026-07-22 18:20:12 +02:00
Tobias Brunner 40aa0a12c4 botan: Fix memory leak on failed ICV verification if not using in-place decryption
Fixes: af26cc4d85 ("botan: Add Botan plugin to libstrongswan")
2026-07-22 18:20:12 +02:00
Tobias Brunner a2f83d3075 aesni: Fix memory leak on failed ICV verification if not using in-place decryption
The `aead_t` interface states that `decrypt()` only allocates a plaintext
buffer if successful, so callers might not free it if the call failed.

Fixes: 313811b72d ("aesni: Add a GCM AEAD based on the AES-NI key schedule")
2026-07-22 18:20:12 +02:00
Tobias Brunner dae65dd492 esp-packet: Fix leak and avoid one if AEAD implementations misbehave
If an `aead_t` implementation incorrectly allocates memory if the
decryption/ICV verification failed, this avoids a leak.  Unfortunately,
many implementations actually did that.

Fixes: 24a8d1253f ("libipsec: Wrap traditional algorithms in AEAD wrapper")
2026-07-22 18:20:12 +02:00
Tobias Brunner f5aeba0f02 watcher: Remove unnecessary pending flag
This was added with 5ce3c9b15a ("watcher: Rebuild fdset when select()
fails"), i.e. before switching to poll(), solely to suppress errors when
FDs are closed and select() would return with an error.  With poll()
this should not happen result in an error (it potentially indicates this
via POLLNVAL in revents of that FD in the array).

Because the flag was not consistently changed/read with the mutex held,
some analysis tools got confused and imagined wild deadlock scenarios.
2026-07-21 10:37:43 +02:00
Tobias Brunner 87bbfe4f5f gcm: Implement block multiplication in constant time 2026-07-21 10:37:43 +02:00
Tobias Brunner 577d4d16f6 charon-tkm: Document that public_key_t::verify() is a dummy implementation 2026-07-21 10:37:43 +02:00
Tobias Brunner bdbdd46941 medsrv: Add missing return to avoid infinite loop while verifying username 2026-07-21 10:37:43 +02:00
Tobias Brunner fcac9fe5df tls-socket: Avoid accessing stale data when processing application data
In non-blocking mode, the previous code set `in_done` to -1 (SIZE_MAX)
if `recv()` would block and nothing was read yet.  If this was followed
by a call to `write()` and `process()` is called and actually processed
application data, the length calculation in the callback underflows and
`memcpy()` would write to `in.ptr + SIZE_MAX`.  Since `read()` already
sets `errno` to `EWOULDBLOCK` and returns -1 if `in_done` is 0, the
removed check was redundant anyway.

Also, the buffer from the previous `read()` call might not be valid
anymore when `write()` is called (e.g. `splice()` uses the same buffer
for both, and the buffer could even be defined on a now invalid stack
frame of the function that called `read()` previously).  Clearing the
data avoids that and ensures the application data is cached until the
next call to `read()`.

However, triggering this is rather difficult as `write()` should only
reach `recv()` while the handshake isn't complete and until then
`process_application()` doesn't accept application data.  But if the
handshake is completed during a call to `write()` that follows a
non-blocking read and data immediately arrives, it's theoretically
imaginable.  This scenario is highly unlikely on a TLS server, which
starts the process with a call to `read()` that then basically loops
until the handshake is done.  Even if multiple calls are required, the
server will generally not call `write()` before it received application
data.  And any calls to `write()` afterwards do not reach `recv()`
anymore (unless no data to send was passed, which would be weird, or
maybe for some weird corner case that lets `build()` fail before all
outbound application data was processed).
2026-07-21 10:37:43 +02:00
Tobias Brunner b3c0019c84 pgp: Fix validity calculation and potential overflow
The two fields were swapped in the calculation and the new code also
avoids overflowing on 32-bit systems.

Fixes: 4cb0e1bb76 ("Added basic support for PGP certificates (no trust relationships yet)")
2026-07-21 10:37:43 +02:00
Tobias Brunner 3582906332 github: Disable SonarQube's (beta) taint analysis
This does not seem to work on these runners.  Tried setting
dataflowMemoryLimit, but that only seems to affect the analysis (which
causes a warning: "Taint analysis was stopped early due to low memory.
The analysis may not have explored the whole program.") not the
post-processing that evidently causes the runner to get killed due to
OOM (there is no explicit error, but in the debug log we see "The runner
has received a shutdown signal", which apparently can indicate OOM
issues).
2026-07-21 10:21:51 +02:00
Tobias Brunner 33917415df github: Use tpm2-tss 4.2.0 for tests 2026-07-21 10:21:51 +02:00
Tobias Brunner 4eb3391801 github: Use AWS-LC 5.3.0 for tests 2026-07-21 10:21:51 +02:00
Tobias Brunner 6894b33e6d child-create: Don't fail creating IKE SA if only Child SA installation fails
Fixes: d7760416d6 ("child-create: Add support for multiple key exchanges")
2026-07-21 10:21:51 +02:00
Tobias Brunner 8cd4ac9f53 github: Use latest SonarQube action 2026-07-21 10:21:51 +02:00
Tobias Brunner 24c70db4b9 aesni: Split plugin to avoid potential SIGILL
Because the CFLAGS applied to the whole plugin, the compiler could
"optimize" the boilerplate plugin code, which could then cause a SIGILL
on hardware that doesn't support such instructions.  This change makes
sure only the actual AES implementation is compiled like that, which
would then not get registered depending on the CPU feature detection.
2026-07-21 10:21:51 +02:00
Tobias Brunner 9d5e619e19 ha: Make receive buffer size for the HA socket configurable
If there are lots of SAs to be synced, the default might be too low
and messages and SAs get dropped.  The new default is already 8 MiB,
which should work fine for lots of SAs.  The code mirrors the one in
the kernel-netlink plugin (but with a guard around SO_RCVBUFFORCE, even
though this plugin is mostly used on Linux as well).
2026-07-21 10:21:51 +02:00
Tobias Brunner 3ef091815f testing: Run test scripts in a subshell so we can properly cancel them
This fixes handling of SIGINT (CTRL+C) so we don't continue with the
next potentially hanging command (e.g. several pings after another that
fail because a required SA didn't come up correctly).  We try to kill
the PID for every SIGINT in case the first one arrived before the
subshell was started.  The `TDUP_<host>` variables are not updated in
the main shell when `stop_tcpdump` is called from the subshell, so
it is called redundantly during the cleanup (removed the useless guard
there and use pkill to suppress any messages if no process is found).

If we get interrupted during one of the init/cleanup WAIT_FOR waits,
we just let them running in the background when exiting the script.
They should generally not do any harm (and be terminated once the next
run is attempted, which might require a rebuild during development
anyway).

Since a103f3a284 ("testing: Add options to only run pre- or posttest
scripts of a scenario") we can now also skip the remaining steps easily.

However, we do run the posttest script to clean up properly (e.g.
terminate the daemons, restore firewall rules etc.).  That's also why
it's not running in a subshell.
2026-07-06 19:01:19 +02:00
Tobias Brunner fa56cca73b testing: Format link to test results as OSC 8 hyperlink
Useful for terminals that support these (but maybe don't parse URLs
automatically).
2026-07-01 09:28:07 +02:00