Commit Graph
19945 Commits
Author SHA1 Message Date
Tobias Brunner be4b9f4aaa xauth-pam: Properly initialize response array when handling sessions
This is documented as a requirement in the man page, so the caller of the
conversation function might expect such an array.  Although, since we
only accept non-interactive requests, for which no response is expected,
it's doubtful whether it will actually try to access elements in the
array.  And if the passed pointer was initialized to NULL, passing it to
free() is probably also fine.

Fixes: 2312504d1e ("xauth-pam: Open/close a PAM session for each connected client")
2026-07-24 08:47:36 +02:00
Tobias Brunner 66f0f3a599 kernel-netlink: Add some safety checks when printing extended error messages
The previous code could potentially cause out-of-bound reads.

Fixes: 7988aea7d8 ("kernel-netlink: Log extended ACK error/warning messages")
2026-07-24 08:47:36 +02:00
Tobias Brunner b52fc6c284 stream-service: Avoid race condition when accepting sockets
Even if `poll()` indicates that the socket is ready it might block if
it's in blocking mode. This change avoids blocking in such cases (accept
will fail with EAGAIN/EWOULDBLOCK and `watch()` will return TRUE).

As the non-blocking mode is inherited on Windows (on Linux, the man page
documents the non-inheritance as a Linux specialty), we set the mode for
the accepted socket explicitly to blocking to match the expectations of
`stream_t`.

Fixes: daf1880b39 ("stream: add a stream service class abstracting services using BSD sockets")
2026-07-24 08:47:36 +02:00
Tobias Brunner c3b99c6982 ip-packet: Properly skip IPv6 fragment headers
Only skip the header, the `ip6e_len` field is reserved in these headers
and does not represent the length (I guess it's usually 0, but still).

Fixes: bdcaca76c5 ("ip-packet: Correctly determine protocol in fragmented IPv6 packets")
2026-07-24 08:47:36 +02:00
Tobias Brunner 2eeb8965ed pkcs11: Fix ECDH derivation
The referenced commit moved the key derivation to `get_shared_secret()`
and broke the handling of ECDH public value as the copied struct now
referred to a buffer allocated on the stack.

Also fixes potential session leaks if generating key pairs fails.

Fixes: 26ca0c9f70 ("pkcs11: Move shared secret calculation to get_shared_secret()")
2026-07-24 08:47:36 +02:00
Tobias Brunner 75baeb9f35 constraints: Fallback to binary OIDs in log messages
Similar to the previous commit.
2026-07-24 08:47:36 +02:00
Tobias Brunner a5d815a6ef certificate-printer: Fallback to binary OID printing for policy mappings
This is the same fallback already used when printing the certificate
policies.

Fixes: 3317d0e77b ("Standardized printing of certificate information")
2026-07-24 08:47:35 +02:00
Tobias Brunner 502fa14536 asn1: Reject OIDs with too large sub-identifiers when converting to string
The shift would overflow the value which could produce garbage output
that might get interpreted as real OIDs (in case strings are compared).

This limit allows OID sub-identifiers to consist of at most 4 bytes,
which should be enough for any real-world OIDs (it's also the maximum we
used in tests so far).

Fixes: f813069e89 ("fixed asn1_oid_to_string() conversion")
2026-07-24 08:47:35 +02:00
Tobias Brunner dafb082ae0 libtls: Check padding and MAC in constant time
Seems difficult to exploit when wrapped in EAP/IKEv2, and the keys for
those TLS sessions are short-lived anyway.

Fixes: c0bf721357 ("tls: Check all bytes of the padding if they equal the padding length")
2026-07-24 08:47:35 +02:00
Tobias Brunner 1372335d30 constant-time: Add 64-bit versions of the helpers
While we could use _Generic() C11 expression to let the compiler select
between the different versions, this only allows selection based on one
of the arguments, which seems a bit fragile.  So make this explicit for
now.  In the future we might consider using the overloadable attribute.
2026-07-24 08:47:35 +02:00
Tobias Brunner db3f4c2955 eap-radius: Avoid NULL-pointer dereference in XAuth backend
Fixes: c434b2a4a9 ("eap-radius: support plain XAuth RADIUS authentication using User-Password")
2026-07-24 08:47:35 +02:00
Tobias Brunner 9965a64723 ike-me: Fix safety check to ensure peer ID payload in ME_CONNECT request
The presence of a peer ID is enforced by the message rules for ME_CONNECT,
this just mirrors the safety check also present in `process_r_ms()`.

Fixes: d5cc175833 ("experimental P2P-NAT-T for IKEv2 merged back from branch")
2026-07-24 08:47:35 +02:00
Tobias Brunner 4feb31d0e6 tls-peer: Fix memory leak when processing Finished messages with TLS 1.3 fails
Fixes: 7a2b02667c ("libtls: Implement TLS 1.3 handshake on client-side")
2026-07-24 08:47:35 +02:00
Tobias Brunner be0ee2e806 tls-server: Fix memory leaks when processing certificates or Finished messages
Fixes: 7fbe2e27ec ("tls-server: TLS 1.3 support for TLS server implementation")
Fixes: d2fc9b0961 ("tls-server: Mutual authentication support for TLS 1.3")
Fixes: 760f3b730f ("tls-server: Add flag that makes client authentication optional")
2026-07-24 08:47:35 +02:00
Tobias Brunner b031cd27a8 connmark: Fix addresses when removing policies in ike_update() handler
These were never correct.  And the first referenced commit, unfortunately,
just simplified the incorrect code.

Fixes: 08a3ee0cce ("bus: Change ike_update() signature and only call it once")
Fixes: b8973b2661 ("connmark: Add CONNMARK rules to select correct output SA based on conntrack")
2026-07-24 08:47:35 +02:00
Tobias Brunner fe6dc7d256 af-alg: Fix output offset if not all data was processed during en-/decryption
If only parts of the total data could be written to the kernel, the result
of the next read chunk would incorrectly get written at the beginning of
the output buffer again.

Also makes sure to close the accepted FD in error cases.

Fixes: 1b5de7ce3b ("Use a generic AF_ALG wrapper for common operations")
2026-07-24 08:47:35 +02:00
Tobias Brunner 289d776904 dhcp: Make sure to only modify transactions after receiving an expected DHCP OFFER
The `transaction` variable was previously still set to the one that
was enumerated last even if the received DHCP OFFER did not match
it.  So the transaction was incorrectly modified.  Once the real
DHCP OFFER would arrive, it would get modified again, but it could
allow adding unintended DNS servers.
2026-07-24 08:47:35 +02:00
Tobias Brunner 8c696dc90a proposal-substructure: Avoid unaligned memory access when reading SPI 2026-07-24 08:47:35 +02:00
Tobias Brunner d13b384536 byteorder: Add helpers to read from unaligned addresses without byte order changes
While utoh32/64 would also have been an option for the name, this is
more distinct to avoid confusion with the existing conversion functions.
2026-07-24 08:47:35 +02:00
Tobias Brunner d19591edda charon-tkm: charon: Avoid potential TOCTOU issues when accessing/writing PID file
Same as the previous commit.
2026-07-24 08:47:35 +02:00
Tobias Brunner 18a104657e charon: Avoid potential TOCTOU issues when accessing/writing PID file
The previous code could potentially truncate and change ownership of
a file that's a symlink to an unintended target file (requires the
attacker to be able to create the symlink in the directory the PID file
is located, which generally requires root privileges).
2026-07-24 08:47:35 +02:00
Tobias Brunner 7bf9b6bad8 x509: Avoid memory leak if multiple nonce extensions are found in OCSP response 2026-07-23 10:26:08 +02:00
Tobias Brunner 7a316d9159 kernel-libipsec: Remove exclude route (reference) if route is updated
Fixes: 587bdf8768 ("kernel-libipsec: Track policies and automatically install routes")
2026-07-23 10:26:08 +02:00
Tobias Brunner e36a8c0d62 kernel-pfkey: Remove exclude route (reference) if route is updated
Fixes: df919d50d0 ("kernel-pfkey: install exclude routes if kernel-net requires them")
2026-07-23 10:26:08 +02:00
Tobias Brunner cef4bce3e1 controller: Properly notify waiting thread after INVALID_KE_PAYLOAD retry failed
When initiating a Child SA with a CREATE_CHILD_SA exchange, the initial
exchange could fail with an INVALID_KE_PAYLOAD notify.  The initiation
would then get retried from scratch (the `child_sa_t` object is destroyed
and a new one created).  If it fails again, the previous code didn't
signal the waiting thread.  If it did not set a timeout, it would wait
indefinitely.

Using a different `status_t` value avoids any confusion with NEED_MORE
that's used to indicate that the callback returned FALSE (e.g. if the
IKE_SA would go down before concluding the retry).

Fixes: c39b0c883d ("controller: Keep following initiate() if the first DH guess was wrong")
2026-07-23 10:26:08 +02:00
Andreas Steffen a885a3da60 pts: Verify PCR info during verification and reject mismatches
Replace `set()` with `extend()` in verify methods so the PCR value is
independently computed rather than taken from the evidence.
Also make `pcr_before` mismatch a hard failure instead of a warning.
2026-07-23 10:26:08 +02:00
Tobias Brunner e1609d8159 forecast: Make BPF statements for metadata reads clearer
The kernel ignores the width of these metadata loads, but since we read
32-bit values, this makes it a bit clearer and technically more correct.
2026-07-23 10:26:08 +02:00
Tobias Brunner 7e7c2805df identification: Avoid truncating identities created from data blobs
This is not necessarily an issue, but we should avoid not using the
full identity data as best as possible.  The change also avoids the
dynamically sized buffer on the stack.

Fixes: 324528700d ("Added identification constructor using a chunk of data, guessing id type")
2026-07-23 10:26:08 +02:00
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