Commit Graph
4797 Commits
Author SHA1 Message Date
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 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 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 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
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 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 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 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 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 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 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 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 02ade69543 vici: Update supported Python versions
Debian bullseye still ships 3.9, while Alpine and newer Ubuntu releases
ship 3.14.
2026-06-29 17:45:29 +02:00
Tobias Brunner 4df53109a5 eap-aka: Make sure AT_RAND has the correct length in AKA-Challenge
This prevents an OOB read if the AT_RAND data is shorter than the
expected 16 bytes.

The check for AT_AUTN is changed for consistency even though its length
is already enforced by the parser (for AT_RAND it isn't because EAP-SIM
expects a length of either 32 or 48 bytes).

Fixes: aea334ec1c ("Splitted EAP-AKA in peer and server implementations, use libsimaka helper library")
2026-06-04 11:31:11 +02:00
Tobias Brunner a904f9125d kernel-netlink: Enable mixed-family IPComp scenarios
Since 6.3, the kernel allows setting XFRM_STATE_AF_UNSPEC for transport
mode SAs, which allows mixed-family use of IPComp.
2026-06-04 11:22:58 +02:00
Tobias Brunner b3ef007d28 vici: Return proposals in a more structured way
This allows clients to distinguish between algorithms of different
transform types more easily.  The names are similar to those used
when returning the algorithms of the selected proposal in list-sas (except
for `ke` instead of `dh` and `sn` instead of `esn` to reflect the
latest IETF/IANA changes).
2026-05-28 14:40:25 +02:00
Mathijs Smit c70ab88363 vici: Include proposals in connection listings
Signed-off-by: Mathijs Smit <smit.mathijs@gmail.com>
2026-05-28 14:40:25 +02:00
Tobias Brunner eb9e44f783 ike-cfg: Add flag to suppress log message when retrieving proposals 2026-05-28 14:40:25 +02:00
Tobias Brunner 60adb95f58 child-cfg: Add flag to suppress log message when retrieving proposals 2026-05-28 14:40:25 +02:00
Tobias Brunner bff405c349 oid: Fix confusing identifiers for elliptic curves over prime fields
SECT (indicating a binary field) was incorrectly used in constants for
the SECP (prime field) curves.
2026-05-28 13:30:07 +02:00
Tobias Brunner dc8b479eb8 ike-init: Fix key derivation if SA is reset after IKE_INTERMEDIATE retransmits
Because the `derived` flag was not reset (it's set after the initial
IKE_SA_INIT exchange), no keys would get derived when sending
IKE_INTERMEDIATE during the next try.  As there is then no `aead_t`
available, encrypting the message would fail and the initiation would
remain stuck.

Fixes: 0d49ddec2e ("ike-init: Add support for multiple key exchanges")
2026-05-22 14:33:28 +02:00
Tobias Brunner ac703e48c3 ike-init: Destroy KE object after each derivation during initial exchanges
This fixes error handling in build_r_multi_ke() so we don't incorrectly
reuse the object from the previous exchange if we don't receive a KE
payload.
2026-05-19 17:27:33 +02:00
Tobias Brunner 158b4c4aa4 child-rekey: Avoid potential use-after-free for deleted SPIs array 2026-05-19 17:27:33 +02:00
Tobias Brunner 7e7629499f receiver: Avoid unaligned memory access in COOKIE verification
This access could be an issue on platforms with strict alignment
requirements.
2026-05-19 17:27:33 +02:00
Tobias Brunner 8f22345542 dhcp: Fix potential OOB read when parsing DHCP messages
The missing parentheses around the additions when calculating optlen
in the previous code can cause an out-of-bound read of up to 228 bytes
if no DHCP_OPTEND is found in the message (the calculation basically
evaluated to `- 20 + 8 + 240`).

Since the buffer for the received packet (via pf_handler_t) is located
on the stack, this shouldn't cause much of an issue in practice.
2026-05-19 17:27:33 +02:00
Tobias Brunner 4821758d46 kernel-pfkey: Add some sanity checks when processing kernel events
These are always set in kernel messages, but just make sure so static
analyzers like SonarQube are happy.
2026-04-23 15:21:45 +02:00
Tobias Brunner cb27593ce0 kernel-netlink: Update family in SA selector if addresses change 2026-04-16 15:33:25 +02:00
Tobias Brunner e1a11e2c1c ike: Use correct format string for unique Child SA identifiers
Analogous to the previous commit.
2026-04-16 15:32:54 +02:00
Tobias Brunner 2a8fd3e4bf ike: Use correct format string for unique IKE SA identifiers
Would take a while until it became an issue, though.
2026-04-16 15:32:54 +02:00
Tobias Brunner 5334d93a45 delete-ike-sa-job: Log unique ID when deleting half-open IKE SA 2026-04-16 15:32:54 +02:00
Tobias Brunner 7f6fc50ba3 ike-init: Log the IKE SA's unique identifier when creating one as responder
The name will not be defined yet, but we have a similar message as
initiator so use the same format.
2026-04-16 15:32:54 +02:00
Markus Theil febe474926 encrypted-payload: Check for non-zero payload size
Signed-off-by: Markus Theil <markus.theil@secunet.com>
2026-04-13 15:12:55 +02:00
Tobias Brunner 2a63343968 trap-manager: Ignore acquires without selectors for wildcard traps
We need to know the actual destination address to process these.
2026-04-02 08:33:30 +02:00
Tobias Brunner 66fffdb1bf ike-init: Remove redundant check for more key exchanges during rekeying
We only call derive_keys() after a successful key_exchange_done() call
during rekeying, so this will always return FALSE.
2026-04-02 08:17:05 +02:00
Tobias Brunner 4af485d87d certreq: Avoid OOB read when enumerating hashes in OCSP CERTREQ
These certificate requests also contain SHA-1 hashes, which is assumed
in `ike_cert_pre.c::process_certreq()` when enumerating key IDs.

Because the parser allocates a separate chunk for the data and the
enumerator doesn't read beyond that chunk's length after the first
iteration, only lengths between 1 and 19 are problematic (0 doesn't
cause an enumeration because chunk_empty is assigned).

Whether the OOB read then can cause a segmentation fault depends on the
allocator, its alignment rules, and its minimum overhead.  For instance,
with glibc on a typical 64-bit system (8 bytes for pointers and size_t),
the alignment is 16 bytes and the minimum allocated size is 32 bytes,
with typically 24 that are technically available for data, even if only
0 bytes are allocated (as returned by `malloc_usable_size()`).  So with
an allocation between 1 and 19, we can always safely read 20 bytes.

Assuming that other allocators behave similar for small allocations, it
seems unlikely that this causes a crash.

Fixes: 15612b3a42 ("Add support for IKEv2 OCSP extensions (RFC 4806)")
2026-04-02 08:17:05 +02:00
Tobias Brunner 20b07f2cbf vici: Prevent uninitialized memory access if VICI_LIST_ITEM is too short
If there is only a single length byte, `value` is not changed and points
to uninitialized data.
2026-04-02 08:17:05 +02:00
Tobias Brunner 65fcf08cdb eap-sim: Prevent infinite loop if version list contains more than one entry
Fixes: ac4dd5439b ("Migrated EAP-SIM to libsimaka, separated server/peer implementations")
2026-04-02 08:17:04 +02:00
Tobias Brunner 1e1dd2976d message: Drop fragments with total fragment count lower than before
The RFC only allows that the number of fragments increases (if the
sender reduces the MTU).

Not enforcing this before could cause early reassembly as the trigger was
that the number of received fragments matches the total count of the
current packet (which was a bit weird anyway).  Only an active MITM could
trigger this as individual fragments are encrypted and authenticated.
2026-04-02 08:17:04 +02:00
Tobias Brunner b377a41336 dhcp: Use correct getter for boolean force_server_address option 2026-04-01 19:33:09 +02:00
Tobias Brunner 73aff21077 eap-ttls: Prevent crash if AVP length header field is invalid
The length field in the AVP header includes the 8 bytes of the header
itself.  Not checking for that and later subtracting it causes an
integer underflow that usually triggers a crash when accessing a
NULL pointer that resulted from the failing chunk_alloc() call because
of the high value.

The attempted allocations for invalid lengths (0-7) are 0xfffffff8,
0xfffffffc, or 0x100000000 (0 on 32-bit hosts), so this doesn't result
in a buffer overflow even if the allocation succeeds.

Fixes: 79f2102cb4 ("implemented server side support for EAP-TTLS")
Fixes: CVE-2026-25075
2026-03-19 16:49:41 +01:00