]> Pileus Git - ~andy/fetchmail/blob - fetchmail-SA-2009-01.txt
f1293e53d9d39a8d770b88abe8952225d4b11c55
[~andy/fetchmail] / fetchmail-SA-2009-01.txt
1 fetchmail-SA-2009-01: Improper SSL certificate subject verification
2
3 Topics:         Improper SSL certificate subject verification
4
5 Author:         Matthias Andree
6 Version:        1.0
7 Announced:      2009-08-06
8 Type:           Allows undetected Man-in-the-middle attacks against SSL/TLS.
9 Impact:         Credential disclose to eavesdroppers.
10 Danger:         medium
11 CVSSv2 vectors: (AV:N/AC:M/Au:N/C:P/I:N/A:N) (E:H/RL:OF/RC:C)
12
13 CVE Name:       CVE-2009-2666
14 URL:            http://www.fetchmail.info/fetchmail-SA-2009-01.txt
15 Project URL:    http://www.fetchmail.info/
16
17 Affects:        fetchmail releases up to and including 6.3.10
18
19 Not affected:   fetchmail release 6.3.11 and newer
20
21 Corrected:      2009-08-04 fetchmail SVN (rev 5389)
22
23 References:     "Null Prefix Attacks Against SSL/TLS Certificates",
24                 Moxie Marlinspike, 2009-07-29, Defcon 17, Blackhat 09.
25
26                 CVE-2009-2408, Mozilla Firefox <3.5 and NSS <3.12.3
27                 improper handling of '\0' characters in domain names in
28                 the Subject CN field of X.509 certificates.
29
30
31 0. Release history
32 ==================
33
34 2009-08-05 0.1  first draft (visible in SVN)
35 2009-08-06 1.0  first release
36
37
38 1. Background
39 =============
40
41 fetchmail is a software package to retrieve mail from remote POP2, POP3,
42 IMAP, ETRN or ODMR servers and forward it to local SMTP, LMTP servers or
43 message delivery agents. It supports SSL and TLS security layers through
44 the OpenSSL library, if enabled at compile time and if also enabled at
45 run time.
46
47
48 2. Problem description and Impact
49 =================================
50
51 Moxie Marlinspike demonstrated in July 2009 that some CAs would sign
52 certificates that contain embedded NUL characters in the Common Name or
53 subjectAltName fields of ITU-T X.509 certificates.
54
55 Applications that would treat such X.509 strings as NUL-terminated C
56 strings (rather than strings that contain an explicit length field)
57 would only check the part up to and excluding the NUL character, so that
58 certificate names such as www.good.example\0www.bad.example.com would be
59 mistaken as a certificate name for www.good.example.  fetchmail also had
60 this design and implementation flaw.
61
62 Note that fetchmail should always be forced to use strict certificate
63 validation through either of these option combinations:
64
65     --sslcertck --ssl --sslproto ssl3    (for service on SSL-wrapped ports)
66 or
67     --sslcertck --sslproto tls1          (for STARTTLS-based services)
68
69 (These are for the command line, in the rcfile, you will need to omit
70 the respective leading --).
71
72 The default is relaxed checking for compatibility with historic versions.
73
74
75 3. Solution
76 ===========
77
78 There are two alternatives, either of them by itself is sufficient:
79
80 a. Apply the patch found in section B of this announcement to
81    fetchmail 6.3.10, recompile and reinstall it.
82
83 b. Install fetchmail 6.3.11 or newer after it will have become available.
84    The fetchmail source code is always available from
85    <http://developer.berlios.de/project/showfiles.php?group_id=1824>.
86
87
88 4. Workaround
89 =============
90
91 Obtain the server fingerprints through a separate secure channel and
92 configure them with the sslfingerprint option, and enable the sslcertck
93 option.
94
95
96 A. Copyright, License and Warranty
97 ==================================
98
99 (C) Copyright 2009 by Matthias Andree, <matthias.andree@gmx.de>.
100 Some rights reserved.
101
102 This work is licensed under the Creative Commons
103 Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
104 To view a copy of this license, visit
105 http://creativecommons.org/licenses/by-nc-nd/3.0/de/ or send a letter to
106
107 Creative Commons
108 171 Second Street
109 Suite 300
110 SAN FRANCISCO, CALIFORNIA 94105
111 USA
112
113
114 THIS WORK IS PROVIDED FREE OF CHARGE AND WITHOUT ANY WARRANTIES.
115 Use the information herein at your own risk.
116
117
118 B. Patch to remedy the problem
119 ==============================
120
121 Note that when taking this from a GnuPG clearsigned file, the lines 
122 starting with a "-" character are prefixed by another "- " (dash + 
123 blank) combination. Either feed this file through GnuPG to strip them, 
124 or strip them manually.
125
126 Whitespace differences can usually be ignored by invoking "patch -l",
127 so try this if the patch does not apply.
128
129
130 Index: socket.c
131 ===================================================================
132 --- ./socket.c~
133 +++ ./socket.c
134 @@ -632,6 +632,12 @@
135                                 report(stderr, GT_("Bad certificate: Subject CommonName too long!\n"));
136                                 return (0);
137                         }
138 +                       if ((size_t)i > strlen(buf)) {
139 +                               /* Name contains embedded NUL characters, so we complain. This is likely
140 +                                * a certificate spoofing attack. */
141 +                               report(stderr, GT_("Bad certificate: Subject CommonName contains NUL, aborting!\n"));
142 +                               return 0;
143 +                       }
144                         if (_ssl_server_cname != NULL) {
145                                 char *p1 = buf;
146                                 char *p2 = _ssl_server_cname;
147 @@ -643,11 +649,18 @@
148                                  * first find a match among alternative names */
149                                 gens = (STACK_OF(GENERAL_NAME) *)X509_get_ext_d2i(x509_cert, NID_subject_alt_name, NULL, NULL);
150                                 if (gens) {
151 -                                       int i, r;
152 -                                       for (i = 0, r = sk_GENERAL_NAME_num(gens); i < r; ++i) {
153 -                                               const GENERAL_NAME *gn = sk_GENERAL_NAME_value(gens, i);
154 +                                       int j, r;
155 +                                       for (j = 0, r = sk_GENERAL_NAME_num(gens); j < r; ++j) {
156 +                                               const GENERAL_NAME *gn = sk_GENERAL_NAME_value(gens, j);
157                                                 if (gn->type == GEN_DNS) {
158                                                         char *p1 = (char *)gn->d.ia5->data;
159                                                         char *p2 = _ssl_server_cname;
160 +                                                       /* Name contains embedded NUL characters, so we complain. This
161 +                                                        * is likely a certificate spoofing attack. */
162 +                                                       if ((size_t)gn->d.ia5->length != strlen(p1)) {
163 +                                                               report(stderr, GT_("Bad certificate: Subject Alternative Name contains NUL, aborting!\n"));
164 +                                                               sk_GENERAL_NAME_free(gens);
165 +                                                               return 0;
166 +                                                       }
167                                                         if (outlevel >= O_VERBOSE)
168                                                                 report(stderr, "Subject Alternative Name: %s\n", p1);
169
170 END OF fetchmail-SA-2009-01.txt