-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-SA-21:16.openssl                                    Security Advisory
                                                          The FreeBSD Project

Topic:          Multiple OpenSSL vulnerabilities

Category:       contrib
Module:         openssl
Announced:      2021-08-24
Credits:        See OpenSSL advisory in references.
Affects:        FreeBSD 12.2 and later.
Corrected:      2021-08-24 18:05:48 UTC (stable/13, 13.0-STABLE)
                2021-08-24 18:08:04 UTC (releng/13.0, 13.0-RELEASE-p4)
                2021-08-24 18:30:22 UTC (stable/12, 12.2-STABLE)
                2021-08-24 18:32:19 UTC (releng/12.2, 12.2-RELEASE-p10)
CVE Name:       CVE-2021-3711, CVE-2021-3712

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:https://security.FreeBSD.org/>.

I.   Background

FreeBSD includes software from the OpenSSL Project.  The OpenSSL Project is a
collaborative effort to develop a robust, commercial-grade, full-featured
Open Source toolkit for the Transport Layer Security (TLS) protocol.  It is
also a general-purpose cryptography library.

II.  Problem Description

There are two issues fixed in this security advisory:

A bug in the SM2 decryption implementation incorrectly calculates a buffer
needed to hold the plaintext leading to a potential buffer overflow.
[CVE-2021-3711]

ASN1_STRING structures directly constructed, instead of using library
functions, may not be NULL-terminated resulting in library functions causing
a read buffer overrun. [CVE-2021-3712]

III. Impact

Specially crafted decrypted SM2 content could cause attacker chosen data to
overflow the buffer changing application behavior or causing the application
to crash. [CVE-2021-3711]

A specially crafted malicious string can cause an application that directly
constructs the ASN1_STRING structure to crash or disclose memory contents.
[CVE-2021-3712]

IV.  Workaround

No workaround is available.

V.   Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date.

Perform one of the following:

1) To update your vulnerable system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or
(on FreeBSD 13 and later) arm64 platforms can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install

2) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

[FreeBSD 13.0]
# fetch https://security.FreeBSD.org/patches/SA-21:16/openssl.13.patch
# fetch https://security.FreeBSD.org/patches/SA-21:16/openssl.13.patch.asc
# gpg --verify openssl.13.patch.asc

[FreeBSD 12.2]
# fetch https://security.FreeBSD.org/patches/SA-21:16/openssl.12.patch
# fetch https://security.FreeBSD.org/patches/SA-21:16/openssl.12.patch.asc
# gpg --verify openssl.12.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile the operating system using buildworld and installworld as
described in <URL:https://www.FreeBSD.org/handbook/makeworld.html>.

Restart all daemons that use the library, or reboot the system.

VI.  Correction details

This issue is corrected by the corresponding Git commit hash or Subversion
revision number in the following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/13/                              9d31ae318711    stable/13-n246940
releng/13.0/                            2261c814b7fa  releng/13.0-n244759
stable/12/                                                        r370385
releng/12.2/                                                      r370396
- -------------------------------------------------------------------------

For FreeBSD 13 and later:

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing NNNNNN with the hash:

<URL:https://cgit.freebsd.org/src/commit/?id=NNNNNN>

To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

For FreeBSD 12 and earlier:

Run the following command to see which files were modified by a particular
revision, replacing NNNNNN with the revision number:

# svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base

Or visit the following URL, replacing NNNNNN with the revision number:

<URL:https://svnweb.freebsd.org/base?view=revision&revision=NNNNNN>

VII. References

<URL:https://www.openssl.org/news/secadv/20210824.txt>

<URL:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3711>

<URL:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3712>

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-21:16.openssl.asc>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmElV18ACgkQ05eS9J6n
5cLnrA//XoiClJmvm+5GKDzP6IbDIxRyS7NkDxMWY/7Q/QvPs8fFrFdXiD4qJOcz
VTElfioKTv2X7j+X5TO4zRKjg86Lb94gSXtgOLeK2tWticksZ3o5WPLXXjI0ohBo
M1VhMJoJc3p2Oam9yPOdfnllCTJYV5ZqmcBL2FZCYWdkebZWkpHgrImZ53yQ87jm
IK4fy+El47l3Jb2K6P5S1eeW3e3CElbkUgNkSIJsl5Z9hdrTrd3We6FSE8QQjXn+
OsQw5s6VDhHzFG34x9CIhqpjWQTX5izdlaeSunMXHwe3Vp5CoRpl/sq1r53PJG1j
nnY7X4Csgbv48rRm6KXOCHDzEatNvmdnBmEzcanIUXer//tra97Zd/wlWepV0hwK
T4TcJly/74DH+tW6TQ78/UC0EkxeTqc/I1Qu41jBIH1KDfDs7OqKiftHo2wOJjQa
43DlAr6eEbRAZ2l1e+ATJs0r6ao1BCUnB+Fpc4cnBLaft9G3DYCAmWI4wUKRSRAU
n880U3kjSTtVDfLTkUQ33QSg0uqduVEjt9XWe/SV9RoL8xHqtvk/CIS+aFAqPbR4
62yaTQCrUdidkeqn7/XVScCuZ27bWCJpqWHGtihTnm3yfM09NtYIjozyngf2duaJ
0RFuewl1kvYo5Xsu54TuO36dQQdmJU0qayKEpWZ1+NadgJUMAJY=
=8I/t
-----END PGP SIGNATURE-----
