1 fetchmail-SA-2010-02: Denial of service in debug mode w/ multichar locales
3 Topics: Denial of service in debug output
5 Author: Matthias Andree
8 Type: Unbounded allocation of memory until exhaustion
9 Impact: Denial of service
12 CVE Name: CVE-2010-1167
13 CVSSv2: (AV:N/AC:M/Au:N/C:N/I:N/A:P/E:U/RL:O/RC:C)
14 CVSS scores: 3.2, Base 4.3 (Impact 2.9, Exploitability 8.6), Temporal 3.2
15 This is calculated without Environmental Score.
16 URL: http://www.fetchmail.info/fetchmail-SA-2010-02.txt
17 Project URL: http://www.fetchmail.info/
19 Affects: fetchmail releases 4.6.3 up to and including 6.3.16
21 Not affected: fetchmail release 6.3.17 and newer
23 Corrected: 2010-04-24 Git, required commits:
24 167fa2093e82f891eb2fcb6eaa0b1eb3685f44e3
25 ec06293134b85876f9201d8a52b844c41581b2b3
27 2010-04-30 fetchmail 6.3.17-pre1 tarball
29 2010-05-06 fetchmail 6.3.17 release tarball
35 2010-04-18 0.1 first draft (visible in SVN and through oss-security)
36 2010-04-19 0.2 add note announcements may appear before releases
37 2010-04-20 0.3 add CVE name, fix Type:
38 2010-04-24 0.4 revise patch
39 2010-04-29 0.5 add info on contributing/mitigating factors
40 2010-05-06 1.0 complete
46 fetchmail is a software package to retrieve mail from remote POP2, POP3,
47 IMAP, ETRN or ODMR servers and forward it to local SMTP, LMTP servers or
48 message delivery agents. It supports SSL and TLS security layers through
49 the OpenSSL library, if enabled at compile time and if also enabled at
53 2. Problem description and Impact
54 =================================
56 In debug mode (-v -v), fetchmail prints information that was obtained from the
57 upstream server (POP3 UIDL lists) or from message headers retrieved from it.
58 If printing such information fails, for instance because there are invalid
59 multibyte character sequences in this information (message headers), fetchmail
60 will misinterpret this condition, and believe that the buffer was too small,
61 and reallocate a bigger one (with linearly increasing buffer size), and repeat,
62 until the allocation fails. At that point, fetchmail will abort.
64 The exact combination of contributing and mitigating factors is not
65 fully understood; GNU glibc 2.7 and 2.10.1 on i586 report EILSEQ when
66 printing invalid sequences through a %.*s format string in multibyte
67 locales such as de_DE.UTF-8; NetBSD 5, FreeBSD 8 and Solaris 10 do not.
68 However, the issue is a genuine fetchmail bug that deserves a fix.
70 Note that the "Affects:" line above may be inaccurate, and it may be that
71 versions before 5.6.6 are actually unaffected. The author was unable to
72 compile such old fetchmail versions to verify the existence of the bug.
73 Given that other security issues are present in such versions, those should
74 not be used, and the wider version range was listed as vulnerable to err
81 There are two alternatives, either of them by itself is sufficient:
83 a. Apply the patch found in section B of this announcement to
84 fetchmail 6.3.14 or newer, recompile and reinstall it.
86 b. Install fetchmail 6.3.17 or newer after it will have become available.
87 (Note that the announcements may be publicly visible quite some time
88 before the release is made, particularly for minor bugs.)
89 The fetchmail source code is always available from
90 <http://developer.berlios.de/project/showfiles.php?group_id=1824>.
96 Run fetchmail with at most one -v (--verbose) option.
99 A. Copyright, License and Warranty
100 ==================================
102 (C) Copyright 2010 by Matthias Andree, <matthias.andree@gmx.de>.
103 Some rights reserved.
105 This work is licensed under the Creative Commons
106 Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
107 To view a copy of this license, visit
108 http://creativecommons.org/licenses/by-nc-nd/3.0/de/ or send a letter to
113 SAN FRANCISCO, CALIFORNIA 94105
117 THIS WORK IS PROVIDED FREE OF CHARGE AND WITHOUT ANY WARRANTIES.
118 Use the information herein at your own risk.
121 B. Patch to remedy the problem
122 ==============================
124 Note that when taking this from a GnuPG clearsigned file, the lines
125 starting with a "-" character are prefixed by another "- " (dash +
126 blank) combination. Either feed this file through GnuPG to strip them,
127 or strip them manually. You may want to use the "-p1" flag to patch.
129 Whitespace differences can usually be ignored by invoking "patch -l",
130 so try this if the patch does not apply.
132 diff --git a/rfc822.c b/rfc822.c
133 index 6f2dbf3..dbcda32 100644
136 @@ -25,6 +25,7 @@ MIT license. Compile with -DMAIN to build the demonstrator.
139 #include "fetchmail.h"
144 @@ -74,9 +75,10 @@ char *reply_hack(
148 - if (outlevel >= O_DEBUG)
149 - report_build(stdout, GT_("About to rewrite %.*s...\n"),
150 - (int)BEFORE_EOL(buf), buf);
151 + if (outlevel >= O_DEBUG) {
152 + report_build(stdout, GT_("About to rewrite %s...\n"), (cp = sdump(buf, BEFORE_EOL(buf))));
156 /* make room to hack the address; buf must be malloced */
157 for (cp = buf; *cp; cp++)
158 @@ -211,9 +213,12 @@ char *reply_hack(
162 - if (outlevel >= O_DEBUG)
163 - report_complete(stdout, GT_("...rewritten version is %.*s.\n"),
164 - (int)BEFORE_EOL(buf), buf);
165 + if (outlevel >= O_DEBUG) {
166 + report_complete(stdout, GT_("...rewritten version is %s.\n"),
167 + (cp = sdump(buf, BEFORE_EOL(buf))));
172 *length = strlen(buf);
174 diff --git a/uid.c b/uid.c
175 index fdc6f5d..9a62ee2 100644
180 #include "fetchmail.h"
185 * Machinery for handling UID lists live here. This is mainly to support
186 @@ -249,8 +250,11 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile)
188 report_build(stdout, GT_("Old UID list from %s:"),
189 ctl->server.pollname);
190 - for (idp = ctl->oldsaved; idp; idp = idp->next)
191 - report_build(stdout, " %s", idp->id);
192 + for (idp = ctl->oldsaved; idp; idp = idp->next) {
193 + char *t = sdump(idp->id, strlen(idp->id));
194 + report_build(stdout, " %s", t);
198 report_build(stdout, GT_(" <empty>"));
199 report_complete(stdout, "\n");
200 @@ -260,8 +264,11 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile)
203 report_build(stdout, GT_("Scratch list of UIDs:"));
204 - for (idp = scratchlist; idp; idp = idp->next)
205 - report_build(stdout, " %s", idp->id);
206 + for (idp = scratchlist; idp; idp = idp->next) {
207 + char *t = sdump(idp->id, strlen(idp->id));
208 + report_build(stdout, " %s", t);
212 report_build(stdout, GT_(" <empty>"));
213 report_complete(stdout, "\n");
214 @@ -517,8 +524,11 @@ void uid_swap_lists(struct query *ctl)
215 report_build(stdout, GT_("Merged UID list from %s:"), ctl->server.pollname);
217 report_build(stdout, GT_("New UID list from %s:"), ctl->server.pollname);
218 - for (idp = dofastuidl ? ctl->oldsaved : ctl->newsaved; idp; idp = idp->next)
219 - report_build(stdout, " %s = %d", idp->id, idp->val.status.mark);
220 + for (idp = dofastuidl ? ctl->oldsaved : ctl->newsaved; idp; idp = idp->next) {
221 + char *t = sdump(idp->id, strlen(idp->id));
222 + report_build(stdout, " %s = %d", t, idp->val.status.mark);
226 report_build(stdout, GT_(" <empty>"));
227 report_complete(stdout, "\n");
228 @@ -567,8 +577,11 @@ void uid_discard_new_list(struct query *ctl)
229 /* this is now a merged list! the mails which were seen in this
230 * poll are marked here. */
231 report_build(stdout, GT_("Merged UID list from %s:"), ctl->server.pollname);
232 - for (idp = ctl->oldsaved; idp; idp = idp->next)
233 - report_build(stdout, " %s = %d", idp->id, idp->val.status.mark);
234 + for (idp = ctl->oldsaved; idp; idp = idp->next) {
235 + char *t = sdump(idp->id, strlen(idp->id));
236 + report_build(stdout, " %s = %d", t, idp->val.status.mark);
240 report_build(stdout, GT_(" <empty>"));
241 report_complete(stdout, "\n");