Bug 1995634 (CVE-2021-3712) - CVE-2021-3712 openssl: Read buffer overruns processing ASN.1 strings
Summary: CVE-2021-3712 openssl: Read buffer overruns processing ASN.1 strings
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2021-3712
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1996053 1996054 1996185 1996186 1997219 1997220 1997221 1997223 1997297 1997298 1997299 1997300 1997301 1997473 2005400 2005401 2005402
Blocks: 1995569
TreeView+ depends on / blocked
 
Reported: 2021-08-19 14:14 UTC by Cedric Buissart
Modified: 2023-09-26 18:23 UTC (History)
40 users (show)

Fixed In Version: openssl 1.1.1l
Doc Type: If docs needed, set a value
Doc Text:
It was found that openssl assumed ASN.1 strings to be NUL terminated. A malicious actor may be able to force an application into calling openssl function with a specially crafted, non-NUL terminated string to deliberately hit this bug, which may result in a crash of the application, causing a Denial of Service attack, or possibly, memory disclosure. The highest threat from this vulnerability is to data confidentiality and system availability.
Clone Of:
Environment:
Last Closed: 2021-11-11 18:57:44 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2021:4613 0 None None None 2021-11-10 17:15:57 UTC
Red Hat Product Errata RHSA-2021:4614 0 None None None 2021-11-10 17:19:23 UTC
Red Hat Product Errata RHSA-2021:4618 0 None None None 2021-11-11 18:32:28 UTC
Red Hat Product Errata RHSA-2021:5226 0 None None None 2021-12-21 09:42:16 UTC
Red Hat Product Errata RHSA-2022:0064 0 None None None 2022-01-11 17:30:35 UTC

Description Cedric Buissart 2021-08-19 14:14:16 UTC
Severity: Moderate

ASN.1 strings are represented internally within OpenSSL as an ASN1_STRING
structure which contains a buffer holding the string data and a field holding
the buffer length. This contrasts with normal C strings which are repesented as
a buffer for the string data which is terminated with a NUL (0) byte.

Although not a strict requirement, ASN.1 strings that are parsed using OpenSSL's
own "d2i" functions (and other similar parsing functions) as well as any string
whose value has been set with the ASN1_STRING_set() function will additionally
NUL terminate the byte array in the ASN1_STRING structure.

However, it is possible for applications to directly construct valid ASN1_STRING
structures which do not NUL terminate the byte array by directly setting the
"data" and "length" fields in the ASN1_STRING array. This can also happen by
using the ASN1_STRING_set0() function.

Numerous OpenSSL functions that print ASN.1 data have been found to assume that
the ASN1_STRING byte array will be NUL terminated, even though this is not
guaranteed for strings that have been directly constructed. Where an application
requests an ASN.1 structure to be printed, and where that ASN.1 structure
contains ASN1_STRINGs that have been directly constructed by the application
without NUL terminating the "data" field, then a read buffer overrun can occur.

The same thing can also occur during name constraints processing of certificates
(for example if a certificate has been directly constructed by the application
instead of loading it via the OpenSSL parsing functions, and the certificate
contains non NUL terminated ASN1_STRING structures). It can also occur in the
X509_get1_email(), X509_REQ_get1_email() and X509_get1_ocsp() functions.

If a malicious actor can cause an application to directly construct an
ASN1_STRING and then process it through one of the affected OpenSSL functions
then this issue could be hit. This might result in a crash (causing a Denial of
Service attack). It could also result in the disclosure of private memory
contents (such as private keys, or sensitive plaintext).

OpenSSL versions 1.1.1k and below are affected by this issue. Users of these
versions should upgrade to OpenSSL 1.1.1l.

OpenSSL versions 1.0.2y and below are affected by this issue. However OpenSSL
1.0.2 is out of support and no longer receiving public updates. Premium support
customers of OpenSSL 1.0.2 should upgrade to 1.0.2z. Other users should upgrade
to 1.1.1l.

An initial instance of this issue in the X509_aux_print() function was reported
to OpenSSL on 18th July 2021 by Ingo Schwarze. The bugfix was developed by Ingo
Schwarze and first publicly released in OpenBSD-current on 10th July 2021 and
subsequently in OpenSSL on 20th July 2021 (commit d9d838d). Subsequent
analysis by David Benjamin on 17th August 2021 identified more instances of the
same bug. Additional analysis was performed by Matt Caswell. Fixes for the
additional instances of this issue were developed by Matt Caswell.

Comment 6 Cedric Buissart 2021-08-20 13:16:22 UTC
Description of the flaw:

It was found that several functions internal to openssl were assuming thata given string would be NUL ('\0') terminated.

However, it may happen that a given application using openssl libraries is tricked by an attacker into calling these functions with specially crafted, non-NUL terminated strings.

This would result in these functions reading past the string's allocated buffer, into the application memory (until a NUL byte is read).

This may result in the crash of the application, or, if the attacker is able to retrieve the content read, disclosure of the application's memory.

The affected functions are X.509 certificate related, and likely used for logging purpose. The memory disclosure is thus likely to be local only (not sent back to a remote attacker).

Comment 13 Cedric Buissart 2021-08-24 16:06:29 UTC
Created mingw-openssl tracking bugs for this issue:

Affects: fedora-all [bug 1997221]


Created openssl tracking bugs for this issue:

Affects: fedora-all [bug 1997219]


Created openssl11 tracking bugs for this issue:

Affects: epel-7 [bug 1997220]

Comment 22 errata-xmlrpc 2021-11-10 17:15:55 UTC
This issue has been addressed in the following products:

  Red Hat JBoss Core Services

Via RHSA-2021:4613 https://access.redhat.com/errata/RHSA-2021:4613

Comment 23 errata-xmlrpc 2021-11-10 17:19:21 UTC
This issue has been addressed in the following products:

  JBoss Core Services on RHEL 7
  JBoss Core Services for RHEL 8

Via RHSA-2021:4614 https://access.redhat.com/errata/RHSA-2021:4614

Comment 24 errata-xmlrpc 2021-11-11 18:32:25 UTC
This issue has been addressed in the following products:

  Red Hat Advanced Cluster Management for Kubernetes 2.4 for RHEL 8

Via RHSA-2021:4618 https://access.redhat.com/errata/RHSA-2021:4618

Comment 25 Product Security DevOps Team 2021-11-11 18:57:40 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2021-3712

Comment 28 errata-xmlrpc 2021-12-21 09:42:14 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2021:5226 https://access.redhat.com/errata/RHSA-2021:5226

Comment 29 errata-xmlrpc 2022-01-11 17:30:30 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2022:0064 https://access.redhat.com/errata/RHSA-2022:0064

Comment 30 Dennixx 2022-01-13 09:08:38 UTC
There seems to be a bug in the fix for RHEL7 which crashes Apache or nginx. See bugzilla id 2039993


Note You need to log in before you can comment on or make changes to this bug.