]> Pileus Git - ~andy/fetchmail/blob - fetchmail-SA-2008-01.txt
Merge branch 'legacy_63'
[~andy/fetchmail] / fetchmail-SA-2008-01.txt
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 fetchmail-SA-2008-01: Crash on large log messages in verbose mode
5
6 Topics:         Crash in large log messages in verbose mode.
7
8 Author:         Matthias Andree
9 Version:        1.2
10 Announced:      2008-06-17
11 Type:           Dereferencing garbage pointer triggered by outside circumstances
12 Impact:         denial of service possible
13 Danger:         low
14 CVSS V2 vector: (AV:N/AC:M/Au:N/C:N/I:N/A:C/E:P/RL:O/RC:C)
15
16 Credits:        Petr Uzel (fix), Petr Cerny (analysis), Gunter Nau (bug report)
17 CVE Name:       CVE-2008-2711
18 URL:            http://www.fetchmail.info/fetchmail-SA-2008-01.txt
19 Project URL:    http://www.fetchmail.info/
20
21 Affects:        fetchmail release before and excluding 6.3.9
22                 fetchmail release candidate 6.3.9-rc1
23
24 Not affected:   fetchmail release 6.3.9 and newer
25                 fetchmail release candidate 6.3.9-rc2 and newer
26                 systems without varargs support.
27
28 Corrected:      2008-06-24 fetchmail SVN (rev 5205)
29
30 References:     <https://bugzilla.novell.com/show_bug.cgi?id=354291>
31                 <http://developer.berlios.de/patch/?func=detailpatch&patch_id=2492&group_id=1824>
32
33
34 0. Release history
35 ==================
36
37 2008-06-13 1.0  first draft for MITRE/CVE (visible in SVN,
38                 posted to oss-security)
39 2008-06-17 1.0  published on http://www.fetchmail.info/
40 2008-06-17 1.1  Corrected typo in Type: above (trigged -> triggered)
41 2008-06-24 1.2  also fixed issue in report_complete (reported by Petr Uzel)
42
43
44 1. Background
45 =============
46
47 fetchmail is a software package to retrieve mail from remote POP2, POP3,
48 IMAP, ETRN or ODMR servers and forward it to local SMTP, LMTP servers or
49 message delivery agents.
50
51 fetchmail ships with a graphical, Python/Tkinter based configuration
52 utility named "fetchmailconf" to help the user create configuration (run
53 control) files for fetchmail.
54
55
56 2. Problem description and Impact
57 =================================
58
59 Gunter Nau reported fetchmail crashing on some messages; further
60 debugging by Petr Uzel and Petr Cerny at Novell/SUSE Czech Republic
61 dug up that this happened when fetchmail was trying to print, in -v -v
62 verbose level, headers exceeding 2048 bytes. In this situation,
63 fetchmail would resize the buffer and fill in further parts of the
64 message, but forget to reinitialize its va_list typed source pointer,
65 thus reading data from a garbage address found on the stack at
66 addresses above the function arguments the caller passed in; usually
67 that would be the caller's stack frame.
68
69 It is unknown whether code can be injected remotely, but given that
70 the segmentation fault is caused by read accesses, the relevant data
71 is not under the remote attacker's control and no buffer overrun
72 situation is present that would allow altering program /flow/, it is
73 deemed rather unlikely that code can be injected.
74
75 Note that the required -vv configuration at hand is both non-default
76 and also not common in automated (cron job) setups, but usually used
77 in manual debugging, so not many systems would be affected by the
78 problem. Nonetheless, in vulnerable configurations, it is remotely
79 exploitable to effect a denial of service attack.
80
81
82
83 3. Solution
84 ===========
85
86 There are two alternatives, either of them by itself is sufficient:
87
88 a. Apply the patch found in section B of this announcement to
89    fetchmail 6.3.8, recompile and reinstall it.
90
91 b. Install fetchmail 6.3.9 or newer after it will have become available.
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 at low verbosity, avoid using two or three -v arguments;
100 internal messages are short and do not contain external message
101 sources so they do not cause buffer resizing. It is recommended to
102 replace the vulnerable code by a fixed version (see previous
103 section 3. Solution) as soon as reasonably possible.
104
105
106 A. Copyright, License and Warranty
107 ==================================
108
109 (C) Copyright 2008 by Matthias Andree, <matthias.andree@gmx.de>.
110 Some rights reserved.
111
112 This work is licensed under the
113 Creative Commons Attribution-NoDerivs 3.0 Germany License (CC BY-ND 3.0).
114
115 To view a copy of this license, visit
116 http://creativecommons.org/licenses/by-nd/3.0/de/deed.en
117 or send a letter to:
118
119 Creative Commons
120 444 Castro Street
121 Suite 900
122 MOUNTAIN VIEW, CALIFORNIA 94041
123 USA
124
125 THIS WORK IS PROVIDED FREE OF CHARGE AND WITHOUT ANY WARRANTIES.
126 Use the information herein at your own risk.
127
128
129 B. Patch to remedy the problem
130 ==============================
131
132 Note that when taking this from a GnuPG clearsigned file, the lines 
133 starting with a "-" character are prefixed by another "- " (dash + 
134 blank) combination. Either feed this file through GnuPG to strip them, 
135 or strip them manually.
136
137 Whitespace differences can usually be ignored by invoking "patch -l",
138 so try this if the patch does not apply.
139
140 diff --git a/report.c b/report.c
141 index 31d4e48..320e60b 100644
142 - --- a/report.c
143 +++ b/report.c
144 @@ -238,11 +238,17 @@ report_build (FILE *errfp, message, va_alist)
145      rep_ensuresize();
146  
147  #if defined(VA_START)
148 - -    VA_START (args, message);
149      for ( ; ; )
150      {
151 +       /*
152 +        * args has to be initialized before every call of vsnprintf(), 
153 +        * because vsnprintf() invokes va_arg macro and thus args is 
154 +        * undefined after the call.
155 +        */
156 +       VA_START(args, message);
157         n = vsnprintf (partial_message + partial_message_size_used, partial_message_size - partial_message_size_used,
158                        message, args);
159 +       va_end (args);
160  
161         if (n >= 0
162             && (unsigned)n < partial_message_size - partial_message_size_used)
163 @@ -254,7 +260,6 @@ report_build (FILE *errfp, message, va_alist)
164         partial_message_size += 2048;
165         partial_message = REALLOC (partial_message, partial_message_size);
166      }
167 - -    va_end (args);
168  #else
169      for ( ; ; )
170      {
171 @@ -304,12 +309,13 @@ report_complete (FILE *errfp, message, va_alist)
172      rep_ensuresize();
173  
174  #if defined(VA_START)
175 - -    VA_START (args, message);
176      for ( ; ; )
177      {
178 +       VA_START(args, message);
179         n = vsnprintf (partial_message + partial_message_size_used,
180                        partial_message_size - partial_message_size_used,
181                        message, args);
182 +       va_end(args);
183  
184         /* old glibc versions return -1 for truncation */
185         if (n >= 0
186 @@ -322,7 +328,6 @@ report_complete (FILE *errfp, message, va_alist)
187         partial_message_size += 2048;
188         partial_message = REALLOC (partial_message, partial_message_size);
189      }
190 - -    va_end (args);
191  #else
192      for ( ; ; )
193      {
194
195 END OF fetchmail-SA-2008-01.txt
196 -----BEGIN PGP SIGNATURE-----
197 Version: GnuPG v1.4.11 (GNU/Linux)
198
199 iEYEARECAAYFAk9/Yg4ACgkQvmGDOQUufZVbTACeOfZU3NVlDF675SDiVqPL4uAl
200 fsgAoMEqf6cpav6sDdEobMHV3UzHSOJV
201 =uvVR
202 -----END PGP SIGNATURE-----