
=====================================================================

                             CERT-Renater

                 Note d'Information No. 2021/VULN464
_____________________________________________________________________

DATE                : 15/09/2021

HARDWARE PLATFORM(S): /

OPERATING SYSTEM(S): Systems running curl versions from 7.20.0 and prior
                                          to 7.79.0.

=====================================================================
https://curl.se/docs/CVE-2021-22945.html
https://curl.se/docs/CVE-2021-22946.html
https://curl.se/docs/CVE-2021-22947.html
_____________________________________________________________________

UAF and double-free in MQTT sending
===================================

Project curl Security Advisory, September 15th 2021 -
[Permalink](https://curl.se/docs/CVE-2021-22945.html)

VULNERABILITY
-------------

When sending data to an MQTT server, libcurl could in some circumstances
erroneously keep a pointer to an already freed memory area and both use
that again in a subsequent call to send data and also free it *again*.

We are not aware of any case of this flaw having been exploited in the wild.

INFO
----

This flaw was introduced in commit
[2522903b79](https://github.com/curl/curl/commit/2522903b79) but since
MQTT support was marked 'experimental' then and not enabled in the build
by default until curl 7.73.0 (October 14, 2020) we count that as the
first flawed version.

The fixed libcurl version properly clears the pointer when the data has
been sent.

The Common Vulnerabilities and Exposures (CVE) project has assigned the
name CVE-2021-22945 to this issue.

CWE-415: Double Free

Severity: Medium

AFFECTED VERSIONS
-----------------

- Affected versions: curl 7.73.0 to and including 7.78.0
- Not affected versions: curl < 7.73.0 and curl >= 7.79.0

Also note that libcurl is used by many applications, and not always
advertised as such.

THE SOLUTION
------------

A [fix for
CVE-2021-22945](https://github.com/curl/curl/commit/43157490a5054bd)

RECOMMENDATIONS
--------------

 A - Upgrade curl to version 7.79.0

 B - Apply the patch to your local version

 C - Do not use MQTT

TIMELINE
--------

This issue was reported to the curl project on July 19, 2021.

This advisory was posted on September 15, 2021.

CREDITS
-------

This issue was reported and patched by z2_.

Thanks a lot!



 / daniel.haxx.se
 | Commercial curl support up to 24x7 is available!
 | Private help, bug fixes, support, ports, new features
 | https://curl.se/support.html

_____________________________________________________________________

Protocol downgrade required TLS bypassed
========================================

Project curl Security Advisory, September 15th 2021 -
[Permalink](https://curl.se/docs/CVE-2021-22946.html)

VULNERABILITY
-------------

A user can tell curl to **require** a successful upgrade to TLS when
speaking to an IMAP, POP3 or FTP server (`--ssl-reqd` on the command
line or `CURLOPT_USE_SSL` set to `CURLUSESSL_CONTROL` or
`CURLUSESSL_ALL` with libcurl). This requirement could be bypassed if
the server would return a properly crafted but perfectly legitimate
response.

This flaw would then make curl silently continue its operations
**without TLS** contrary to the instructions and expectations, exposing
possibly sensitive data in clear text over the network.

We are not aware of any case of this flaw having been exploited in the
wild.

INFO
----

This flaw was first introduced in commit
[ec3bb8f727405](https://github.com/curl/curl/commit/ec3bb8f727405) for
IMAP and POP3 and in
[c5ba0c2f544653](https://github.com/curl/curl/commit/c5ba0c2f544653) for
FTP.

SMTP also features a similar TLS upgrade method, but that code in curl
doesn't suffer from this bug.

The Common Vulnerabilities and Exposures (CVE) project has assigned the
name CVE-2021-22946 to this issue.

CWE-325: Missing Cryptographic Step

Severity: Medium

AFFECTED VERSIONS
-----------------

- Affected versions: curl 7.20.0 to and including 7.78.0
- Not affected versions: curl < 7.20.0 and curl >= 7.79.0

Also note that libcurl is used by many applications, and not always
advertised as such.

THE SOLUTION
------------

A [fix for
CVE-2021-22946](https://github.com/curl/curl/commit/364f174724ef115)

RECOMMENDATIONS
--------------

 A - Upgrade curl to version 7.79.0

 B - Apply the patch to your local version

 C - Do not use IMAP, POP3 or FTP

TIMELINE
--------

This issue was reported to the curl project on September 8, 2021.

This advisory was posted on September 15, 2021.

CREDITS
-------

This issue was reported and patched by Patrick Monnerat.

Thanks a lot!



 / daniel.haxx.se
 | Commercial curl support up to 24x7 is available!
 | Private help, bug fixes, support, ports, new features
 | https://curl.se/support.html
_____________________________________________________________________

STARTTLS protocol injection via MITM
====================================

Project curl Security Advisory, September 15th 2021 -
[Permalink](https://curl.se/docs/CVE-2021-22947.html)

VULNERABILITY
-------------

When curl connects to an IMAP, POP3, SMTP or FTP server to exchange data
securely using STARTTLS to upgrade the connection to TLS level, the
server can still respond and send back multiple responses before the TLS
upgrade. Such multiple "pipelined" responses are cached by curl. curl
would then upgrade to TLS but not flush the in-queue of cached responses
and instead use and trust the responses it got *before* the TLS
handshake as if they were authenticated.

Using this flaw, it allows a Man-In-The-Middle attacker to first inject
the fake responses, then pass-through the TLS traffic from the
legitimate server and trick curl into sending data back to the user
thinking the attacker's injected data comes from the TLS-protected
server.

Over POP3 and IMAP an attacker can inject fake response data.

We are not aware of any case of this flaw having been exploited in the
wild.

INFO
----

This flaw was first introduced in commit
[ec3bb8f727405](https://github.com/curl/curl/commit/ec3bb8f727405).

The Common Vulnerabilities and Exposures (CVE) project has assigned the
name CVE-2021-22947 to this issue.

CWE-349: Acceptance of Extraneous Untrusted Data With Trusted Data

Severity: Medium

AFFECTED VERSIONS
-----------------

- Affected versions: curl 7.20.0 to and including 7.78.0
- Not affected versions: curl < 7.20.0 and curl >= 7.79.0

Also note that libcurl is used by many applications, and not always
advertised as such.

THE SOLUTION
------------

A [fix for
CVE-2021-22947](https://github.com/curl/curl/commit/8ef147c43646e91)

RECOMMENDATIONS
--------------

 A - Upgrade curl to version 7.79.0

 B - Apply the patch to your local version

 C - Do not use IMAP, POP3, SMTP or FTP with explicit TLS

TIMELINE
--------

This issue was reported to the curl project on September 7, 2021.

This advisory was posted on September 15, 2021.

CREDITS
-------

This issue was reported and patched by Patrick Monnerat.

Thanks a lot!



 / daniel.haxx.se
 | Commercial curl support up to 24x7 is available!
 | Private help, bug fixes, support, ports, new features
 | https://curl.se/support.html


=========================================================
+ CERT-RENATER       |    tel : 01-53-94-20-44          +
+ 23/25 Rue Daviel   |    fax : 01-53-94-20-41          +
+ 75013 Paris        |    email:cert@support.renater.fr +
=========================================================



