summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaul Wold <sgw@linux.intel.com>2013-08-29 11:54:17 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-30 18:06:32 +0100
commit36fcb616b0c87c70fa0aa803d5fef4c5f35be5b6 (patch)
tree5fb49982b00422e42c941daa55d3333cc89788fe
parent116441d6dcd6ab3d044de84e7f0e85b6b50bfb2a (diff)
downloadpoky-36fcb616b0c87c70fa0aa803d5fef4c5f35be5b6.tar.gz
python: Backport 2 CVE from upstream
These are back ports of 2 patches from upstream to address CVE-2011-4944 CVE-2013-4238 (From OE-Core rev: 4606eab53e8eff57d6369ea20a5ea63916ea3ea7) Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch251
-rw-r--r--meta/recipes-devtools/python/python/pypirc-secure.patch35
-rw-r--r--meta/recipes-devtools/python/python_2.7.3.bb2
3 files changed, 288 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch b/meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch
new file mode 100644
index 0000000000..0d17463052
--- /dev/null
+++ b/meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch
@@ -0,0 +1,251 @@
1Upstream-Status: Backport
2
3Signed-off-by: Saul Wold <sgw@linux.intel.com>
4
5diff -r 9ddc63c039ba Lib/test/nullbytecert.pem
6--- /dev/null Thu Jan 01 00:00:00 1970 +0000
7+++ b/Lib/test/nullbytecert.pem Sun Aug 11 18:13:17 2013 +0200
8@@ -0,0 +1,90 @@
9+Certificate:
10+ Data:
11+ Version: 3 (0x2)
12+ Serial Number: 0 (0x0)
13+ Signature Algorithm: sha1WithRSAEncryption
14+ 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
15+ Validity
16+ Not Before: Aug 7 13:11:52 2013 GMT
17+ Not After : Aug 7 13:12:52 2013 GMT
18+ 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
19+ Subject Public Key Info:
20+ Public Key Algorithm: rsaEncryption
21+ Public-Key: (2048 bit)
22+ Modulus:
23+ 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3:
24+ 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97:
25+ 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2:
26+ 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1:
27+ 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4:
28+ 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8:
29+ a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02:
30+ 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75:
31+ ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91:
32+ 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d:
33+ 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30:
34+ 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7:
35+ f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12:
36+ f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5:
37+ ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb:
38+ d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f:
39+ 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da:
40+ 2f:85
41+ Exponent: 65537 (0x10001)
42+ X509v3 extensions:
43+ X509v3 Basic Constraints: critical
44+ CA:FALSE
45+ X509v3 Subject Key Identifier:
46+ 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C
47+ X509v3 Key Usage:
48+ Digital Signature, Non Repudiation, Key Encipherment
49+ X509v3 Subject Alternative Name:
50+ *************************************************************
51+ WARNING: The values for DNS, email and URI are WRONG. OpenSSL
52+ doesn't print the text after a NULL byte.
53+ *************************************************************
54+ 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
55+ Signature Algorithm: sha1WithRSAEncryption
56+ ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5:
57+ a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44:
58+ 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37:
59+ 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3:
60+ 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86:
61+ de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac:
62+ 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4:
63+ 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60:
64+ d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5:
65+ 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60:
66+ 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6:
67+ 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d:
68+ 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e:
69+ 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6:
70+ c1:ca:a9:94
71+-----BEGIN CERTIFICATE-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DCBzTAMBgNV
88+HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E
89+BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu
90+Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251
91+bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA
92+AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9
93+i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j
94+HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk
95+kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx
96+VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW
97+RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ=
98+-----END CERTIFICATE-----
99diff -r 9ddc63c039ba Lib/test/test_ssl.py
100--- a/Lib/test/test_ssl.py Sun Aug 11 13:04:50 2013 +0300
101+++ b/Lib/test/test_ssl.py Sun Aug 11 18:13:17 2013 +0200
102@@ -25,6 +25,7 @@
103 HOST = test_support.HOST
104 CERTFILE = None
105 SVN_PYTHON_ORG_ROOT_CERT = None
106+NULLBYTECERT = None
107
108 def handle_error(prefix):
109 exc_format = ' '.join(traceback.format_exception(*sys.exc_info()))
110@@ -123,6 +124,27 @@
111 ('DNS', 'projects.forum.nokia.com'))
112 )
113
114+ def test_parse_cert_CVE_2013_4073(self):
115+ p = ssl._ssl._test_decode_cert(NULLBYTECERT)
116+ if test_support.verbose:
117+ sys.stdout.write("\n" + pprint.pformat(p) + "\n")
118+ subject = ((('countryName', 'US'),),
119+ (('stateOrProvinceName', 'Oregon'),),
120+ (('localityName', 'Beaverton'),),
121+ (('organizationName', 'Python Software Foundation'),),
122+ (('organizationalUnitName', 'Python Core Development'),),
123+ (('commonName', 'null.python.org\x00example.org'),),
124+ (('emailAddress', 'python-dev@python.org'),))
125+ self.assertEqual(p['subject'], subject)
126+ self.assertEqual(p['issuer'], subject)
127+ self.assertEqual(p['subjectAltName'],
128+ (('DNS', 'altnull.python.org\x00example.com'),
129+ ('email', 'null@python.org\x00user@example.org'),
130+ ('URI', 'http://null.python.org\x00http://example.org'),
131+ ('IP Address', '192.0.2.1'),
132+ ('IP Address', '2001:DB8:0:0:0:0:0:1\n'))
133+ )
134+
135 def test_DER_to_PEM(self):
136 with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f:
137 pem = f.read()
138@@ -1360,7 +1382,7 @@
139
140
141 def test_main(verbose=False):
142- global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT
143+ global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT, NULLBYTECERT
144 CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
145 "keycert.pem")
146 SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
147@@ -1368,10 +1390,13 @@
148 "https_svn_python_org_root.pem")
149 NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir,
150 "nokia.pem")
151+ NULLBYTECERT = os.path.join(os.path.dirname(__file__) or os.curdir,
152+ "nullbytecert.pem")
153
154 if (not os.path.exists(CERTFILE) or
155 not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or
156- not os.path.exists(NOKIACERT)):
157+ not os.path.exists(NOKIACERT) or
158+ not os.path.exists(NULLBYTECERT)):
159 raise test_support.TestFailed("Can't read certificate files!")
160
161 tests = [BasicTests, BasicSocketTests]
162diff -r 9ddc63c039ba Modules/_ssl.c
163--- a/Modules/_ssl.c Sun Aug 11 13:04:50 2013 +0300
164+++ b/Modules/_ssl.c Sun Aug 11 18:13:17 2013 +0200
165@@ -741,8 +741,13 @@
166
167 /* get a rendering of each name in the set of names */
168
169+ int gntype;
170+ ASN1_STRING *as = NULL;
171+
172 name = sk_GENERAL_NAME_value(names, j);
173- if (name->type == GEN_DIRNAME) {
174+ gntype = name-> type;
175+ switch (gntype) {
176+ case GEN_DIRNAME:
177
178 /* we special-case DirName as a tuple of tuples of attributes */
179
180@@ -764,11 +769,61 @@
181 goto fail;
182 }
183 PyTuple_SET_ITEM(t, 1, v);
184+ break;
185
186- } else {
187+ case GEN_EMAIL:
188+ case GEN_DNS:
189+ case GEN_URI:
190+ /* GENERAL_NAME_print() doesn't handle NUL bytes in ASN1_string
191+ correctly. */
192+ t = PyTuple_New(2);
193+ if (t == NULL)
194+ goto fail;
195+ switch (gntype) {
196+ case GEN_EMAIL:
197+ v = PyUnicode_FromString("email");
198+ as = name->d.rfc822Name;
199+ break;
200+ case GEN_DNS:
201+ v = PyUnicode_FromString("DNS");
202+ as = name->d.dNSName;
203+ break;
204+ case GEN_URI:
205+ v = PyUnicode_FromString("URI");
206+ as = name->d.uniformResourceIdentifier;
207+ break;
208+ }
209+ if (v == NULL) {
210+ Py_DECREF(t);
211+ goto fail;
212+ }
213+ PyTuple_SET_ITEM(t, 0, v);
214+ v = PyString_FromStringAndSize((char *)ASN1_STRING_data(as),
215+ ASN1_STRING_length(as));
216+ if (v == NULL) {
217+ Py_DECREF(t);
218+ goto fail;
219+ }
220+ PyTuple_SET_ITEM(t, 1, v);
221+ break;
222
223+ default:
224 /* for everything else, we use the OpenSSL print form */
225-
226+ switch (gntype) {
227+ /* check for new general name type */
228+ case GEN_OTHERNAME:
229+ case GEN_X400:
230+ case GEN_EDIPARTY:
231+ case GEN_IPADD:
232+ case GEN_RID:
233+ break;
234+ default:
235+ if (PyErr_Warn(PyExc_RuntimeWarning,
236+ "Unknown general name type") == -1) {
237+ goto fail;
238+ }
239+ break;
240+ }
241 (void) BIO_reset(biobuf);
242 GENERAL_NAME_print(biobuf, name);
243 len = BIO_gets(biobuf, buf, sizeof(buf)-1);
244@@ -794,6 +849,7 @@
245 goto fail;
246 }
247 PyTuple_SET_ITEM(t, 1, v);
248+ break;
249 }
250
251 /* and add that rendering to the list */
diff --git a/meta/recipes-devtools/python/python/pypirc-secure.patch b/meta/recipes-devtools/python/python/pypirc-secure.patch
new file mode 100644
index 0000000000..8e2df677b6
--- /dev/null
+++ b/meta/recipes-devtools/python/python/pypirc-secure.patch
@@ -0,0 +1,35 @@
1# HG changeset patch
2# User Philip Jenvey <pjenvey@underboss.org>
3# Date 1322701507 28800
4# Branch 2.7
5# Node ID e7c20a8476a0e2ca18f8040864cbc400818d8f24
6# Parent 3ecddf168f1f554a17a047384fe0b02f2d688277
7create the .pypirc securely
8
9Upstream-Status: Backport
10
11Signed-off-by: Saul Wold <sgw@linux.intel.com>
12
13
14diff -r 3ecddf168f1f -r e7c20a8476a0 Lib/distutils/config.py
15--- a/Lib/distutils/config.py Tue Nov 29 00:53:09 2011 +0100
16+++ b/Lib/distutils/config.py Wed Nov 30 17:05:07 2011 -0800
17@@ -42,16 +42,8 @@
18 def _store_pypirc(self, username, password):
19 """Creates a default .pypirc file."""
20 rc = self._get_rc_file()
21- f = open(rc, 'w')
22- try:
23- f.write(DEFAULT_PYPIRC % (username, password))
24- finally:
25- f.close()
26- try:
27- os.chmod(rc, 0600)
28- except OSError:
29- # should do something better here
30- pass
31+ with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0600), 'w') as fp:
32+ fp.write(DEFAULT_PYPIRC % (username, password))
33
34 def _read_pypirc(self):
35 """Reads the .pypirc file."""
diff --git a/meta/recipes-devtools/python/python_2.7.3.bb b/meta/recipes-devtools/python/python_2.7.3.bb
index 2e35da60c4..f6a460989b 100644
--- a/meta/recipes-devtools/python/python_2.7.3.bb
+++ b/meta/recipes-devtools/python/python_2.7.3.bb
@@ -30,6 +30,8 @@ SRC_URI += "\
30 file://gcc-4.8-fix-configure-Wformat.patch \ 30 file://gcc-4.8-fix-configure-Wformat.patch \
31 file://fix-makefile-for-ptest.patch \ 31 file://fix-makefile-for-ptest.patch \
32 file://run-ptest \ 32 file://run-ptest \
33 file://CVE-2013-4073_py27.patch \
34 file://pypirc-secure.patch \
33" 35"
34 36
35S = "${WORKDIR}/Python-${PV}" 37S = "${WORKDIR}/Python-${PV}"