Browse code

CVE-2018-14647 - python3

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

Tapas Kundu authored on 2018/12/31 21:33:51
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,79 @@
0
+commit f7666e828cc3d5873136473ea36ba2013d624fa1
1
+Author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
2
+Date:   Tue Sep 18 06:14:13 2018 -0700
3
+
4
+    bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146)
5
+    
6
+    
7
+    The C accelerated _elementtree module now initializes hash randomization
8
+    salt from _Py_HashSecret instead of libexpat's default CPRNG.
9
+    
10
+    Signed-off-by: Christian Heimes <christian@python.org>
11
+    
12
+    https://bugs.python.org/issue34623
13
+    (cherry picked from commit cb5778f00ce48631c7140f33ba242496aaf7102b)
14
+    
15
+    Co-authored-by: Christian Heimes <christian@python.org>
16
+
17
+diff --git a/Include/pyexpat.h b/Include/pyexpat.h
18
+index 44259bf..07020b5 100644
19
+--- a/Include/pyexpat.h
20
+@@ -3,7 +3,7 @@
21
+ 
22
+ /* note: you must import expat.h before importing this module! */
23
+ 
24
+-#define PyExpat_CAPI_MAGIC  "pyexpat.expat_CAPI 1.0"
25
++#define PyExpat_CAPI_MAGIC  "pyexpat.expat_CAPI 1.1"
26
+ #define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
27
+ 
28
+ struct PyExpat_CAPI
29
+@@ -48,6 +48,8 @@ struct PyExpat_CAPI
30
+     enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding);
31
+     int (*DefaultUnknownEncodingHandler)(
32
+         void *encodingHandlerData, const XML_Char *name, XML_Encoding *info);
33
++    /* might be none for expat < 2.1.0 */
34
++    int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt);
35
+     /* always add new stuff to the end! */
36
+ };
37
+ 
38
+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
39
+new file mode 100644
40
+index 0000000..31ad92e
41
+--- /dev/null
42
+@@ -0,0 +1,2 @@
43
++The C accelerated _elementtree module now initializes hash randomization
44
++salt from _Py_HashSecret instead of libexpat's default CSPRNG.
45
+diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
46
+index 707ab29..53f05f9 100644
47
+--- a/Modules/_elementtree.c
48
+@@ -3261,6 +3261,11 @@ _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *html,
49
+         PyErr_NoMemory();
50
+         return -1;
51
+     }
52
++    /* expat < 2.1.0 has no XML_SetHashSalt() */
53
++    if (EXPAT(SetHashSalt) != NULL) {
54
++        EXPAT(SetHashSalt)(self->parser,
55
++                           (unsigned long)_Py_HashSecret.expat.hashsalt);
56
++    }
57
+ 
58
+     if (target) {
59
+         Py_INCREF(target);
60
+diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
61
+index 47c3e86..aa21d93 100644
62
+--- a/Modules/pyexpat.c
63
+@@ -1887,6 +1887,11 @@ MODULE_INITFUNC(void)
64
+     capi.SetStartDoctypeDeclHandler = XML_SetStartDoctypeDeclHandler;
65
+     capi.SetEncoding = XML_SetEncoding;
66
+     capi.DefaultUnknownEncodingHandler = PyUnknownEncodingHandler;
67
++#if XML_COMBINED_VERSION >= 20100
68
++    capi.SetHashSalt = XML_SetHashSalt;
69
++#else
70
++    capi.SetHashSalt = NULL;
71
++#endif
72
+ 
73
+     /* export using capsule */
74
+     capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        A high-level scripting language
2 2
 Name:           python3
3 3
 Version:        3.5.6
4
-Release:        1%{?dist}
4
+Release:        2%{?dist}
5 5
 License:        PSF
6 6
 URL:            http://www.python.org/
7 7
 Group:          System Environment/Programming
... ...
@@ -14,6 +14,7 @@ Patch1:         sockWarning.patch
14 14
 Patch3:         python3-CVE-2018-1000117.patch
15 15
 Patch4:         python3-CVE-2017-18207.patch
16 16
 Patch5:         python3-CVE-2018-1061.patch
17
+Patch6:         python3-CVE-2018-14647.patch
17 18
 BuildRequires:  pkg-config >= 0.28
18 19
 BuildRequires:  bzip2-devel
19 20
 BuildRequires:  ncurses-devel >= 6.0-3
... ...
@@ -95,6 +96,7 @@ to build python programs.
95 95
 %patch3 -p1
96 96
 %patch4 -p1
97 97
 %patch5 -p1
98
+%patch6 -p1
98 99
 
99 100
 %build
100 101
 export OPT="${CFLAGS}"
... ...
@@ -199,6 +201,8 @@ rm -rf %{buildroot}/*
199 199
 %{_bindir}/idle*
200 200
 
201 201
 %changelog
202
+*   Mon Dec 31 2018 Tapas Kundu <tkundu@vmware.com> 3.5.6-2
203
+-   Fix for CVE-2018-14647
202 204
 *   Thu Dec 06 2018 Sujay G <gsujay@vmware.com> 3.5.6-1
203 205
 -   Upgrade to version 3.5.6
204 206
 *   Fri Aug 17 2018 Dweep Advani <dadvani@vmware.com> 3.5.5-2