]> git.ipfire.org Git - people/stevee/ipfire-3.x.git/blob - python/patches/00185-CVE-2013-4238-hostname-check-bypass-in-SSL-module.patch
pam: Update to 1.3.0
[people/stevee/ipfire-3.x.git] / python / patches / 00185-CVE-2013-4238-hostname-check-bypass-in-SSL-module.patch
1 diff -r 9ddc63c039ba Lib/test/nullbytecert.pem
2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3 +++ b/Lib/test/nullbytecert.pem Sun Aug 11 18:13:17 2013 +0200
4 @@ -0,0 +1,90 @@
5 +Certificate:
6 + Data:
7 + Version: 3 (0x2)
8 + Serial Number: 0 (0x0)
9 + Signature Algorithm: sha1WithRSAEncryption
10 + Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org
11 + Validity
12 + Not Before: Aug 7 13:11:52 2013 GMT
13 + Not After : Aug 7 13:12:52 2013 GMT
14 + Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org
15 + Subject Public Key Info:
16 + Public Key Algorithm: rsaEncryption
17 + Public-Key: (2048 bit)
18 + Modulus:
19 + 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3:
20 + 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97:
21 + 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2:
22 + 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1:
23 + 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4:
24 + 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8:
25 + a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02:
26 + 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75:
27 + ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91:
28 + 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d:
29 + 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30:
30 + 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7:
31 + f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12:
32 + f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5:
33 + ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb:
34 + d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f:
35 + 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da:
36 + 2f:85
37 + Exponent: 65537 (0x10001)
38 + X509v3 extensions:
39 + X509v3 Basic Constraints: critical
40 + CA:FALSE
41 + X509v3 Subject Key Identifier:
42 + 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C
43 + X509v3 Key Usage:
44 + Digital Signature, Non Repudiation, Key Encipherment
45 + X509v3 Subject Alternative Name:
46 + *************************************************************
47 + WARNING: The values for DNS, email and URI are WRONG. OpenSSL
48 + doesn't print the text after a NULL byte.
49 + *************************************************************
50 + DNS:altnull.python.org, email:null@python.org, URI:http://null.python.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1
51 + Signature Algorithm: sha1WithRSAEncryption
52 + ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5:
53 + a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44:
54 + 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37:
55 + 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3:
56 + 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86:
57 + de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac:
58 + 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4:
59 + 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60:
60 + d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5:
61 + 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60:
62 + 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6:
63 + 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d:
64 + 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e:
65 + 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6:
66 + c1:ca:a9:94
67 +-----BEGIN CERTIFICATE-----
68 +MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx
69 +DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ
70 +eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg
71 +RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y
72 +ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw
73 +NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI
74 +DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv
75 +ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt
76 +ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgk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JqRStVRHM1koZlJmXNx2BX4vPo6iW
93 +RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ=
94 +-----END CERTIFICATE-----
95 diff -r 9ddc63c039ba Lib/test/test_ssl.py
96 --- a/Lib/test/test_ssl.py Sun Aug 11 13:04:50 2013 +0300
97 +++ b/Lib/test/test_ssl.py Sun Aug 11 18:13:17 2013 +0200
98 @@ -25,6 +25,7 @@
99 HOST = test_support.HOST
100 CERTFILE = None
101 SVN_PYTHON_ORG_ROOT_CERT = None
102 +NULLBYTECERT = None
103
104 def handle_error(prefix):
105 exc_format = ' '.join(traceback.format_exception(*sys.exc_info()))
106 @@ -123,6 +124,27 @@
107 ('DNS', 'projects.forum.nokia.com'))
108 )
109
110 + def test_parse_cert_CVE_2013_4073(self):
111 + p = ssl._ssl._test_decode_cert(NULLBYTECERT)
112 + if test_support.verbose:
113 + sys.stdout.write("\n" + pprint.pformat(p) + "\n")
114 + subject = ((('countryName', 'US'),),
115 + (('stateOrProvinceName', 'Oregon'),),
116 + (('localityName', 'Beaverton'),),
117 + (('organizationName', 'Python Software Foundation'),),
118 + (('organizationalUnitName', 'Python Core Development'),),
119 + (('commonName', 'null.python.org\x00example.org'),),
120 + (('emailAddress', 'python-dev@python.org'),))
121 + self.assertEqual(p['subject'], subject)
122 + self.assertEqual(p['issuer'], subject)
123 + self.assertEqual(p['subjectAltName'],
124 + (('DNS', 'altnull.python.org\x00example.com'),
125 + ('email', 'null@python.org\x00user@example.org'),
126 + ('URI', 'http://null.python.org\x00http://example.org'),
127 + ('IP Address', '192.0.2.1'),
128 + ('IP Address', '2001:DB8:0:0:0:0:0:1\n'))
129 + )
130 +
131 def test_DER_to_PEM(self):
132 with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f:
133 pem = f.read()
134 @@ -1360,7 +1382,7 @@
135
136
137 def test_main(verbose=False):
138 - global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT
139 + global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT, NULLBYTECERT
140 CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
141 "keycert.pem")
142 SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
143 @@ -1368,10 +1390,13 @@
144 "https_svn_python_org_root.pem")
145 NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir,
146 "nokia.pem")
147 + NULLBYTECERT = os.path.join(os.path.dirname(__file__) or os.curdir,
148 + "nullbytecert.pem")
149
150 if (not os.path.exists(CERTFILE) or
151 not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or
152 - not os.path.exists(NOKIACERT)):
153 + not os.path.exists(NOKIACERT) or
154 + not os.path.exists(NULLBYTECERT)):
155 raise test_support.TestFailed("Can't read certificate files!")
156
157 tests = [BasicTests, BasicSocketTests]
158 diff -r 9ddc63c039ba Modules/_ssl.c
159 --- a/Modules/_ssl.c Sun Aug 11 13:04:50 2013 +0300
160 +++ b/Modules/_ssl.c Sun Aug 11 18:13:17 2013 +0200
161 @@ -741,8 +741,13 @@
162
163 /* get a rendering of each name in the set of names */
164
165 + int gntype;
166 + ASN1_STRING *as = NULL;
167 +
168 name = sk_GENERAL_NAME_value(names, j);
169 - if (name->type == GEN_DIRNAME) {
170 + gntype = name-> type;
171 + switch (gntype) {
172 + case GEN_DIRNAME:
173
174 /* we special-case DirName as a tuple of tuples of attributes */
175
176 @@ -764,11 +769,61 @@
177 goto fail;
178 }
179 PyTuple_SET_ITEM(t, 1, v);
180 + break;
181
182 - } else {
183 + case GEN_EMAIL:
184 + case GEN_DNS:
185 + case GEN_URI:
186 + /* GENERAL_NAME_print() doesn't handle NUL bytes in ASN1_string
187 + correctly. */
188 + t = PyTuple_New(2);
189 + if (t == NULL)
190 + goto fail;
191 + switch (gntype) {
192 + case GEN_EMAIL:
193 + v = PyUnicode_FromString("email");
194 + as = name->d.rfc822Name;
195 + break;
196 + case GEN_DNS:
197 + v = PyUnicode_FromString("DNS");
198 + as = name->d.dNSName;
199 + break;
200 + case GEN_URI:
201 + v = PyUnicode_FromString("URI");
202 + as = name->d.uniformResourceIdentifier;
203 + break;
204 + }
205 + if (v == NULL) {
206 + Py_DECREF(t);
207 + goto fail;
208 + }
209 + PyTuple_SET_ITEM(t, 0, v);
210 + v = PyString_FromStringAndSize((char *)ASN1_STRING_data(as),
211 + ASN1_STRING_length(as));
212 + if (v == NULL) {
213 + Py_DECREF(t);
214 + goto fail;
215 + }
216 + PyTuple_SET_ITEM(t, 1, v);
217 + break;
218
219 + default:
220 /* for everything else, we use the OpenSSL print form */
221 -
222 + switch (gntype) {
223 + /* check for new general name type */
224 + case GEN_OTHERNAME:
225 + case GEN_X400:
226 + case GEN_EDIPARTY:
227 + case GEN_IPADD:
228 + case GEN_RID:
229 + break;
230 + default:
231 + if (PyErr_Warn(PyExc_RuntimeWarning,
232 + "Unknown general name type") == -1) {
233 + goto fail;
234 + }
235 + break;
236 + }
237 (void) BIO_reset(biobuf);
238 GENERAL_NAME_print(biobuf, name);
239 len = BIO_gets(biobuf, buf, sizeof(buf)-1);
240 @@ -794,6 +849,7 @@
241 goto fail;
242 }
243 PyTuple_SET_ITEM(t, 1, v);
244 + break;
245 }
246
247 /* and add that rendering to the list */