Commit Graph
2252 Commits
Author SHA1 Message Date
Tobias Brunner 44ab5533b0 connmark: Consider configured mask in installed firewall rules
This allows using the upper parts of the marks for other purposes.  For
instance, with `mark_in=mark_out=%unique/0x0000ffff` mark values in the
upper two bytes would not get reset by the rules installed by this plugin.
However, note that in this example the daemon would have to get restarted
after 65'535 CHILD_SAs to reset the counter for unique marks, which is a
global 32-bit counter that's unaware of any masks.

Closes strongswan/strongswan#1087
2022-07-18 15:05:51 +02:00
Tobias Brunner 36d16e5b24 forecast: Fix incompatible function types warning 2022-07-18 12:42:24 +02:00
Tobias Brunner 3af7c6db87 Rename diffie_hellman_t to key_exchange_t and change the interface etc.
This makes it more generic so we can use it for QSKE methods.
2022-06-29 10:28:50 +02:00
Tobias Brunner df18934d20 Replace or remove wiki.strongswan.org URLs 2022-06-28 13:33:51 +02:00
Tobias Brunner 19ef2aec15 Update copyright headers after acquisition by secunet 2022-06-28 10:22:56 +02:00
Tobias Brunner c9d471091f Use mallinfo2() if available
mallinfo() is deprecated because it uses `int` for the members of the
returned struct, whereas mallinfo2() uses `size_t`.  It's available
since glibc 2.33.
2022-04-25 14:16:20 +02:00
Tobias Brunner ec17fa2fef vici: Report registered KDFs 2022-04-14 18:54:24 +02:00
Tobias Brunner 07bf428ad1 stroke: List registered KDFs 2022-04-14 18:54:24 +02:00
Tobias Brunner b1c7fac768 vici: Add options to only return specific CHILD_SAs in list-sas() 2022-04-14 18:42:01 +02:00
Tobias Brunner 2994347d18 vici: Report security label on CHILD_SA, policies and configs 2022-04-14 18:42:01 +02:00
Tobias Brunner 7cf6f29ac5 vici: Make security labels and mode configurable 2022-04-14 18:42:01 +02:00
Tobias Brunner f52e565ad3 kernel-netlink: Forward labels from acquires 2022-04-14 18:42:01 +02:00
Tobias Brunner b00a4e778f selinux: Add plugin to install trap policies with generic labels
After establishing an IKE_SA, we check if any of its child configs
define generic SELinux labels and install trap policies for them if
necessary narrowed to the current (virtual) IPs.
2022-04-14 18:42:01 +02:00
Tobias Brunner 96ecc39cd0 kernel-netlink: Allow reqid updates for policies again
This was originally added with 1551d8b13d ("kernel-netlink: reject
policy refcount if the reqid differs").  Since then we added code to
allocate constant reqids for the same TS, which pretty much avoids the
previous issues.

However, the reqid might have to be changed due to MOBIKE updates. And
because reqids are allocated for a complete set of traffic selectors and
not individual pairs, this can create a problem with drop policies as
those will use the old reqid (they are installed with the same priority,
reqid etc. to replace the actual IPsec policies), while unmodified
replacement policies will use the new one.  A similar issue exists for
CHILD_SAs with SELinux contexts as those all use duplicate policies (same
generic label) but can't all be updated concurrently.
2022-04-14 18:42:01 +02:00
Tobias Brunner 1b3af3e37d kernel-interface: Add support to change the reqid in update_sa() 2022-04-14 18:42:01 +02:00
Tobias Brunner 1f060357f4 kernel-wfp: Use new UDP ports in update_sa() 2022-04-14 18:42:01 +02:00
Tobias Brunner bf0542c4e1 kernel-netlink: Add support for optional security label on SAs and policies 2022-04-14 18:42:01 +02:00
Tobias Brunner d71d181d28 traffic-selector: Add TS_SECLABEL type 2022-04-14 18:42:01 +02:00
Tobias Brunner c00c5e5a35 vici: Make combination of 'trap' and 'start' configurable 2022-04-14 18:42:01 +02:00
Tobias Brunner 4f4d4021b4 ike: Treat action_t as flags so 'start' and 'trap' can be combined
While combining the actions could cause duplicates (while the SA is
initiated, traffic might trigger the trap and the initiation of another
CHILD_SA), the previous commit should avoid most duplicates.  If reuse_ikesa
is disabled, duplicates can't be prevented, though.
2022-04-14 18:42:01 +02:00
Tobias Brunner 3b699c720f kernel-listener: Use a struct to pass data from acquires 2022-04-14 18:42:01 +02:00
Tobias Brunner 9983326b20 kernel-netlink: Read protocol of acquire not from template
If a policy with IPComp template triggers an acquire, we get two, one for
an IPComp, one for ESP/AH SA.  However, the triggering template of the trap
policy (where we get the reqid from), will be the same in both acquires,
IPComp, which we ignore, so no acquire was actually forwarded.
2022-04-14 18:42:01 +02:00
Tobias Brunner 8a76c5af8a kernel-pfkey: Don't install exclude routes for locally connected peers
Such routes with a gateway that equals the peer's address are problematic
on FreeBSD.  And since there is most likely a narrow route for the local
subnet anyway, the exclude routes would be redundant.
2022-03-15 13:52:24 +01:00
Tobias Brunner 5de6ab82a6 kernel-pfkey: Only install exclude route if not routing via outbound interface
When installing routes based on remote traffic selectors, it can be
necessary to install an exclude route for the remote peer to avoid a
routing loop and continue to be able to reach it via IKE/ESP.

However, such routes are only necessary, if the routes we install don't
go via outbound interface.  That's the case when using VIPs and routing
via TUN devices, or when using internal source IPs and routing via
their interfaces.

Installing such exclude routes if not necessary can cause issues on
FreeBSD (EINVAL when sending packets to the peer).
2022-03-15 13:52:24 +01:00
Leon Romanovsky 012e4cd902 kernel-netlink: Remove unimplemented XFRM_OFFLOAD_IPV6 flag
The XFRM_OFFLOAD_IPV6 flag was never implemented in the kernel and there
are no plans to do so.

Kernel patch: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c76ecd9c99b6e9a771d813ab1aa7fa428b3ade1

Closes strongswan/strongswan#916
2022-03-14 15:48:21 +01:00
Thomas Egerer d6879ef984 ha: Streamline handling of conditions and extensions
Automatically takes care of sending/receiving newly added extensions and
conditions.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2022-02-15 15:27:13 +01:00
Tobias Brunner 801bb8536a error-notify: Handle missing alerts
References strongswan/strongswan#876.
2022-02-15 15:23:37 +01:00
Martin Willi e3d1766aff addrblock: Allow limiting validation depth of issuer addrblock extensions
RFC3779 requires to validate the addrblocks of issuer certificates strictly,
that is, they must contain the extension and the claimed addrblock, up to
the root CA.

When working with third party root CAs that do not have the extension,
this makes using the plugin impossible. So add a depth setting that limits
the number of issuer certificates to check bottom-up towards the root CA.
A depth value of 0 disables any issuer check, the default value of -1
checks all issuers in the chain, keeping the existing behavior.

Closes strongswan/strongswan#860
2022-01-24 17:32:06 +01:00
Tobias Brunner 64cc9acbf0 eap-authenticator: Enforce failure if MSK generation fails
Without this, the authentication succeeded if the server sent an early
EAP-Success message for mutual, key-generating EAP methods like EAP-TLS,
which may be used in EAP-only scenarios but would complete without server
or client authentication.  For clients configured for such EAP-only
scenarios, a rogue server could capture traffic after the tunnel is
established or even access hosts behind the client.  For non-mutual EAP
methods, public key server authentication has been enforced for a while.

A server previously could also crash a client by sending an EAP-Success
immediately without initiating an actual EAP method.

Fixes: 0706c39cda ("added support for EAP methods not establishing an MSK")
Fixes: CVE-2021-45079
2022-01-20 17:23:24 +01:00
Tobias Brunner e43052893d vici: Fix check before applying identity to public keys 2021-11-23 16:15:41 +01:00
Tobias Brunner 11b10bc2b0 farp: Fix incompatible function types warning 2021-11-17 18:21:30 +01:00
Tobias Brunner cceca1a3c4 eap-radius: Fix incompatible function types warnings 2021-11-17 18:18:09 +01:00
Tobias Brunner f4bfdec21f kernel-pfroute: Set lower MTU on TUN devices
The default MTU of 1500 is too high if kernel-libipsec is used (considering
the overhead of UDP-encapsulated ESP), but might also have an effect if
a TUN device is only used to install a virtual IP (the route points to it,
so the system might use its MTU and 1500 would still be too high).

This also works around an issue on macOS 12 where no RTM_IFINFO event
is sent for the newly created TUN device (neither for the creation,
setting it "up", nor adding the address).  Changing the MTU, however,
triggers such an event and we can detect the virtual IP.

Closes strongswan/strongswan#707
2021-11-09 09:43:01 +01:00
Tobias Brunner 57faf886db stroke: Clear ipsec.secrets file from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner b9aafa7ebf vici: Clear all request messages in case they contain secrets 2021-10-04 11:30:03 +02:00
Tobias Brunner 4bea9e8b60 vici: Clear cached strings in case the message contained shared secrets 2021-10-04 11:30:03 +02:00
Tobias Brunner b94236487c kernel-pfkey: Wipe request/response messages when managing SAs 2021-09-23 15:28:22 +02:00
Tobias Brunner a415761a8e vici: Update supported Python versions 2021-09-09 12:30:17 +02:00
Noel Kuntze fbd4930323 vici: Add DBG4 messages that print loaded shared keys and PINs
Closes strongswan/strongswan#217
2021-09-02 10:42:41 +02:00
Tobias Brunner de5609b297 vici: Use the more generic BUILD_BLOB to parse certificates/public keys 2021-08-23 17:59:39 +02:00
Tobias Brunner 1c4e134f26 kernel-netlink: Initialize ifreq structs when detecting offload capability 2021-08-11 15:35:52 +02:00
Andreas Steffen a09a905e1d vici: Suppress trailing nul character 2021-07-06 12:06:23 +02:00
Tobias Brunner 06e11b481b kernel-netlink: Fix theoretical memory leak when parsing routes
This currently can't happen as the kernel always puts RTA_TABLE as first
attribute in RTM_NEWROUTE messages.
2021-06-25 13:51:44 +02:00
Tobias Brunner f6aafb3005 Fixed some typos, courtesy of codespell
Main change is the conversion from the British cancelling/-ed to the
American canceling/-ed.
2021-06-25 11:32:29 +02:00
Tobias Brunner 79b526deba ha: Register the correct IKE_SA with the manager after a rekeying
Fixes: 20dfbcad08 ("ha: Register new IKE_SAs before calling inherit_post()")
Closes strongswan/strongswan#456.
2021-06-21 10:02:26 +02:00
Tobias Brunner eec3bdb04a vici: Signal waiting threads when skipping disconnected connections
If two threads are waiting in find_entry() and remove_entry(),
respectively, and the former is woken first, the latter remains stuck
as it won't get signaled.
2021-06-21 09:59:15 +02:00
Tobias Brunner b0e2187b6b vici: Signal waiting threads when removing a connection entry
If there are threads waiting in find_entry() and one in remove_entry()
and the latter is woken first by a thread calling put_entry(), the
former threads would remain stuck as they get never signaled.
2021-06-21 09:59:15 +02:00
Tobias Brunner 030e80957d kernel-netlink: Don't wait for VIPs to disappear during de-initialization
This can happen if an IKE_SA is terminated forcefully shortly before
terminating the daemon.  The thread that handles the terminate command
will call checkin_and_destroy(), which unregisters the IKE_SA from the
manager before destroying it.  The main thread that calls flush() on the
IKE_SA manager won't wait for this SA (its entry is already gone), so
the processor and in turn the watcher job/thread might get canceled
before the first thread started deleting the VIP.  It would then wait
indefinitely for a signal that can never be sent.

There is still a small chance the thread hangs in wait() if the state check
happens right before the watcher is canceled and it wasn't yet able to
deliver the event from the kernel, we counter that by rechecking the state
after a while.
2021-06-21 09:59:06 +02:00
Tobias Brunner ae71f8357d dhcp: Move log messages for received packets
This way they are logged in the context of the corresponding IKE_SA.

Closes strongswan/strongswan#417.
2021-06-08 17:03:17 +02:00
Thomas Egerer 4e29d6fac1 bus: Extend and reorder arguments of ike_derived_keys() hook
This now includes all key material derived for IKE_SAs in the order
defined in the RFC:

  {SK_d | SK_ai | SK_ar | SK_ei | SK_er | SK_pi | SK_pr}
               = prf+ (SKEYSEED, Ni | Nr | SPIi | SPIr)

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2021-06-07 17:08:27 +02:00