]> Pileus Git - ~andy/fetchmail/blob - fetchmail-SA-2010-02.txt
Add a note that security announcements may appear before releases.
[~andy/fetchmail] / fetchmail-SA-2010-02.txt
1 - DRAFT - XXX - DRAFT -
2
3 fetchmail-SA-2010-02: Denial of service in debug mode w/ multichar locales
4
5 Topics:         Denial of service in debug output.
6
7 Author:         Matthias Andree
8 Version:        0.1 XXX
9 Announced:      XXX
10 Type:           malloc() Buffer overrun with printable characters
11 Impact:         Denial of service.
12 Danger:         low
13
14 CVE Name:       CVE-2010-XXXX
15 CVSSv2:         XXX
16 URL:            http://www.fetchmail.info/fetchmail-SA-2010-02.txt
17 Project URL:    http://www.fetchmail.info/
18
19 Affects:        fetchmail releases 4.6.3 up to and including 6.3.16
20
21 Not affected:   fetchmail release 6.3.17 and newer
22
23 Corrected:      2010-04-18 Git (XXX)
24
25
26 0. Release history
27 ==================
28
29 2010-04-18 0.1  first draft (visible in SVN and through oss-security)
30 XXX
31
32
33 1. Background
34 =============
35
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
40 run time.
41
42
43 2. Problem description and Impact
44 =================================
45
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.
53
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
59 towards the safe.
60
61
62 3. Solution
63 ===========
64
65 There are two alternatives, either of them by itself is sufficient:
66
67 a. Apply the patch found in section B of this announcement to
68    fetchmail 6.3.14 or newer, recompile and reinstall it.
69
70 b. Install fetchmail 6.3.17 or newer after it will have become available.
71    (Note that the announcements may be publicly visible quite some time
72    before the release is made, particularly for minor bugs.)
73    The fetchmail source code is always available from
74    <http://developer.berlios.de/project/showfiles.php?group_id=1824>.
75
76
77 4. Workaround
78 =============
79
80 Run fetchmail with at most one -v (--verbose) option.
81
82
83 A. Copyright, License and Warranty
84 ==================================
85
86 (C) Copyright 2010 by Matthias Andree, <matthias.andree@gmx.de>.
87 Some rights reserved.
88
89 This work is licensed under the Creative Commons
90 Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
91 To view a copy of this license, visit
92 http://creativecommons.org/licenses/by-nc-nd/3.0/de/ or send a letter to
93
94 Creative Commons
95 171 Second Street
96 Suite 300
97 SAN FRANCISCO, CALIFORNIA 94105
98 USA
99
100
101 THIS WORK IS PROVIDED FREE OF CHARGE AND WITHOUT ANY WARRANTIES.
102 Use the information herein at your own risk.
103
104
105 B. Patch to remedy the problem
106 ==============================
107
108 Note that when taking this from a GnuPG clearsigned file, the lines
109 starting with a "-" character are prefixed by another "- " (dash +
110 blank) combination. Either feed this file through GnuPG to strip them,
111 or strip them manually. You may want to use the "-p1" flag to patch.
112
113 Whitespace differences can usually be ignored by invoking "patch -l",
114 so try this if the patch does not apply.
115
116 diff --git a/rfc822.c b/rfc822.c
117 index 6f2dbf3..dbcda32 100644
118 --- a/rfc822.c
119 +++ b/rfc822.c
120 @@ -25,6 +25,7 @@ MIT license.  Compile with -DMAIN to build the demonstrator.
121  #include  <stdlib.h>
122  
123  #include "fetchmail.h"
124 +#include "sdump.h"
125  
126  #ifndef MAIN
127  #include "i18n.h"
128 @@ -74,9 +75,10 @@ char *reply_hack(
129      }
130  
131  #ifndef MAIN
132 -    if (outlevel >= O_DEBUG)
133 -       report_build(stdout, GT_("About to rewrite %.*s...\n"),
134 -                       (int)BEFORE_EOL(buf), buf);
135 +    if (outlevel >= O_DEBUG) {
136 +       report_build(stdout, GT_("About to rewrite %s...\n"), (cp = sdump(buf, BEFORE_EOL(buf))));
137 +       xfree(cp);
138 +    }
139  
140      /* make room to hack the address; buf must be malloced */
141      for (cp = buf; *cp; cp++)
142 @@ -211,9 +213,12 @@ char *reply_hack(
143      }
144  
145  #ifndef MAIN
146 -    if (outlevel >= O_DEBUG)
147 -       report_complete(stdout, GT_("...rewritten version is %.*s.\n"),
148 -                       (int)BEFORE_EOL(buf), buf);
149 +    if (outlevel >= O_DEBUG) {
150 +       report_complete(stdout, GT_("...rewritten version is %s.\n"),
151 +                       (cp = sdump(buf, BEFORE_EOL(buf))));
152 +       xfree(cp)
153 +    }
154 +
155  #endif /* MAIN */
156      *length = strlen(buf);
157      return(buf);
158 diff --git a/uid.c b/uid.c
159 index fdc6f5d..d813bee 100644
160 --- a/uid.c
161 +++ b/uid.c
162 @@ -20,6 +20,7 @@
163  
164  #include "fetchmail.h"
165  #include "i18n.h"
166 +#include "sdump.h"
167  
168  /*
169   * Machinery for handling UID lists live here.  This is mainly to support
170 @@ -260,8 +261,11 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile)
171         if (uidlcount)
172         {
173             report_build(stdout, GT_("Scratch list of UIDs:"));
174 -           for (idp = scratchlist; idp; idp = idp->next)
175 -               report_build(stdout, " %s", idp->id);
176 +           for (idp = scratchlist; idp; idp = idp->next) {
177 +               char *t = sdump(idp->id, strlen(idp->id));
178 +               report_build(stdout, " %s", t);
179 +               free(t);
180 +           }
181             if (!idp)
182                 report_build(stdout, GT_(" <empty>"));
183             report_complete(stdout, "\n");
184 @@ -517,8 +521,11 @@ void uid_swap_lists(struct query *ctl)
185             report_build(stdout, GT_("Merged UID list from %s:"), ctl->server.pollname);
186         else
187             report_build(stdout, GT_("New UID list from %s:"), ctl->server.pollname);
188 -       for (idp = dofastuidl ? ctl->oldsaved : ctl->newsaved; idp; idp = idp->next)
189 -           report_build(stdout, " %s = %d", idp->id, idp->val.status.mark);
190 +       for (idp = dofastuidl ? ctl->oldsaved : ctl->newsaved; idp; idp = idp->next) {
191 +           char *t = sdump(idp->id, strlen(idp->id));
192 +           report_build(stdout, " %s = %d", t, idp->val.status.mark);
193 +           free(t);
194 +        }
195         if (!idp)
196             report_build(stdout, GT_(" <empty>"));
197         report_complete(stdout, "\n");
198 @@ -567,8 +574,11 @@ void uid_discard_new_list(struct query *ctl)
199         /* this is now a merged list! the mails which were seen in this
200          * poll are marked here. */
201         report_build(stdout, GT_("Merged UID list from %s:"), ctl->server.pollname);
202 -       for (idp = ctl->oldsaved; idp; idp = idp->next)
203 -           report_build(stdout, " %s = %d", idp->id, idp->val.status.mark);
204 +       for (idp = ctl->oldsaved; idp; idp = idp->next) {
205 +           char *t = sdump(idp->id, strlen(idp->id));
206 +           report_build(stdout, " %s = %d", t, idp->val.status.mark);
207 +           free(t);
208 +       }
209         if (!idp)
210             report_build(stdout, GT_(" <empty>"));
211         report_complete(stdout, "\n");