Bug 1107874 - (CVE-2018-16151) VUL-0: CVE-2018-16151, CVE-2018-16152: strongswan: several flaws in the gmp plugin that may lead to an authorization bypass vulnerability
(CVE-2018-16151)
VUL-0: CVE-2018-16151, CVE-2018-16152: strongswan: several flaws in the gmp p...
Status: RESOLVED FIXED
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents
unspecified
Other Other
: P3 - Medium : Normal
: ---
Assigned To: Manuel Buil
Security Team bot
https://smash.suse.de/issue/214023/
CVSSv3:SUSE:CVE-2018-16151:4.8:(AV:N/...
:
Depends on: CVE-2018-17540
Blocks:
  Show dependency treegraph
 
Reported: 2018-09-10 15:40 UTC by Karol Babioch
Modified: 2022-03-04 12:29 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
strongswan-4.4.0-4.4.1_gmp-pkcs1-verify.patch (9.40 KB, patch)
2018-09-10 15:40 UTC, Karol Babioch
Details | Diff
strongswan-4.5.1-5.0.0_gmp-pkcs1-verify.patch (9.40 KB, patch)
2018-09-10 15:41 UTC, Karol Babioch
Details | Diff
strongswan-5.0.1-5.3.0_gmp-pkcs1-verify.patch (9.19 KB, patch)
2018-09-10 15:41 UTC, Karol Babioch
Details | Diff
strongswan-5.3.1-5.6.0_gmp-pkcs1-verify.patch (9.20 KB, patch)
2018-09-10 15:41 UTC, Karol Babioch
Details | Diff
strongswan-5.6.1-5.6.3_gmp-pkcs1-verify.patch (9.14 KB, patch)
2018-09-10 15:42 UTC, Karol Babioch
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karol Babioch 2018-09-10 15:40:57 UTC
Created attachment 782661 [details]
strongswan-4.4.0-4.4.1_gmp-pkcs1-verify.patch

Dear strongSwan partner,

A security researcher privately reported several flaws in the gmp plugin
that may lead to an authorization bypass vulnerability.


# Insufficient input validation in gmp plugin

Several flaws in the implementation that parsed and verified RSA
signatures in the gmp plugin may allow for a Bleichenbacher-style
low-exponent signature forgery in certificates and during IKE
authentication.  Potentially affected are all strongSwan versions
including the latest 5.6.3.

CVE-2018-16151 and CVE-2018-16152 have been assigned for two of the
flaws that may lead to this vulnerability (see below for details).

To verify an RSA signature it is decrypted using the public key with the
operation m^e mod n, where m is the signature value, and e and n are the
exponent and modulus of the public key, respectively.  When using PKCS#1
v1.5 the result of that calculation is a binary number that has a very
specific form:

	0x00 || 0x01 || PS || 0x00 || T

Where T is an ASN.1 encoded digestInfo (algorithmIdentifier with the OID
of the used hash function followed by the binary hash value) and the
padding PS consists of at least 8 bytes of 0xFF to make sure the
resulting value consists of exactly the same number of bytes as the modulus.

Already in 2006 Daniel Bleichenbacher showed that it is possible to
easily forge signatures for low-exponent keys (i.e. with e=3) if the
implementation fails to verify that there is enough padding to ensure
that T is right-aligned and if it allows arbitrary data after the hash.

While the implementation in the gmp plugin was not vulnerable to the
latter (i.e. it didn't allow data after the ASN.1 structure) further
research (e.g. in [1]) showed that the ASN.1 structure may offer similar
room for variance if the implementation verifying it is not strict
enough.  Since our ASN.1 parsing code is mainly designed to accept all
kinds of keys and certificates etc. it is pretty lenient, which lead to
the following issues.

The first is that the OID parser allows any number of random bytes after
a valid OID.  The asn1_known_oid() function just parses until it finds a
leaf in the tree of known OIDs, any further data that follows is simply
ignored.  And the function that parses ASN.1 algorithmIdentifier
structures doesn't care if the full OID data was parsed as it usually
doesn't really matter.  CVE-2018-16151 has been assigned to this issue.

The second problem is that the algorithmIdentifier structure not only
contains the OID but also an optional parameters field.  While none of
the algorithms used with PKCS#1 use parameters, i.e. the field should
always be encoded as ASN.1 NULL value, our parser does not enforce this,
it simply skips over the parameters.  This allows an attacker to fill
the field with random data.  CVE-2018-16152 has been assigned to this issue.

Additionally, the implementation did not enforce at least 8 bytes of
padding, actually it was perfectly fine to accept signatures without any
padding at all.  This does not immediately lead to a vulnerability in
itself (hence no separate CVE is assigned) but it makes exploiting the
other flaws much easier.

An attacker may use these flaws to generate forged signatures in order
to generate arbitrary certificates if a CA certificate uses a
low-exponent key or authenticate as a particular peer if that peer's
end-entity certificate or raw public key uses a low-exponent.
It's important to note that the attacker does not need to know the
actual public key, just the key length (which could be guessed).  Such a
forged signature will be accepted by any key with the same length and
low exponent.  More details on exploiting these flaws (the second in
particular) may be found in section 5 of [1].

Remote code execution is not possible due to these issues.


# Mitigation

Since only the gmp plugin is affected, installations that don't have
this plugin enabled and loaded are not vulnerable.

If the plugin is loaded, make sure that none of the employed keys and
certificates (including those of CAs) use keys with e = 3.  Our own tool
to generate keys (pki --gen) always used e = 65537 (0x10001), which is
not vulnerable, so certificates and keys generated with this tool are
fine for use even with an unpatched gmp plugin.

The attached patches fix the vulnerability in the respective strongSwan
versions and should apply with appropriate hunk offsets (please note
that patches for versions < 4.4.0 are not provided).
In order to apply them those for CVE-2012-2388 [2] (versions <= 4.6.3)
and CVE-2017-11185 [3] (versions <= 5.5.3) must be applied already.

Please prepare updated releases and patch your installations, but do not
yet publicly disclose any information about this vulnerability.  We want
to give you as a partner enough time to prepare new releases and will
publicly disclose the vulnerability with the strongSwan 5.7.0 release on
Mon Sep 24, 14:00 CEST.

Credit to Sze Yiu Chau and his team from Purdue University and The
University of Iowa for finding this vulnerability.  More details will be
released in their research paper later this year.

Our apologies for the inconvenience.

Kind Regards
Tobias Brunner
strongSwan Developer

[1] Variants of Bleichenbacher's Low-Exponent Attack on PKCS#1 RSA
Signatures
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.698.7230
[2] https://download.strongswan.org/security/CVE-2012-2388
[3] https://download.strongswan.org/security/CVE-2017-11185
Comment 1 Karol Babioch 2018-09-10 15:41:29 UTC
Created attachment 782662 [details]
strongswan-4.5.1-5.0.0_gmp-pkcs1-verify.patch
Comment 2 Karol Babioch 2018-09-10 15:41:42 UTC
Created attachment 782663 [details]
strongswan-5.0.1-5.3.0_gmp-pkcs1-verify.patch
Comment 3 Karol Babioch 2018-09-10 15:41:55 UTC
Created attachment 782664 [details]
strongswan-5.3.1-5.6.0_gmp-pkcs1-verify.patch
Comment 4 Karol Babioch 2018-09-10 15:42:10 UTC
Created attachment 782665 [details]
strongswan-5.6.1-5.6.3_gmp-pkcs1-verify.patch
Comment 5 Karol Babioch 2018-09-13 12:32:30 UTC
CRD: 2018-09-24 14:00 CEST
Comment 6 Karol Babioch 2018-09-14 12:17:14 UTC
There was an issue with the patches for versions < 5.0.1 (due to the
changed return type of the allocate_hash() method).  I've uploaded
updated patches for these versions to [1].

Regards,
Tobias

[1] https://download.strongswan.org/patches/27_gmp_pkcs1_verify_patch/
Comment 7 Karol Babioch 2018-09-27 08:19:38 UTC
There is another vulnerability that was introduced with the fix: Bug 1109845 -> CVE-2018-17540
Comment 12 Swamp Workflow Management 2019-11-25 20:21:38 UTC
SUSE-SU-2019:3056-1: An update that fixes 5 vulnerabilities is now available.

Category: security (important)
Bug References: 1093536,1094462,1107874,1109845
CVE References: CVE-2018-10811,CVE-2018-16151,CVE-2018-16152,CVE-2018-17540,CVE-2018-5388
Sources used:
SUSE Linux Enterprise Module for Packagehub Subpackages 15 (src):    strongswan-5.6.0-4.3.2
SUSE Linux Enterprise Module for Open Buildservice Development Tools 15-SP1 (src):    strongswan-5.6.0-4.3.2
SUSE Linux Enterprise Module for Open Buildservice Development Tools 15 (src):    strongswan-5.6.0-4.3.2
SUSE Linux Enterprise Module for Basesystem 15-SP1 (src):    strongswan-5.6.0-4.3.2
SUSE Linux Enterprise Module for Basesystem 15 (src):    strongswan-5.6.0-4.3.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 13 Swamp Workflow Management 2019-11-30 23:12:37 UTC
openSUSE-SU-2019:2594-1: An update that fixes 5 vulnerabilities is now available.

Category: security (important)
Bug References: 1093536,1094462,1107874,1109845
CVE References: CVE-2018-10811,CVE-2018-16151,CVE-2018-16152,CVE-2018-17540,CVE-2018-5388
Sources used:
openSUSE Leap 15.0 (src):    strongswan-5.6.0-lp150.3.3.1
Comment 14 Swamp Workflow Management 2019-12-01 05:12:07 UTC
openSUSE-SU-2019:2598-1: An update that fixes 5 vulnerabilities is now available.

Category: security (important)
Bug References: 1093536,1094462,1107874,1109845
CVE References: CVE-2018-10811,CVE-2018-16151,CVE-2018-16152,CVE-2018-17540,CVE-2018-5388
Sources used:
openSUSE Leap 15.1 (src):    strongswan-5.6.0-lp151.4.3.1
Comment 15 Swamp Workflow Management 2019-12-11 14:19:20 UTC
SUSE-SU-2019:3266-1: An update that solves 5 vulnerabilities and has one errata is now available.

Category: security (important)
Bug References: 1009254,1071853,1093536,1094462,1107874,1109845
CVE References: CVE-2018-10811,CVE-2018-16151,CVE-2018-16152,CVE-2018-17540,CVE-2018-5388
Sources used:
SUSE OpenStack Cloud 8 (src):    strongswan-5.1.3-26.13.1
SUSE OpenStack Cloud 7 (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server for SAP 12-SP3 (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server for SAP 12-SP2 (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server for SAP 12-SP1 (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server 12-SP5 (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server 12-SP4 (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server 12-SP3-LTSS (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server 12-SP3-BCL (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server 12-SP2-LTSS (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server 12-SP2-BCL (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Server 12-SP1-LTSS (src):    strongswan-5.1.3-26.13.1
SUSE Linux Enterprise Desktop 12-SP4 (src):    strongswan-5.1.3-26.13.1
SUSE Enterprise Storage 5 (src):    strongswan-5.1.3-26.13.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 16 Bjørn Lie 2020-01-23 18:06:06 UTC
Please ack and forward

https://build.opensuse.org/request/show/761676

That way we can have this CVE fixed in Tumbleweed too.....
Comment 17 Swamp Workflow Management 2020-01-26 10:00:07 UTC
This is an autogenerated message for OBS integration:
This bug (1107874) was mentioned in
https://build.opensuse.org/request/show/767305 Factory / strongswan
Comment 18 Gianluca Gabrielli 2021-10-14 08:35:09 UTC
Hi Manuel,

submission for SUSE:SLE-11-SP1:Update is missing. Can you please provide it?
Comment 20 Swamp Workflow Management 2022-02-18 14:37:28 UTC
SUSE-SU-2022:14887-1: An update that fixes four vulnerabilities is now available.

Category: security (important)
Bug References: 1107874,1109845,1194471
CVE References: CVE-2018-16151,CVE-2018-16152,CVE-2018-17540,CVE-2021-45079
JIRA References: 
Sources used:
SUSE Linux Enterprise Server 11-SP4-LTSS (src):    strongswan-4.4.0-6.36.12.1
SUSE Linux Enterprise Point of Sale 11-SP3 (src):    strongswan-4.4.0-6.36.12.1
SUSE Linux Enterprise Debuginfo 11-SP4 (src):    strongswan-4.4.0-6.36.12.1
SUSE Linux Enterprise Debuginfo 11-SP3 (src):    strongswan-4.4.0-6.36.12.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 21 Marcus Meissner 2022-03-04 12:29:29 UTC
released