Browse code

CVE-2018-14647 - python2

Change-Id: Idf03682315d31ec7134a58894cbfb66f6012ee9c
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/6419
Tested-by: michellew <michellew@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Tapas Kundu authored on 2018/12/31 20:02:05
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,84 @@
0
+commit 18b20bad75b4ff0486940fba4ec680e96e70f3a2
1
+Author: Christian Heimes <christian@python.org>
2
+Date:   Tue Sep 18 15:13:09 2018 +0200
3
+
4
+    [2.7] bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146) (GH-9394)
5
+    
6
+    
7
+    
8
+    The C accelerated _elementtree module now initializes hash randomization
9
+    salt from _Py_HashSecret instead of libexpat's default CPRNG.
10
+    
11
+    Signed-off-by: Christian Heimes <christian@python.org>
12
+    
13
+    https://bugs.python.org/issue34623.
14
+    (cherry picked from commit cb5778f00ce48631c7140f33ba242496aaf7102b)
15
+    
16
+    Co-authored-by: Christian Heimes <christian@python.org>
17
+    
18
+    
19
+    
20
+    https://bugs.python.org/issue34623
21
+
22
+diff --git a/Include/pyexpat.h b/Include/pyexpat.h
23
+index 5340ef5..3fc5fa5 100644
24
+--- a/Include/pyexpat.h
25
+@@ -3,7 +3,7 @@
26
+ 
27
+ /* note: you must import expat.h before importing this module! */
28
+ 
29
+-#define PyExpat_CAPI_MAGIC  "pyexpat.expat_CAPI 1.0"
30
++#define PyExpat_CAPI_MAGIC  "pyexpat.expat_CAPI 1.1"
31
+ #define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
32
+ 
33
+ struct PyExpat_CAPI 
34
+@@ -43,6 +43,8 @@ struct PyExpat_CAPI
35
+         XML_Parser parser, XML_UnknownEncodingHandler handler,
36
+         void *encodingHandlerData);
37
+     void (*SetUserData)(XML_Parser parser, void *userData);
38
++    /* might be none for expat < 2.1.0 */
39
++    int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt);
40
+     /* always add new stuff to the end! */
41
+ };
42
+ 
43
+diff --git a/Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst b/Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst
44
+new file mode 100644
45
+index 0000000..31ad92e
46
+--- /dev/null
47
+@@ -0,0 +1,2 @@
48
++The C accelerated _elementtree module now initializes hash randomization
49
++salt from _Py_HashSecret instead of libexpat's default CSPRNG.
50
+diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
51
+index f7f992d..b38e0ab 100644
52
+--- a/Modules/_elementtree.c
53
+@@ -2574,6 +2574,11 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
54
+         PyErr_NoMemory();
55
+         return NULL;
56
+     }
57
++    /* expat < 2.1.0 has no XML_SetHashSalt() */
58
++    if (EXPAT(SetHashSalt) != NULL) {
59
++        EXPAT(SetHashSalt)(self->parser,
60
++                           (unsigned long)_Py_HashSecret.prefix);
61
++    }
62
+ 
63
+     ALLOC(sizeof(XMLParserObject), "create expatparser");
64
+ 
65
+diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
66
+index 2b4d312..1f8c0d7 100644
67
+--- a/Modules/pyexpat.c
68
+@@ -2042,6 +2042,11 @@ MODULE_INITFUNC(void)
69
+     capi.SetProcessingInstructionHandler = XML_SetProcessingInstructionHandler;
70
+     capi.SetUnknownEncodingHandler = XML_SetUnknownEncodingHandler;
71
+     capi.SetUserData = XML_SetUserData;
72
++#if XML_COMBINED_VERSION >= 20100
73
++    capi.SetHashSalt = XML_SetHashSalt;
74
++#else
75
++    capi.SetHashSalt = NULL;
76
++#endif
77
+ 
78
+     /* export using capsule */
79
+     capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        A high-level scripting language
2 2
 Name:           python2
3 3
 Version:        2.7.15
4
-Release:        2%{?dist}
4
+Release:        3%{?dist}
5 5
 License:        PSF
6 6
 URL:            http://www.python.org/
7 7
 Group:          System Environment/Programming
... ...
@@ -11,6 +11,7 @@ Source0:        http://www.python.org/ftp/python/%{version}/Python-%{version}.ta
11 11
 %define sha1    Python=f99348a095ec4a6411c84c0d15343d11920c9724
12 12
 Patch0:         cgi.patch
13 13
 Patch1:         added-pyopenssl-ipaddress-certificate-validation.patch
14
+Patch3:         CVE-2018-14647.patch
14 15
 BuildRequires:  pkg-config >= 0.28
15 16
 BuildRequires:  bzip2-devel
16 17
 BuildRequires:  openssl-devel
... ...
@@ -100,6 +101,7 @@ to build python programs.
100 100
 %setup -q -n Python-%{version}
101 101
 %patch0 -p1
102 102
 %patch1 -p1
103
+%patch3 -p1
103 104
 
104 105
 %build
105 106
 export OPT="${CFLAGS}"
... ...
@@ -218,6 +220,8 @@ rm -rf %{buildroot}/*
218 218
 %{_bindir}/idle*
219 219
 
220 220
 %changelog
221
+*   Mon Dec 31 2018 Tapas Kundu <tkundu@vmware.com> 2.7.15-3
222
+-   Fix for CVE-2018-14647
221 223
 *   Mon Sep 17 2018 Dweep Advani <dadvani@vmware.com> 2.7.15-2
222 224
 -   Remove vulnerable Windows installers from python-libs rpm
223 225
 *   Fri Aug 17 2018 Dweep Advani <dadvani@vmware.com> 2.7.15-1