18448 Commits

Author SHA1 Message Date
Thomas Egerer
4ea61dcbfe kernel-interface: Make first reqid configurable
This can be helpful to reserve low reqids for manual configuration.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2022-10-05 10:28:05 +02:00
Tobias Brunner
27da024a5d backtrace: Only define print_sourceline() and esc() if actually used 2022-10-03 17:36:17 +02:00
Tobias Brunner
3cc5a670b5 lookip: Explicitly include string.h for strcpy() 2022-10-03 17:36:17 +02:00
Tobias Brunner
ff21f8affe error-notify: Explicitly include string.h for strcpy() 2022-10-03 17:36:17 +02:00
Andreas Steffen
e09bc70d12 Version bump to 5.9.8 5.9.8 2022-10-03 16:16:53 +02:00
Tobias Brunner
b2488db2ce NEWS: Add info about CVE-2022-40617 2022-10-03 10:48:46 +02:00
Tobias Brunner
1f870ae189 cert-validator: Use a separate method for online revocation checking
This avoids having to repeat offline checks after basic trust chain
validation.
2022-10-03 10:48:46 +02:00
Tobias Brunner
1968615590 revocation: Enforce a (configurable) timeout when fetching OCSP/CRL
Malicious servers could otherwise block the fetching thread indefinitely
after the initial TCP handshake (which has a default timeout of 10s
in the curl and winhttp plugins, the soup plugin actually has a default
overall timeout of 10s).
2022-10-03 10:48:46 +02:00
Tobias Brunner
b1e926148a credential-manager: Do online revocation checks only after basic trust chain validation
This avoids querying URLs of potentially untrusted certificates, e.g. if
an attacker sends a specially crafted end-entity and intermediate CA
certificate with a CDP that points to a server that completes the
TCP handshake but then does not send any further data, which will block
the fetcher thread (depending on the plugin) for as long as the default
timeout for TCP.  Doing that multiple times will block all worker threads,
leading to a DoS attack.

The logging during the certificate verification obviously changes.  The
following example shows the output of `pki --verify` for the current
strongswan.org certificate:

new:

  using certificate "CN=www.strongswan.org"
  using trusted intermediate ca certificate "C=US, O=Let's Encrypt, CN=R3"
  using trusted ca certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  reached self-signed root ca with a path length of 1
checking certificate status of "CN=www.strongswan.org"
  requesting ocsp status from 'http://r3.o.lencr.org' ...
  ocsp response correctly signed by "C=US, O=Let's Encrypt, CN=R3"
  ocsp response is valid: until Jul 27 12:59:58 2022
certificate status is good
checking certificate status of "C=US, O=Let's Encrypt, CN=R3"
ocsp response verification failed, no signer certificate 'C=US, O=Let's Encrypt, CN=R3' found
  fetching crl from 'http://x1.c.lencr.org/' ...
  using trusted certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl correctly signed by "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl is valid: until Apr 18 01:59:59 2023
certificate status is good
certificate trusted, lifetimes valid, certificate not revoked

old:

  using certificate "CN=www.strongswan.org"
  using trusted intermediate ca certificate "C=US, O=Let's Encrypt, CN=R3"
checking certificate status of "CN=www.strongswan.org"
  requesting ocsp status from 'http://r3.o.lencr.org' ...
  ocsp response correctly signed by "C=US, O=Let's Encrypt, CN=R3"
  ocsp response is valid: until Jul 27 12:59:58 2022
certificate status is good
  using trusted ca certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
checking certificate status of "C=US, O=Let's Encrypt, CN=R3"
ocsp response verification failed, no signer certificate 'C=US, O=Let's Encrypt, CN=R3' found
  fetching crl from 'http://x1.c.lencr.org/' ...
  using trusted certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl correctly signed by "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl is valid: until Apr 18 01:59:59 2023
certificate status is good
  reached self-signed root ca with a path length of 1
certificate trusted, lifetimes valid, certificate not revoked

Note that this also fixes an issue with the previous dual-use of the
`trusted` flag.  It not only indicated whether the chain is trusted but
also whether the current issuer is the root anchor (the corresponding
flag in the `cert_validator_t` interface is called `anchor`).  This was
a problem when building multi-level trust chains for pre-trusted
end-entity certificates (i.e. where `trusted` is TRUE from the start).
This caused the main loop to get aborted after the first intermediate CA
certificate and the mentioned `anchor` flag wasn't correct in any calls
to `cert_validator_t` implementations.

Fixes: CVE-2022-40617
2022-10-03 10:48:46 +02:00
Andreas Steffen
6bf60221f5 pkcs7: Support rsa-pss signatures 2022-10-03 09:52:07 +02:00
Tobias Brunner
e0fd191f31 object: Make INIT() a compound statement
This forces the use of a semicolon after INIT() and makes existing ones,
which was the case for basically all instances, necessary so e.g.
sonarcloud won't complain about an empty statement after every one of
them.

By evaluating to the allocated object, it would theoretically also allow
constructs like this:

  struct_t *this;

  return INIT(this,
  	.a = x,
  	.b = y,
  );

or this:

  array_insert(a, ARRAY_TAIL, INIT(this,
    .a = x,
    .b = y,
  ));
2022-09-29 11:36:00 +02:00
Tobias Brunner
3da4ac8ef6 pki: Remove superfluous ; when initializing EST client 2022-09-29 11:34:50 +02:00
Tobias Brunner
ce82edfbe2 NEWS: Add news for 5.9.8
Also fixed the RFC number for EST.
2022-09-29 09:44:32 +02:00
Tobias Brunner
895597817a github: Prefer third-party crypto lib's implementations over ours
If e.g. the hmac plugin is loaded before the third-party crypto lib
plugin, we might not use the latter's HMAC implementation in some
cases (e.g. in the libtls tests).
2022-09-28 17:17:56 +02:00
Tobias Brunner
b05a8927d9 lgtm: Don't build with ASan and extra warnings 2022-09-28 15:37:27 +02:00
Tobias Brunner
0cbd1ad892 pki: Fix formatting and use else if to make Coverity happy 2022-09-28 15:07:37 +02:00
Tobias Brunner
00fd78305c Use wolfSSL 5.5.1 for tests 2022-09-28 14:55:39 +02:00
Tobias Brunner
7c9ccceec8 Fixed some typos, courtesy of codespell 2022-09-27 17:46:27 +02:00
Andreas Steffen
ef93c7e2ea Version bump to 5.9.8rc1 5.9.8rc1 2022-09-26 10:34:04 +02:00
Tobias Brunner
5ce1c91b58 ikev2: Trigger ike_updown() event after all IKE-specific tasks ran
This makes sure the event is only triggered after the IKE_SA is fully
established and e.g. virtual IPs, additional peer addresses or
a modified reauth time (on the initiator) are assigned to it.  This was
e.g. a problem for the selinux plugin if virtual IPs are used.

We use a separate task to trigger the event that's queued before the
child-create task so the event is triggered before the child_updown()
event.  Same goes for the state change to IKE_ESTABLISHED.

A new condition is used to indicate the successful completion of all
authentication rounds, so we don't have to set the IKE_ESTABLISHED state
in the ike-auth task (it was used as condition in other tasks).

Since set_state() also sets the rekey and reauth times, this required
some minor changes in regards to how AUTH_LIFETIME notifies are handled.
2022-09-23 16:28:35 +02:00
Tobias Brunner
14243dcdb5 ikev2: Make sure the child-create task runs after all IKE_SA specific tasks 2022-09-22 17:42:22 +02:00
Tobias Brunner
f3da04c05e ikev2: The ike-me task does not have to run before the ike-auth task
Since e334bd46b184 ("ike-auth: Move packet collection to post_build()
method") tasks and plugins can modify the IKE_SA_INIT message independent
of the ike-auth task.
2022-09-22 17:42:22 +02:00
Tobias Brunner
03ea02175e socket-dynamic: Use IPv6-only mode for IPv6 sockets
Same as the previous commit.

Fixes: 5f9ad62a8156 ("socket-dynamic: Don't set SO_REUSEADDR on IKE sockets anymore")
2022-09-22 17:38:58 +02:00
Tobias Brunner
ebaaacc459 socket-default: Use IPv6-only mode for IPv6 sockets
Otherwise, we can't open a dedicated IPv4 socket on the same port as the
IPv6 socket already is set up do receive IPv4 packets (unless we'd again
enable SO_REUSEADDR).

Fixes: 83da13371292 ("socket-default: Don't set SO_REUSEADDR on IKE sockets anymore")
2022-09-22 17:33:52 +02:00
Tobias Brunner
7433f1672a android: Prevent FD leak from HttpURLConnection
The default is apparently "Connection: keep-alive", which somehow keeps
the socket around, which leaks file descriptors with every connection
that fetches OCSP and/or CRLs.  Over time that could result in the number
of FDs reaching a limit e.g. imposed by FD_SET().

Closes strongswan/strongswan#1160
2022-09-21 15:15:18 +02:00
Tobias Brunner
ef68a7056b android: Update dependencies 2022-09-21 15:15:18 +02:00
Tobias Brunner
232623dd44 android: Set compile-/targetSdkVersion to 32 2022-09-21 15:15:18 +02:00
Tobias Brunner
9db90f8c26 android: Fix "Format string ... is not valid format string..." error
The linter complained that two of the strings don't actually contain any
printf-specifiers (i.e. don't expect any arguments) and therefore
shouldn't be used with String.format().
2022-09-21 15:15:18 +02:00
Tobias Brunner
563407e42a android: Mark PendingIntents as immutable via FLAG_IMMUTABLE
Setting this or explicitly FLAG_MUTABLE is required when targeting
Android 12.

References strongswan/strongswan#1151
2022-09-21 15:14:23 +02:00
Tobias Brunner
86b69f26e4 android: Explicitly mark Activities/Services with intent-filter as exported
Required when targeting Android 12.
2022-09-21 13:54:37 +02:00
Tobias Brunner
6ab9297b5d android: Move package namespace declaration from Manifest to build file 2022-09-21 13:54:37 +02:00
Tobias Brunner
a09727465c android: Remove unused jni directory spec from sourceSets 2022-09-21 13:54:37 +02:00
Tobias Brunner
cd698bf46b android: Update Gradle plugin 2022-09-21 13:54:37 +02:00
Tobias Brunner
357d680649 socket-win: Don't set SO_REUSEADDR on IKE sockets anymore
Same as the change for socket-default in a previous commit.
2022-09-21 13:53:44 +02:00
Tobias Brunner
5f9ad62a81 socket-dynamic: Don't set SO_REUSEADDR on IKE sockets anymore
Same as the previous commit.
2022-09-21 13:53:44 +02:00
Tobias Brunner
83da133712 socket-default: Don't set SO_REUSEADDR on IKE sockets anymore
This was originally required when pluto and charon both bound sockets to
the same port to send messages.  Pluto also received messages on them but
charon didn't and used a raw socket instead.  Since the removal of pluto
we don't need to set this option anymore, which might actually mask
mistakes like running charon and charon-systemd concurrently (that could
result in messages getting sent fine by both daemons but only received
by one).

Note that a failure to create/bind the sockets will not immediately
result in a shutdown of the daemon.  Instead, there will be an error
once the receiver tries to read any messages and also whenever the sender
attempts to send a request.
2022-09-21 13:53:44 +02:00
Tobias Brunner
0da8cae671 Merge branch 'eap-vendor-id'
Changes the type for EAP vendor IDs from uint32_t to pen_t, which has
explicitly been added to represent three-byte IANA-allocated Private
Enterprise Numbers (PEN), which the EAP RFC called "SMI Network
Management Private Enterprise Codes".

References strongswan/strongswan#581
2022-09-21 13:53:44 +02:00
Tobias Brunner
cdeb724839 eap: Make sure eap_type_t is large enough to hold vendor-specific types
Unless compiled with `-fshort-enumes` that's usually the case already.
2022-09-21 13:53:44 +02:00
Tobias Brunner
9efd7d7e90 eap: Print vendor (PEN) names for vendor-specific EAP methods 2022-09-21 13:53:44 +02:00
Tobias Brunner
f6e6fcd2f6 eap: Use pen_t instead of uint32_t for vendor ID 2022-09-21 13:53:44 +02:00
Andreas Steffen
8f5ff23d6c Version bump to 5.9.8dr4 5.9.8dr4 2022-09-20 16:37:44 +02:00
Andreas Steffen
063ef084e4 pki: Base64 encoding of username:password in HTTP basic authentication 2022-09-20 11:07:33 +02:00
Martin Willi
a708e96906 pki: Always and implicitly use base64 encoding for EST requests/response
Content-Transfer-Encoding is actually not a valid HTTP header, but a MIME
header, and must not be used. The original RFC7030 specifies this wrong,
and an errata discusses this issue.

The use of base64 encoding has been clarified in RFC8951, and the
recommendation is to always use/expect base64 encoding, but not send/expect
the Content-Transfer-Encoding header.
2022-09-20 11:07:33 +02:00
Tobias Brunner
75d820de8b scepclient: Remove documentation about removal of scepclient
There should be no need for such a persistent documentation on a removed
component in the repository.  The commit history is enough.  And besides
that, there is user-facing documentation about it in the docs and the
changelog/NEWS.
2022-09-20 10:50:36 +02:00
Tobias Brunner
231df029b0 pki: Add SCEP utility functions and enums to Doxygen doc 2022-09-20 10:18:36 +02:00
Tobias Brunner
f21ef43b0c vici: Ignore NULL message in raise_event()
There are a lot of calls like this:

  this->dispatcher->raise_event(this->dispatcher, "...", 0,
                                b->finalize(b));

However, if finalize() fails, e.g. because a previous call to add()
failed due to the size limit, it returns NULL.  This then caused a
segmentation fault in raise_event() when it interacted with that value.

Closes strongswan/strongswan#1278
2022-09-20 10:15:13 +02:00
Tobias Brunner
33f5e23c4e Merge branch 'ike-sa-flush'
This fixes a race condition during shutdown between the main thread
flushing the IKE_SA manager and worker threads still creating IKE_SAs.

Closes strongswan/strongswan#1252
2022-09-20 10:09:59 +02:00
Tobias Brunner
2740c50bb8 ike-sa-manager: Make sure flush() removes entries that might get added concurrently
Because flush() has to release the segment locks intermittently, threads
might add new entries (even with the change in the previous commit as the
IKE_SA might already be created, just not registered/checked in yet).

Since those entries are added to the front of the segment lists, the
enumerator in the previous step 2 didn't notice them and did not wait
for them to get checked in.  However, step 3 and 4 then proceeded to
delete and destroy the entry and IKE_SA, which could lead to a crash
once the other thread attempts to check in the already destroyed IKE_SA.

This change combines the three loops of steps 2-4 but then loops over
the whole table until it's actually empty.  This way we wait for and
destroy newly added entries.
2022-09-20 10:06:14 +02:00
Tobias Brunner
6f456afe39 ike-sa-manager: Prevent new IKE_SA from getting created when flush() is called
Without ability to create SPIs, other threads are prevented from creating
new IKE_SAs while we are flushing existing IKE_SAs.  However, there could
still be IKE_SAs already created that might get checked in while the
segments are temporarily unlocked to wait for threads to check existing
SAs in.
2022-09-20 10:04:06 +02:00
Tobias Brunner
69995ed2c4 ike-sa: Always set ike_cfg_t when setting peer_cfg_t
This is more consistent and e.g. allows to properly take into account
some settings that are also relevant during IKE_AUTH (e.g. childless).

We also already use the peer_cfg_t's ike_cfg_t when rekeying,
reauthenticating and reestablishing an IKE_SA (and e.g. for DSCP).

Also changed are some IKEv1 cases where get_ike_cfg() is called before
set_peer_cfg() without taking a reference to the ike_cfg_t that might
get replaced/destroyed (none of the cases were problematic, though, but
it also wasn't necessary to keep the ike_cfg_t around).

Closes strongswan/strongswan#1238
2022-09-20 10:03:02 +02:00