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