UPDATED fetchmail security announcement 2021-01 (CVE-2021-36386) - potential denial of service or information disclosure in some configurations - update contains regression fix

Matthias Andree <[email protected]> Mon, 9 Aug 2021 18:50:53 +0200
Newsgroups gmane.mail.fetchmail.announce
Message-ID <YRFc7Tol79seSP4P__35057.2785873496$1628527890$gmane$org@ryzen.an3e.de>
--===============4243552034414717525==
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="BFBMB1Oxr6/3ND7C"
Content-Disposition: inline


--BFBMB1Oxr6/3ND7C
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

TL;DR Summary: While fetchmail 6.4.20 fixed CVE-2021-36386, it=20
introduced a bug WRT buffered logging that got fixed in 6.4.21.

Packagers should either upgrade all the way to 6.4.21, or pick the=20
near-trivial regression fix from section #3 below or Git commit d3db2da1=20
can be cherry-picked from the GitLab or SourceForge repos.

Updated security announcement follows:
--------------------------------------------------------------------

fetchmail-SA-2021-01: DoS or information disclosure logging long messages

Topics:		fetchmail denial of service or information disclosure when logging=
 long messages

Author:		Matthias Andree
Version:	1.3
Announced:	2021-07-28 (original), 2021-08-09 (last update)
Type:		missing variable initialization can cause read from bad memory
		locations
Impact:		fetchmail logs random information, or segfaults and aborts,
		stalling inbound mail
Danger:		low
Acknowledgment:	Christian Herdtweck, Intra2net AG, T=FCbingen, Germany
		for analysis and report and a patch suggestion

CVE Name:	CVE-2021-36386 and CVE-2008-2711
URL:		https://www.fetchmail.info/fetchmail-SA-2021-01.txt
URL:		https://www.fetchmail.info/fetchmail-SA-2008-01.txt
Project URL:	https://www.fetchmail.info/

Affects:	- fetchmail releases up to and including 6.3.8
		- fetchmail releases 6.3.17 up to incl. 6.4.19
		  (but note 6.4.20 regresses for buffered output,
		   f.i. with --logfile)

Not affected:	- fetchmail releases 6.4.21 and newer
		  (fetchmail 6.4.20 fixes the immediate bug but regresses
		   and causes message truncation on buffered output)
		- fetchmail releases 6.3.9 to 6.3.16

Corrected in:	c546c829 + d3db2da1 Git commit hash (both needed)
		2021-08-09 fetchmail 6.4.21 release tarball

0. Release history
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

2021-07-07	initial report to maintainer
2021-07-28 1.0	release
2021-07-28 1.1	update Git commit hash with correction
2021-08-03 1.2  add references to CVE-2008-2711/fetchmail-SA-2008-01
2021-08-09 1.3  mention buffered logging regression (--logfile)


1. Background
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

fetchmail is a software package to retrieve mail from remote POP3, IMAP,
ETRN or ODMR servers and forward it to local SMTP, LMTP servers or
message delivery agents. fetchmail supports SSL and TLS security layers
through the OpenSSL library, if enabled at compile time and if also
enabled at run time, in both SSL/TLS-wrapped mode on dedicated ports as
well as in-band-negotiated "STARTTLS" and "STLS" modes through the
regular protocol ports.


2. Problem description and Impact
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D

Fetchmail has long had support to assemble log/error messages that are
generated piecemeal, and takes care to reallocate the output buffer as need=
ed.
In the reallocation case, i. e. when long log messages are assembled that c=
an
stem from very long headers, and on systems that have a varargs.h/stdarg.h
interface (all modern systems), fetchmail's code would fail to reinitialize
the va_list argument to vsnprintf.

The exact effects depend on the verbose mode (how many -v are given) of
fetchmail, computer architecture, compiler, operating system and
configuration.  On some systems, the code just works without ill effects, s=
ome
systems log a garbage message (potentially disclosing sensitive information=
),
some systems log literally "(null)", some systems trigger SIGSEGV (signal
#11), which crashes fetchmail, causing a denial of service on fetchmail's e=
nd.

The same bug then named CVE-2008-2711 had already been fixed in fetchmail 6=
=2E3.9,
but a code refactoring in fetchmail 6.3.17 (commit 414a3809 in 2010)
reintroduced the bug.
Fetchmail versions 6.4.19 and older are no longer supported, however.

The bugfix used in 6.4.20 uses a different, more thorough, approach.


3. Solution
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Install fetchmail 6.4.21 or newer.

The fetchmail source code is available from
<https://sourceforge.net/projects/fetchmail/files/>.

Distributors are encouraged to review the NEWS file and move forward to
6.4.21, rather than backport individual security fixes, because doing so
routinely misses other fixes crucial to fetchmail's proper operation,
for which no security announcements are issued, or documentation,
or translation updates.

The regression fix for the new non-security bug in 6.4.20 that causes
log message truncation simply consists of editing report.c to rotate lines =
289
through 291, such that the /corrected/ report.c then looks like this:

   286	    n =3D snprintf (partial_message + partial_message_size_used,
   287			    partial_message_size - partial_message_size_used,
   288			    message, a1, a2, a3, a4, a5, a6, a7, a8);
   289
   290	    if (n > 0) partial_message_size_used +=3D n;
   291	#endif
   292
   293	    if (unbuffered && partial_message_size_used !=3D 0)


Fetchmail 6.4.X releases have been made with a focus on unchanged user and
program interfaces so as to avoid disruptions when upgrading from 6.3.Z or
6.4.X to 6.4.Y with Y > X.  Care was taken to not change the interface
incompatibly.


A. Copyright, License and Non-Warranty
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

(C) Copyright 2021 by Matthias Andree, <[email protected]>.
Some rights reserved.

fetchmail-SA-2021-01 =A9 2021 by Matthias Andree is licensed under CC
BY-ND 4.0. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nd/4.0/

THIS WORK IS PROVIDED FREE OF CHARGE AND WITHOUT ANY WARRANTIES.
Use the information herein at your own risk.

END of fetchmail-SA-2021-01

--BFBMB1Oxr6/3ND7C
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE3EplW9mTzUhx+oIQ5BKxVu/zhVoFAmERXOwACgkQ5BKxVu/z
hVpNOhAAj2J0hgiRhwW5TOhVDeiiEIYSnvRkCGdFf3Tlw2hYUsAvdMvwy3oKUjG6
V5v5+IvGliLSQ8r69+CC+Banp0mbNQRg5mmGlQQp7syj9m3eF3XbBlY4ogdPA7rL
v0D44m8pmd/Q9Hs+GnS1ffgscewk4P14R/Iuk83u6+ebPV4HWwySEMPoVnqLJmiI
6Ey4eriS3/mgsHevlJ1OhkNh771/1nd2rW2gwGWA51XGpQukMfRS1XSGgzbbitL9
OSDX2Mh3K8JSIWMs7w9F4meIaQq/c3pp4nP06Z8CWnmGaPxzBb/gul0NrB0Q8tCe
VcAfXcvPmXV8MPQ6XYu3P672L/sCFDILooIJLsS7cfmNMNnk/zgTWdL1W133tlXc
ndYEfbNHvoHwcaoAmAMNL2LIUa8hqB6lhKfH8dM6SzMj/7Tes1M5jLGgO0RO7lC4
PQLtX0kIMa9fX1FbeOBkIDWci7W/of4Q2J1pO2PzOF8G13ldyWzz1Xkj4Aa4X7v+
CSNBxFCetbdeTQRxaBh4P+8am3pQhfFm5s/vRlXxW764lODLXeg2YQpOSNAkmt7T
8hUPKOjsMJC9PZoI4mKz5NO5eRchPgT52zcF3syKcrV+EGU1vj1XiLoCCG7cx6M8
68D7K07xtNWURYmCwiU31oxyfR06aPBwQ5dm3bSDwcppkz7lmEg=
=j2MI
-----END PGP SIGNATURE-----

--BFBMB1Oxr6/3ND7C--


--===============4243552034414717525==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============4243552034414717525==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Fetchmail-announce mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fetchmail-announce

--===============4243552034414717525==--