Commit Graph
18014 Commits
Author SHA1 Message Date
Tobias Brunner 02e4f994ec signature-params: Reject schemes other than RSASSA-PSS with parameters
NULL parameters (for classic PKCS#1 signature schemes) are explicitly
allowed (for any schemes for now), but we only expect parameters for
RSASSA-PSS.  Before enforcing this, it was possible to modify the
parameters in the signatureAlgorithm field of the outer X.509 Certificate
structure to something different than the signature field of the signed,
inner tbsCertificate structure, allowing generating infinite versions
of valid certificates with different binary encodings.  Now we accept at
most two (NULL and absent parameters).
2021-10-14 18:59:07 +02:00
Tobias Brunner f061dedcb7 asn1: Return any parameters of algorithmIdentifier structures
Previously, only parameters of type OID, SEQUENCE and OCTET STRING were
returned (so e.g. random integers could be put in parameters and we
wouldn't know about it).

Log output is basically the same as with asn1_parser_t before, except
that parameters are always dumped (if any), that wasn't the case before
because ASN1_RAW (instead of ASN1_OBJ) was used.
2021-10-14 18:59:07 +02:00
Tobias Brunner dceed8e099 cert-cache: Prevent crash due to integer overflow/sign change
random() allocates values in the range [0, RAND_MAX], with RAND_MAX usually
equaling INT_MAX = 2^31-1.  Previously, values between 0 and 31 were added
directly to that offset before applying`% CACHE_SIZE` to get an index into
the cache array.  If the random value was very high, this resulted in an
integer overflow and a negative index value and, therefore, an out-of-bounds
access of the array and in turn dereferencing invalid pointers when trying
to acquire the read lock.  This most likely results in a segmentation fault.

Fixes: 764e8b2211 ("reimplemented certificate cache")
Fixes: CVE-2021-41991
2021-10-14 18:59:07 +02:00
Tobias Brunner 234302a108 gmp: Reject RSASSA-PSS signatures with negative salt length
The `salt_len` field is signed because negative values are used to indicate
automatic salt lengths when generating signatures.  This must never be the
case when validating them.

Not checking this could lead to an integer overflow below.  The value is
assigned to the `len` field of a chunk (`size_t`), which is further used
in calculations to check the padding structure and (if that is passed by
a matching crafted signature value) eventually a memcpy() that will result
in a segmentation fault.

Fixes: 7d6b81648b ("gmp: Add support for RSASSA-PSS signature verification")
Fixes: CVE-2021-41990
2021-10-14 18:59:07 +02:00
Tobias Brunner 03fbceb3f5 signature-params: Reject RSASSA-PSS params that result in negative salt len
The `salt_len` member in the struct is of type `ssize_t` because we use
negative values for special automatic salt lengths when generating
signatures.  This change ensures that `salt_len` will not overflow the
`len` fields of chunks (`size_t`), which could lead to integer overflows
when validating signatures (see the next commit).

Fixes: a22316520b ("signature-params: Add functions to parse/build ASN.1 RSASSA-PSS params")
2021-10-14 18:59:07 +02:00
Tobias Brunner 2403154f95 pki: Use correct enum value to initialize ID type in --keyid command 2021-10-13 15:17:09 +02:00
Tobias Brunner b241e944fa cirrus: Use specific package name for OpenLDAP
Seems the openldap-client alias is gone.
2021-10-12 14:55:55 +02:00
Tobias Brunner e7f0c6f778 cirrus: Also build on FreeBSD 13.0 2021-10-12 14:49:03 +02:00
Andreas Steffen 1ecb0b8133 Version bump to 5.9.4rc1 2021-10-12 08:54:03 +02:00
Tobias Brunner c6cde0c8b6 pki: Ensure allocated serial numbers don't start with a zero byte
If the randomly allocated serial starts with 0x80, the fix added with
e49197f15e ("pki: Don't generate negative random serial numbers in
X.509 certificates") causes the value to become zero.  So the encoded
ASN.1 integer will start with a zero byte, which is only correct if the
integer would otherwise be interpreted as negative, i.e. the next byte
starts with the most significant bit set.  If that isn't the case, the
encoding is technically invalid and might get rejected by strict parsers.

Note that e49197f15e did not actually fix a violation of RFC 5280 as
asn1_integer() assumes all passed numbers are positive and automatically
adds a zero prefix if the MSB is set.  What it did instead (or at least
attempted to) is ensure that the generated serial is a positive 64-bit
number in two's complement. The difference can be seen in the output of
`openssl x509 -text`.  While 8-byte serials with the MSB set are printed
as hex dump:

    Serial Number:
            af:e2:e1:47:0f:66:b5:a4

    (The encoding is 02:09:00:af:e2:e1:47:0f:66:b5:a4)

those without MSB set are actually printed as number:

    Serial Number: 289805014144645117 (0x405981ffa37f7fd)

    (The encoding is 02:08:04:05:98:1F:FA:37:F7:FD)

The reason is that OpenSSL only does the latter if the number fits into a
signed `long` variable, which isn't the case if a positive 64-bit number
has the MSB set (i.e. has a zero prefix) as it would be interpreted as
negative number in two's complement.  OpenSSL does print negative serial
numbers (even if it's a violation of the RFC), but only if they were
encoded as such, i.e. if there was no zero prefix:

    Serial Number: -5492225205882687294 (-0x4c384db9c7158f3e)

    (The encoding is 02:08:b3:c7:b2:46:38:ea:70:c2)

Fixes: e49197f15e ("pki: Don't generate negative random serial numbers in X.509 certificates")
Closes strongswan/strongswan#631
2021-10-06 09:10:12 +02:00
Andreas Steffen 740038e401 Version bump to 5.9.4dr3 2021-10-04 15:47:05 +02:00
Tobias Brunner 128d054407 Clear static buffer returned by getpass() 2021-10-04 11:30:03 +02:00
Tobias Brunner de442491d9 swanctl: Clear config from memory
The 'secrets' section in the config file may contain passwords/PINs.
2021-10-04 11:30:03 +02:00
Tobias Brunner f3a5b54ab3 settings: Add destructor that wipes contents 2021-10-04 11:30:03 +02:00
Tobias Brunner 57faf886db stroke: Clear ipsec.secrets file from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner b667eb37b9 swanctl: Clear possibly unencrypted key/container files from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner 3a739424e1 pem: Clear possibly unencrypted key file from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner e2e21f2486 chunk: Optionally clear mmap'd chunk before unmapping
This is mostly for the non-mmap case as with mmap available, access to the
unmapped memory isn't easily possible (e.g. opening the same area with
MAP_ANONYMOUS | MAP_UNINITIALIZED is usually prevented by the missing
CONFIG_MMAP_ALLOW_UNINITIALIZED option in most kernels).
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 66e80f3d1b pem: Clear chunks after decrypting files 2021-10-04 11:30:03 +02:00
Tobias Brunner 16d91ab761 shared-key: Clear shared secret when destroyed 2021-10-04 11:30:03 +02:00
Tobias Brunner 5c24b05f0c Merge branch 'testing-bullseye'
Use Debian bullseye as base image for the testing environment.
2021-10-01 17:13:18 +02:00
Tobias Brunner 3edf3856d4 testing: Use Debian bullseye as base image 2021-10-01 15:05:44 +02:00
Tobias Brunner bc51815839 testing: Determine Debian version in TNC scenarios automatically again
Was statically set to 10 since f3d96b7bc9 ("Version bump to 5.9.1dr1").
2021-10-01 15:05:44 +02:00
Tobias Brunner f2420cee49 libimcv: Add Debian 11 (bullseye) to IMV database 2021-10-01 15:05:44 +02:00
Tobias Brunner 1ec01f10a2 testing: Replace arp with ip neigh
The net-tools package, which provides arp and other older utilities like
ifconfig, is not installed anymore on Debian bullseye.
2021-10-01 15:05:44 +02:00
Tobias Brunner ccac9c3047 testing: Allow DNS via TCP in net2net-dnscert scenario
New versions of Bind limit the maximum UDP message size to 1232 bytes,
which is the same that newer versions of libunbound propose as maximum via
EDNS in requests, so increasing the limit on the server wouldn't help.

Instead we allow DNS via TCP so the client can switch after receiving the
truncated UDP response.
2021-10-01 15:05:44 +02:00
Tobias Brunner 5b9c46b988 testing: Remove support for Debian jessie and FreeRADIUS 2 2021-10-01 15:05:44 +02:00
Tobias Brunner dff5a0cab8 testing: Support build with Debian bullseye base image 2021-10-01 15:05:44 +02:00
Tobias Brunner f92ad8454b openssl: Use correct key types when adopting Ed25519/448 keys
Fixes: cbf07ab5b0 ("openssl: Add support for Ed25519/Ed448")
2021-10-01 15:04:13 +02:00
Tobias Brunner c463a14483 openssl: Remove workaround for Brainpool ECDH curves for older OpenSSL versions
Using the workaround with the EVP interface, which we use to derive shared
keys since 74e02ff5e6 ("openssl: Mainly use EVP interface for ECDH"),
would actually require us to register the OIDs of these curves as NID.
Otherwise, the two EC_GROUPs used by private and public key objects
are not considered the same and the key derivation fails.

Since the curves are supported by OpenSSL since 1.0.2 it's probably rare to
find a version without them nowadays.  One exception is the old BoringSSL
version we still use on Android, which defines the NIDs but not the curve
data.  However, that version also lacks support to register OIDs as NIDs,
so the only option to support these groups there would be to got back to not
using the EVP interface, which isn't in anyone's interest.  If there really
is a need for them there, we could probably patch BoringSSL or use OpenSSL.
2021-10-01 15:04:13 +02:00
Tobias Brunner 3e148e5b76 github: Fix build on macOS due to moved OpenSSL location 2021-09-30 16:24:25 +02:00
Tobias Brunner 72e5b3b702 crl: Fix compilation with OpenSSL 3.0
Closes strongswan/strongswan#635
2021-09-30 11:57:43 +02:00
Tobias Brunner 2fbbd05ec5 github: Use OpenSSL 1.1 on macOS
The "openssl" alias now defaults to OpenSSL 3.0, which produces a lot of
deprecation warnings.  To avoid build failures due to `-Werror`, stay with
OpenSSL 1.1 until we can get rid of these issues.
2021-09-23 17:02:17 +02:00
Tobias Brunner b94236487c kernel-pfkey: Wipe request/response messages when managing SAs 2021-09-23 15:28:22 +02:00
Andreas Steffen 1b21a00fa7 Version bump to 5.9.4dr2 2021-09-21 14:18:16 +02:00
Tobias Brunner e166e6913c Change shebang for Python scripts to use python3 2021-09-21 12:51:47 +02:00
Tobias Brunner 6467f0416f testing: Fix updown script in route-based/net2net-xfrmi-ike scenario
With the update to Python 3 the encoding of the values in vici messages
changed to bytestrings (the keys are properly decoded).  And getting the
first CHILD_SA also needs a change.

The logger is now also initialized after daemonizing to avoid that opened
sockets are closed etc.
2021-09-21 12:50:12 +02:00
Andreas Steffen 3e2841572b testing: Switch to Python 3
Both swidGenerator and strongTNC were migrated to Python 3.
This allows to migrate all testing scripts to Python 3, too.
2021-09-21 09:47:43 +02:00
Tobias Brunner a5662e8f6e keymat_v2: Properly wipe DH secret during IKE_SA rekeying
While `secret` is wiped explicitly, it wasn't when concatenating with
the nonces.
2021-09-20 16:10:03 +02:00
Andreas Steffen 91896264b2 sec-updater: Use latest versions 2021-09-09 22:54:38 +02:00
Andreas Steffen d23ca7f345 os_info: Parse /etc/os-release first 2021-09-09 22:54:38 +02:00
Tobias Brunner bf91b71f1a github: Remove build on Ubuntu Xenial (16.04)
Support for it will be removed later this month.
2021-09-09 12:30:17 +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 3c0d7ec531 ike: Initiate new IKE_SA not until all children are queued
If there are many CHILD_SAs, the time between initiating the new IKE_SA
and checking it in might be longer (depending on what else is going on
in the daemon) than the retransmission timeout and no retransmits might
be sent afterwards for this SA (it will just linger around dead).
Calling initiate() last should avoid that (we do this similarly for MBB
reauthentication).
2021-08-24 14:31:55 +02:00
Tobias Brunner 23e46ea5ab ikev2: Only request reauth during IKE_AUTH if active reauth is not possible
If we can initiate the reauthentication ourselves, there is no reason to
explicitly request the peer to do so (at basically the same time).
2021-08-24 14:31:55 +02:00
Tobias Brunner 0d373e25e0 ike-rekey: Respond with TEMPORARY_FAILURE while reauthenticating
This could lead to duplicates as the new IKE_SA can't delete the old one
once reauthentication is complete if it was replaced by a rekeying.
2021-08-24 14:31:55 +02:00
Tobias Brunner 36161febd3 ike: Don't rekey IKE_SA while reauthenticating
If we are using make-before-break reauthentication, this could lead to
duplicates as the new IKE_SA wouldn't be able to delete the previous
one if it was replaced by a rekeying.
2021-08-24 14:31:55 +02:00