18473 Commits

Author SHA1 Message Date
Tobias Brunner
abce9feb6a child-create: Add support for multiple key exchanges
It also changes that payloads are built before installing the CHILD_SA on
the responder, that is, the KE payload is generated before keys are derived,
so that key_exchange_t::get_public_key() is called before get_shared_secret(),
or it's internal equivalent, which could be relevant for KE implementations
that want to ensure that the key can't be used again after the key
derivation.
2022-10-04 09:49:03 +02:00
Tobias Brunner
d3da7b1fdd ike-rekey: Support IKE_SA rekeying with multiple key exchanges 2022-10-04 09:49:02 +02:00
Tobias Brunner
d68cd46478 ike-init: Add support for multiple key exchanges
Initially, this is handled with a key derivation for each
IKE_INTERMEDIATE exchange.  When rekeying the keys are derived only when
all IKE_FOLLOWUP_KE exchanges are done.
2022-10-04 09:49:02 +02:00
Tobias Brunner
930d82783d bus: Support multiple key exchanges in ike/child_keys() events 2022-10-04 09:49:02 +02:00
Tobias Brunner
3bbc2d6aca keymat_v2: Support key derivation with multiple key exchanges 2022-10-04 09:49:02 +02:00
Tobias Brunner
20e6dc0665 key-exchange: Add helper to concatenate shared secrets of several key exchanges 2022-10-04 09:49:02 +02:00
Tobias Brunner
e9771db66f keymat_v2: Proper cleanup if derive_ike_keys() is called multiple times 2022-10-04 09:49:02 +02:00
Tobias Brunner
cf0a861678 ike-auth: Calculate and collect IntAuth for IKE_INTERMEDIATE exchanges
The message ID of the first IKE_AUTH exchange is a safe-guard against
potential truncation attacks if IKE_INTERMEDIATE exchanges are not used
for multiple key exchanges but some other future use where the number of
exchanges might not depend on the selected proposal.
2022-10-04 09:49:02 +02:00
Tobias Brunner
cd3d8d2040 pubkey-authenticator: Handle IntAuth data 2022-10-04 09:49:02 +02:00
Tobias Brunner
17773226ce psk-authenticator: Handle IntAuth data 2022-10-04 09:49:02 +02:00
Tobias Brunner
b2aa035fc6 eap-authenticator: Handle IntAuth data 2022-10-04 09:49:02 +02:00
Tobias Brunner
8a7910522c keymat_v2: Include optional IntAuth in signed octets 2022-10-04 09:49:02 +02:00
Tobias Brunner
69d5c3fade authenticator: Add optional method to set IntAuth data 2022-10-04 09:49:02 +02:00
Tobias Brunner
d9f3527519 message: Store original encrypted payload when generating fragments
If we don't do this, get_plain() will fail after generating the message
fragmented.
2022-10-04 09:49:02 +02:00
Tobias Brunner
d290c54362 message: Add method to generate data to authenticate IKE_INTERMEDIATE exchanges 2022-10-04 09:49:02 +02:00
Tobias Brunner
c1fa35422e generator: Make pointer to length field optional
Only useful if we generate an IKE header.
2022-10-04 09:49:02 +02:00
Tobias Brunner
f95819e87d keymat_v2: Add method to calculate IntAuth for IKE_INTERMEDIATE exchanges 2022-10-04 09:49:02 +02:00
Tobias Brunner
f5226e531c message: Add rules for IKE_FOLLOWUP_KE exchanges 2022-10-04 09:49:02 +02:00
Tobias Brunner
333fbe447b wip: ike-header: Add IKE_FOLLOWUP_KE exchange type 2022-10-04 09:49:02 +02:00
Tobias Brunner
f4b9f0af9f wip: notify-payload: Add notify types for multiple key exchanges 2022-10-04 09:49:02 +02:00
Tobias Brunner
af5a06a279 ikev2: Reject IKE_INTERMEDIATE requests after IKE_AUTH
We currently only support these exchanges for additional key exchanges,
so once we have the final keys derived and the ike-init task is removed,
we don't expect any more of them.
2022-10-04 09:49:02 +02:00
Tobias Brunner
4810ecc926 message: Add rules for IKE_INTERMEDIATE exchanges 2022-10-03 17:37:43 +02:00
Tobias Brunner
db5aad74c3 ike-header: Add IKE_INTERMEDIATE exchange type 2022-10-03 17:37:43 +02:00
Tobias Brunner
a1803e58f4 notify-payload: Add notify type for IKE_INTERMEDIATE exchange 2022-10-03 17:37:43 +02:00
Tobias Brunner
daf9b9faa0 proposal-substructure: Encode additional key exchange methods 2022-10-03 17:37:43 +02:00
Tobias Brunner
17584a1ae0 proposal: Make all key exchange transforms optional in ESP/AH proposals 2022-10-03 17:37:43 +02:00
Tobias Brunner
a467b786e6 proposal: Skip all KE transforms if PROPOSAL_SKIP_KE given 2022-10-03 17:37:43 +02:00
Tobias Brunner
f7579edb2c transform: Add helper to check if transform type negotiates key exchange 2022-10-03 17:37:43 +02:00
Tobias Brunner
c59cafead2 transform: Add additional key exchange transform types 2022-10-03 17:37:43 +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