1 - DRAFT - XXX - DRAFT -
3 fetchmail-SA-2010-02: Denial of service in debug mode w/ multichar locales
5 Topics: Denial of service in debug output.
7 Author: Matthias Andree
10 Type: malloc() Buffer overrun with printable characters
11 Impact: Denial of service.
14 CVE Name: CVE-2010-XXXX
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-18 Git (XXX)
29 2010-04-18 0.1 first draft (visible in SVN and through oss-security)
36 fetchmail is a software package to retrieve mail from remote POP2, POP3,
37 IMAP, ETRN or ODMR servers and forward it to local SMTP, LMTP servers or
38 message delivery agents. It supports SSL and TLS security layers through
39 the OpenSSL library, if enabled at compile time and if also enabled at
43 2. Problem description and Impact
44 =================================
46 In debug mode (-v -v), fetchmail prints information that was obtained from the
47 upstream server (POP3 UIDL lists) or from message headers retrieved from it.
48 If printing such information fails, for instance because there are invalid
49 multibyte character sequences in this information (message headers), fetchmail
50 will misinterpret this condition, and believe that the buffer was too small,
51 and reallocate a bigger one (with linearly increasing buffer size), and repeat,
52 until the allocation fails. At that point, fetchmail will abort.
54 Note that the "Affects:" line above may be inaccurate, and it may be that
55 versions before 5.6.6 are actually unaffected. The author was unable to
56 compile such old fetchmail versions to verify the existence of the bug.
57 Given that other security issues are present in such versions, those should
58 not be used, and the wider version range was listed as vulnerable to err
65 There are two alternatives, either of them by itself is sufficient:
67 a. Apply the patch found in section B of this announcement to
68 fetchmail 6.3.14 or newer, recompile and reinstall it.
70 b. Install fetchmail 6.3.17 or newer after it will have become available.
71 The fetchmail source code is always available from
72 <http://developer.berlios.de/project/showfiles.php?group_id=1824>.
78 Run fetchmail with at most one -v (--verbose) option.
81 A. Copyright, License and Warranty
82 ==================================
84 (C) Copyright 2010 by Matthias Andree, <matthias.andree@gmx.de>.
87 This work is licensed under the Creative Commons
88 Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
89 To view a copy of this license, visit
90 http://creativecommons.org/licenses/by-nc-nd/3.0/de/ or send a letter to
95 SAN FRANCISCO, CALIFORNIA 94105
99 THIS WORK IS PROVIDED FREE OF CHARGE AND WITHOUT ANY WARRANTIES.
100 Use the information herein at your own risk.
103 B. Patch to remedy the problem
104 ==============================
106 Note that when taking this from a GnuPG clearsigned file, the lines
107 starting with a "-" character are prefixed by another "- " (dash +
108 blank) combination. Either feed this file through GnuPG to strip them,
109 or strip them manually. You may want to use the "-p1" flag to patch.
111 Whitespace differences can usually be ignored by invoking "patch -l",
112 so try this if the patch does not apply.
114 diff --git a/rfc822.c b/rfc822.c
115 index 6f2dbf3..dbcda32 100644
118 @@ -25,6 +25,7 @@ MIT license. Compile with -DMAIN to build the demonstrator.
121 #include "fetchmail.h"
126 @@ -74,9 +75,10 @@ char *reply_hack(
130 - if (outlevel >= O_DEBUG)
131 - report_build(stdout, GT_("About to rewrite %.*s...\n"),
132 - (int)BEFORE_EOL(buf), buf);
133 + if (outlevel >= O_DEBUG) {
134 + report_build(stdout, GT_("About to rewrite %s...\n"), (cp = sdump(buf, BEFORE_EOL(buf))));
138 /* make room to hack the address; buf must be malloced */
139 for (cp = buf; *cp; cp++)
140 @@ -211,9 +213,12 @@ char *reply_hack(
144 - if (outlevel >= O_DEBUG)
145 - report_complete(stdout, GT_("...rewritten version is %.*s.\n"),
146 - (int)BEFORE_EOL(buf), buf);
147 + if (outlevel >= O_DEBUG) {
148 + report_complete(stdout, GT_("...rewritten version is %s.\n"),
149 + (cp = sdump(buf, BEFORE_EOL(buf))));
154 *length = strlen(buf);
156 diff --git a/uid.c b/uid.c
157 index fdc6f5d..d813bee 100644
162 #include "fetchmail.h"
167 * Machinery for handling UID lists live here. This is mainly to support
168 @@ -260,8 +261,11 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile)
171 report_build(stdout, GT_("Scratch list of UIDs:"));
172 - for (idp = scratchlist; idp; idp = idp->next)
173 - report_build(stdout, " %s", idp->id);
174 + for (idp = scratchlist; idp; idp = idp->next) {
175 + char *t = sdump(idp->id, strlen(idp->id));
176 + report_build(stdout, " %s", t);
180 report_build(stdout, GT_(" <empty>"));
181 report_complete(stdout, "\n");
182 @@ -517,8 +521,11 @@ void uid_swap_lists(struct query *ctl)
183 report_build(stdout, GT_("Merged UID list from %s:"), ctl->server.pollname);
185 report_build(stdout, GT_("New UID list from %s:"), ctl->server.pollname);
186 - for (idp = dofastuidl ? ctl->oldsaved : ctl->newsaved; idp; idp = idp->next)
187 - report_build(stdout, " %s = %d", idp->id, idp->val.status.mark);
188 + for (idp = dofastuidl ? ctl->oldsaved : ctl->newsaved; idp; idp = idp->next) {
189 + char *t = sdump(idp->id, strlen(idp->id));
190 + report_build(stdout, " %s = %d", t, idp->val.status.mark);
194 report_build(stdout, GT_(" <empty>"));
195 report_complete(stdout, "\n");
196 @@ -567,8 +574,11 @@ void uid_discard_new_list(struct query *ctl)
197 /* this is now a merged list! the mails which were seen in this
198 * poll are marked here. */
199 report_build(stdout, GT_("Merged UID list from %s:"), ctl->server.pollname);
200 - for (idp = ctl->oldsaved; idp; idp = idp->next)
201 - report_build(stdout, " %s = %d", idp->id, idp->val.status.mark);
202 + for (idp = ctl->oldsaved; idp; idp = idp->next) {
203 + char *t = sdump(idp->id, strlen(idp->id));
204 + report_build(stdout, " %s = %d", t, idp->val.status.mark);
208 report_build(stdout, GT_(" <empty>"));
209 report_complete(stdout, "\n");