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