1 fetchmail-SA-2009-01: Improper SSL certificate subject verification
3 Topics: Improper SSL certificate subject verification
5 Author: Matthias Andree
8 Type: Allows undetected Man-in-the-middle attacks against SSL/TLS.
9 Impact: Credential disclose to eavesdroppers.
11 CVSSv2 vectors: (AV:N/AC:M/Au:N/C:P/I:N/A:N) (E:H/RL:OF/RC:C)
13 CVE Name: CVE-2009-2666
14 URL: http://www.fetchmail.info/fetchmail-SA-2009-01.txt
15 Project URL: http://www.fetchmail.info/
17 Affects: fetchmail releases up to and including 6.3.10
19 Not affected: fetchmail release 6.3.11 and newer
21 Corrected: 2009-08-04 fetchmail SVN (rev 5389)
23 References: "Null Prefix Attacks Against SSL/TLS Certificates",
24 Moxie Marlinspike, 2009-07-29, Defcon 17, Blackhat 09.
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.
34 2009-08-05 0.1 first draft (visible in SVN)
35 2009-08-06 1.0 first release
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
48 2. Problem description and Impact
49 =================================
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.
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.
62 Note that fetchmail should always be forced to use strict certificate
63 validation through either of these option combinations:
65 --sslcertck --ssl --sslproto ssl3 (for service on SSL-wrapped ports)
67 --sslcertck --sslproto tls1 (for STARTTLS-based services)
69 (These are for the command line, in the rcfile, you will need to omit
70 the respective leading --).
72 The default is relaxed checking for compatibility with historic versions.
78 There are two alternatives, either of them by itself is sufficient:
80 a. Apply the patch found in section B of this announcement to
81 fetchmail 6.3.10, recompile and reinstall it.
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>.
91 Obtain the server fingerprints through a separate secure channel and
92 configure them with the sslfingerprint option, and enable the sslcertck
96 A. Copyright, License and Warranty
97 ==================================
99 (C) Copyright 2009 by Matthias Andree, <matthias.andree@gmx.de>.
100 Some rights reserved.
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
110 SAN FRANCISCO, CALIFORNIA 94105
114 THIS WORK IS PROVIDED FREE OF CHARGE AND WITHOUT ANY WARRANTIES.
115 Use the information herein at your own risk.
118 B. Patch to remedy the problem
119 ==============================
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.
126 Whitespace differences can usually be ignored by invoking "patch -l",
127 so try this if the patch does not apply.
131 ===================================================================
135 report(stderr, GT_("Bad certificate: Subject CommonName too long!\n"));
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"));
144 if (_ssl_server_cname != NULL) {
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);
152 - for (i = 0, r = sk_GENERAL_NAME_num(gens); i < r; ++i) {
153 - const GENERAL_NAME *gn = sk_GENERAL_NAME_value(gens, i);
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);
167 if (outlevel >= O_VERBOSE)
168 report(stderr, "Subject Alternative Name: %s\n", p1);
170 END OF fetchmail-SA-2009-01.txt