Commit Graph
14442 Commits
Author SHA1 Message Date
Tobias Brunner db87087fae tls: Only return EAP MSK if TLS handshake is complete
The MSK is generated when the keys are derived.  For TLS 1.3 that's also
when the handshake is complete.  However, for TLS 1.2 it happens when
generating or processing the ClientKeyExchange message, which, on the
client, happens before the final Finished handshake message has been
received from the server.  This caused the EAP-TLS client to accept an
EAP-Success message instead of the server's final TLS handshake
messages, unintentionally allowing servers to cut the exchange short by
two EAP messages (in the regular exchange the response to the server's
final handshake messages is an empty EAP-Response, which is then
followed by the server's EAP-Success).

While this is not correct, it does not seem to pose a security issue.
If DH is used as key exchange, the server signs the ServerKeyExchange
message and the client is sure to communicate with a trusted server
before it derives the MSK.  If RSA encryption is used as key exchange,
the client sends the premaster secret, on which the MSK is based,
encrypted with the server's public key (as extracted from the trusted
certificate).  An attacker won't be able to decrypt this and, therefore,
can't derive the same MSK to generate a valid AUTH payload and the IKE
authentication will fail.
2023-03-21 16:11:49 +01:00
Jean-Tiare Le BigotandTobias Brunner bb6174a4d1 vici: Generalize timeout support in Python bindings
Since 3dd5dc5011 ("Merge branch 'vici-python-timeout'"), any timeout
set directly on the socket is reset by `vici.Transport.receive()` unless
called by `vici.Session.listen()`. This prevents configuring a default
timeout directly on the socket.

However, setting a timeout directly on the socket also had drawbacks
since it can cause `vici.Transport.receive()` to raise a timeout error
while a subset of the data have been received, with no way to recover.

This commit merges both approaches by considering the timeout configured
on the socket by default (when no timeout is explicitly set) and
keeping the switch to blocking receive once the first byte has been
received. When the full expected data have been received, the timeout
configured on the socket is restored.

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
Signed-off-by: Jean-Tiare Le Bigot <jt@yadutaf.fr>

Closes strongswan/strongswan#1562
2023-03-10 09:10:44 +01:00
Tobias Brunner 8aa13a1797 eap-peap: Initiate Phase 2 immediately for TLS 1.3
Before TLS 1.3, the server sent the last handshake message and had the
option to piggyback the EAP-Identity request directly onto the packet
with the TLS Finished message, or wait for the empty message by the
client that acknowledges the completion of the handshake.  With TLS 1.3,
the client finishes the handshake after the server.  So this option
is irrelevant there and we immediately start with Phase 2.
2023-03-02 09:31:52 +01:00
Tobias Brunner 8e9b2bd27f pki: Add possibility to add/remove flags in requests when issuing certificates 2023-02-23 17:36:38 +01:00
Tobias Brunner 8325eeff06 pki: Allow overriding EKU flags from certificate request via command line
The flags encoded in the PKCS#10 structure (or derived from the encoded
profile name) might not be appropriate in some instances. This allows
overriding them without having to issue a new certificate request.
2023-02-23 16:55:57 +01:00
Tobias Brunner 501483b313 libvici: Fix Doxygen comment for vici_on_close()
Fixes: 9e5533fef9 ("libvici: Add callback invoked if connection is closed by daemon")
2023-02-22 14:33:34 +01:00
Tobias Brunner a5ba701783 swanctl: Fix Windows build of --monitor-sas command
Fixes: 4784c92c55 ("swanctl: Terminate --monitor-sa command if daemon closes connection")
2023-02-22 14:33:34 +01:00
Tobias Brunner 18d73a9a5c utils: Add counterpart to wait_sigint() to explicitly stop waiting 2023-02-22 14:33:34 +01:00
Tobias Brunner 58f278f932 charon-nm: Use an XFRM interface if available
This allows NM more freedom in regards to how it wants to use the passed
device.  In particular, if dnsmasq is used with NM as that binds to the
interface to send requests via VPN.

Installing the VIPs on lo avoids weird address removal/addition events
that happen for IPv6 on the physical interface (which would cause the VIP
to get incorrectly detected as non-VIP address and ignored during
deletion).

We could let NM install routes via XFRM interface, however, that causes
problems with e.g. the bypass-lan plugin (the throw routes in table 220
wouldn't have any effect).  We could let it install regular routes in
the main table, but determining the physical interface would be tricky
as the routes installed by NM, also in the main table, would conflict.

So instead we let the kernel-netlink interface install routes via XFRM
interface and to avoid routing the IKE traffic that way, we set a mark
on the IKE socket and exclude traffic with that mark from our routing
table.
2023-02-22 13:43:17 +01:00
Tobias Brunner 04486507b2 kernel-netlink: Add an option to install routes for SAs with XFRM interfaces
Since these might conflict with IKE traffic, this requires special care.
One option is to install bypass policies for the peer, which install
appropriate (throw) routes.  However, that won't work if the traffic to
the gateway itself should be protected, in particular, for host-to-host
tunnels.  So an alternative is to set a mark for the IKE socket and then
exclude that traffic from table 220 via the kernel-netlink plugin's
fwmark option.
2023-02-22 13:37:45 +01:00
Tobias Brunner 0cc780d317 kernel-netlink: Automatically bring up XFRM interfaces after creation 2023-02-22 13:37:45 +01:00
Tobias Brunner e1ff1eefcf kernel-netlink: Add manager for XFRM interfaces
The manager will allow charon-nm to create XFRM interfaces if supported
by the kernel instead of creating an unused dummy TUN interface.

The xfrmi tool is mostly obsolete nowadays as iproute2 supports creating
XFRM interfaces since 5.1.0 (2019-05).  Older Debians don't ship that and
early versions didn't list the interface IDs.  So there might still be
some uses for this tool.
2023-02-22 13:37:45 +01:00
Tobias Brunner 85d56b1c6a charon-nm: Tie lifetime of dummy TUN device to connection
NM doesn't terminate charon-nm after disconnecting, so the TUN device
previously stayed around even if no connection was established.  This
might be a bit more what users expect.
2023-02-22 13:37:45 +01:00
Tobias Brunner 5401a74d36 eap-tls: Add support for TLS 1.3
As defined in RFC 9190, a "protected success indication" (0x00) is sent
from the server to the client over the TLS connection when using TLS 1.3.

The client responds with an empty EAP message, which is interpreted as
acknowledgement in our stack.

If we ever support session resumption with tunneled methods such as
EAP-TTLS, we'd have to send such an indication there too.
2023-02-22 13:34:53 +01:00
Tobias Brunner 06abdf1d31 tls-crypto: Fix MSK calculation for TLS 1.3
As noted in 121ac4b9e3 ("tls-crypto: Generate MSK for TLS 1.3"), the
calculation was only preliminary.  It is now fixed according to RFC 9190
and draft-ietf-emu-tls-eap-types (soon to become an RFC, currently in
the RFC editor queue).

Fixes: 121ac4b9e3 ("tls-crypto: Generate MSK for TLS 1.3")
2023-02-22 13:34:31 +01:00
Tobias Brunner 346a050c36 kernel-netlink: Increase log level for dumped Netlink messages
Some of these contain key material so they should be logged on level 4.
2023-02-22 13:20:10 +01:00
Tobias Brunner 1138b629fb android: Announce support for TFC padding
Has been supported by libipsec for a long time (since 5.1.1).  UDP encap
is already enforced via config, this just makes the flags the same as
in kernel-libipsec.
2023-02-22 13:20:10 +01:00
Tobias Brunner e21290ec30 kernel-netlink: Read last use time from SA if possible
Since 6.2 the Linux kernel updates the last use time per SA.  In
previous releases the attribute was only updated and reported for
specific outbound IPv6 SAs.

Using this reduces the number of kernel queries per CHILD_SA: for DPDs
from two policy queries (IN/FWD) to a single query of the inbound SA,
and for status reports the three policy queries (IN/FWD/OUT) can be
omitted and only the two SAs have to be queried.  For NAT keepalives the
number of queries doesn't change but a policy query (OUT) is replaced by
a query for the outbound SA.

While we could use the existence of the attribute as indicator for its
support, we don't know this until we queried an SA.  By using a version
check we can announce the feature from the start.
2023-02-22 13:20:10 +01:00
Tobias Brunner 6301b880df child-sa: Query policies only if querying SAs doesn't update the use time 2023-02-22 13:20:10 +01:00
Tobias Brunner b9131c34d3 kernel-interface: Add feature to indicate if query_sa() returns last use time
Currently supported by libipsec and PF_KEY on macOS (FreeBSD, like Linux,
reports the time the SA was first used in sadb_lifetime_usetime - it also
triggers rekeyings based on that, which Linux doesn't, it also triggers
them if an SA is never used).
2023-02-22 13:20:10 +01:00
Tobias Brunner 1efdb0f791 ikev2: Add option to prefer childless IKE_SAs as initiator 2023-02-22 13:19:46 +01:00
Tobias Brunner 4784c92c55 swanctl: Terminate --monitor-sa command if daemon closes connection 2023-02-22 11:44:14 +01:00
Tobias Brunner 9e5533fef9 libvici: Add callback invoked if connection is closed by daemon 2023-02-22 11:44:14 +01:00
Tobias Brunner cbd69ec732 android: Update the README for the build via NDK 2023-02-20 14:11:59 +01:00
Tobias Brunner af93db93e6 android: New release after OpenSSL plugin fix 2023-02-17 16:59:13 +01:00
Tobias Brunner 48ef9bfbb6 openssl: Fix size of plugin feature array
Fixes: 312847e1a3 ("openssl: Add curve25519 and curve448 after ECDH groups")
2023-02-17 16:58:19 +01:00
Tobias Brunner 27d41a2442 android: New release after fixing interoperability issue with Zyxel firewalls 2023-02-17 16:42:42 +01:00
Tobias Brunner 312847e1a3 openssl: Add curve25519 and curve448 after ECDH groups
This was the order before 46a6b06282 ("openssl: Only announce ECDH
groups actually supported by OpenSSL") but that's not really the reason
for this change.  It's related to the Android app, where we previously
didn't support these DH groups in BoringSSL and added the curve25519
plugin after the openssl plugin instead.  This resulted in the same
order, i.e. ECDH groups before curve25519.  With the switch to OpenSSL
and the mentioned commit, this changed and curve25519 was now the first
group that was proposed and used for the KE payload.  Not really an
issue you'd think, however, there are apparently Zyxel Firewalls with
older firmware versions (some forum posts mentioned a fix in V5.31) that
can't handle KE payloads with DH groups > 21 (ecp521). So with
curve25519 (31) proposed in the KE payload, they silently dropped the
IKE_SA_INIT request and no connection could be established.
2023-02-17 16:40:59 +01:00
Tobias Brunner 4d3fc90caf libtls: Fix double-free for untrusted peer certificates
`public` is returned, but previously only if a trusted key was found.
We obviously don't want to return untrusted keys and since the reference
was correctly destroyed after determining the key type, this later caused
a double-free.

Fixes: 63fd718915 ("libtls: call create_public_enumerator() with key_type")
2023-02-17 15:11:43 +01:00
Tobias BrunnerandThomas Egerer 0de42047a9 enum: Add functions to add and remove mappings from enum names
Co-authored-by: Thomas Egerer <thomas.egerer@secunet.com>
2023-02-17 13:37:38 +01:00
Tobias Brunner 15c6360145 kernel-netlink: Offload bypass policies for IKE ports on interfaces
While this uses the same mechanism, it's not necessary to explicitly
enable port_bypass, the regular socket policies work fine to bypass any
software policies.
2023-02-16 14:45:57 +01:00
Tobias Brunner 77a5c9514c kernel-netlink: Use event socket wrapper for XFRM and networking events 2023-02-16 13:25:35 +01:00
Tobias Brunner cb0bdb847d kernel-netlink: Add simple wrapper for Netlink event sockets 2023-02-16 13:25:35 +01:00
Tobias Brunner e323539428 kernel-pfkey: Always register for events
The starter-specific code path isn't necessary anymore since
d8fdd1018e ("starter: Don't flush SAs in the kernel").
2023-02-16 13:25:35 +01:00
Tobias Brunner 30cb3bd4d5 kernel-pfroute: Always listen for events
The starter-specific code path isn't necessary anymore since
d8fdd1018e ("starter: Don't flush SAs in the kernel").
2023-02-16 13:25:35 +01:00
Tobias Brunner d7ccb44354 kernel-netlink: Always register for events
The starter-specific code path isn't necessary anymore since
d8fdd1018e ("starter: Don't flush SAs in the kernel").
2023-02-16 13:25:35 +01:00
Tobias Brunner 4e91ff7d8c starter: Remove starter-specific plugin lists
It hasn't loaded any plugins since d8fdd1018e ("starter: Don't flush
SAs in the kernel"), which was released with 5.3.3.
2023-02-16 13:25:34 +01:00
Tobias Brunner 68ccb1930c kernel-netlink: Fallback to configured interface when HW offloading policies
This allows offloading bypass and drop policies to a specific interface
by configuring `interface` and `hw_offload=packet` (`auto` works too).
2023-02-16 13:25:34 +01:00
Tobias Brunner 763014c028 shunt-manager: Pass HW offload mode when installing policies 2023-02-16 13:25:34 +01:00
Tobias Brunner 2b8f26308f vici: Update offloading configuration for full packet HW offloading 2023-02-16 13:25:34 +01:00
Tobias Brunner 55719d7de5 kernel-netlink: Add support for full packet and policy HW offloading 2023-02-16 13:25:34 +01:00
Tobias Brunner 46cfebe4ab child-sa: Pass HW offload mode for policies 2023-02-16 13:25:34 +01:00
Tobias Brunner af1eeda08b kernel-ipsec: Add HW offload mode to policies 2023-02-16 13:25:34 +01:00
Tobias Brunner 5390da1412 android: New release after switching to OpenSSL 2023-02-13 15:46:53 +01:00
Tobias Brunner 65aff933f1 android: Use correct language code for Ukrainian
While UA is the country code, the language code is apparently uk.
2023-02-13 15:46:53 +01:00
Tobias Brunner 937f726154 android: Clean up plugin list after switching to OpenSSL
Keep the kdf plugin because of AES-XCBC (and CAMELLIA-XCBC, which is now
supported due to OpenSSL).  Other plugins like fips-prf, pubkey or pkcs8
were never actually used by the app.  The random plugin might have been
necessary with early versions.
2023-02-13 15:30:58 +01:00
Tobias Brunner f959157d31 android: Increase minSdkVersion to 21 (Android 5.0)
Newer NDKs haven't supported the version(s) we used for a while. Also,
versions < 21 will be removed with the next version of the NDK.
2023-02-13 15:30:58 +01:00
Tobias Brunner 7e5c4bbb32 android: Add a script to build OpenSSL's libcrypto as needed by the app
The build script requires the paths to the NDK and OpenSSL sources.

It runs the build in a Docker container, by default. But if the required
tools are installed on the system (currently jq, make and perl) it can
also be run directly on the system by defining NO_DOCKER.

A relatively recent version of the NDK is required (the pre-built
toolchains are required).
2023-02-13 15:30:58 +01:00
Tobias Brunner 2fc8b14918 android: Add the application ID to the log 2023-02-10 11:27:44 +01:00
Tobias Brunner 12c925a7e7 android: Update screenshots and add more with advanced settings 2023-02-09 18:04:07 +01:00