diff options
Diffstat (limited to 'meta/recipes-devtools/python/python3/CVE-2018-14647.patch')
| -rw-r--r-- | meta/recipes-devtools/python/python3/CVE-2018-14647.patch | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3/CVE-2018-14647.patch b/meta/recipes-devtools/python/python3/CVE-2018-14647.patch new file mode 100644 index 0000000000..c1f21f826c --- /dev/null +++ b/meta/recipes-devtools/python/python3/CVE-2018-14647.patch | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | From 610b4b0dbaedd3099ab76acf678e9cc845d99a76 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: stratakis <cstratak@redhat.com> | ||
| 3 | Date: Mon, 25 Feb 2019 22:04:09 +0100 | ||
| 4 | Subject: [PATCH] [3.5] bpo-34623: Use XML_SetHashSalt in _elementtree (#9933) | ||
| 5 | |||
| 6 | * bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146) | ||
| 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 | CVE: CVE-2018-14647 | ||
| 19 | Upstream-Status: Backport | ||
| 20 | [https://github.com/python/cpython/commit/41b48e71ac8a71f56694b548f118bd20ce203410] | ||
| 21 | |||
| 22 | Signed-off-by: Dan Tran <dantran@microsoft.com> | ||
| 23 | --- | ||
| 24 | Include/pyexpat.h | 4 +++- | ||
| 25 | .../next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst | 2 ++ | ||
| 26 | Modules/_elementtree.c | 5 +++++ | ||
| 27 | Modules/pyexpat.c | 5 +++++ | ||
| 28 | 4 files changed, 15 insertions(+), 1 deletion(-) | ||
| 29 | create mode 100644 Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst | ||
| 30 | |||
| 31 | diff --git a/Include/pyexpat.h b/Include/pyexpat.h | ||
| 32 | index 44259bf6d7..07020b5dc9 100644 | ||
| 33 | --- a/Include/pyexpat.h | ||
| 34 | +++ b/Include/pyexpat.h | ||
| 35 | @@ -3,7 +3,7 @@ | ||
| 36 | |||
| 37 | /* note: you must import expat.h before importing this module! */ | ||
| 38 | |||
| 39 | -#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0" | ||
| 40 | +#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1" | ||
| 41 | #define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" | ||
| 42 | |||
| 43 | struct PyExpat_CAPI | ||
| 44 | @@ -48,6 +48,8 @@ struct PyExpat_CAPI | ||
| 45 | enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding); | ||
| 46 | int (*DefaultUnknownEncodingHandler)( | ||
| 47 | void *encodingHandlerData, const XML_Char *name, XML_Encoding *info); | ||
| 48 | + /* might be none for expat < 2.1.0 */ | ||
| 49 | + int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt); | ||
| 50 | /* always add new stuff to the end! */ | ||
| 51 | }; | ||
| 52 | |||
| 53 | 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 | ||
| 54 | new file mode 100644 | ||
| 55 | index 0000000000..cbaa4b7506 | ||
| 56 | --- /dev/null | ||
| 57 | +++ b/Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst | ||
| 58 | @@ -0,0 +1,2 @@ | ||
| 59 | +CVE-2018-14647: The C accelerated _elementtree module now initializes hash | ||
| 60 | +randomization salt from _Py_HashSecret instead of libexpat's default CSPRNG. | ||
| 61 | diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c | ||
| 62 | index 5dba9f70a9..90c6daf64a 100644 | ||
| 63 | --- a/Modules/_elementtree.c | ||
| 64 | +++ b/Modules/_elementtree.c | ||
| 65 | @@ -3282,6 +3282,11 @@ _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *html, | ||
| 66 | PyErr_NoMemory(); | ||
| 67 | return -1; | ||
| 68 | } | ||
| 69 | + /* expat < 2.1.0 has no XML_SetHashSalt() */ | ||
| 70 | + if (EXPAT(SetHashSalt) != NULL) { | ||
| 71 | + EXPAT(SetHashSalt)(self->parser, | ||
| 72 | + (unsigned long)_Py_HashSecret.expat.hashsalt); | ||
| 73 | + } | ||
| 74 | |||
| 75 | if (target) { | ||
| 76 | Py_INCREF(target); | ||
| 77 | diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c | ||
| 78 | index adc9b6cde8..948ab1b703 100644 | ||
| 79 | --- a/Modules/pyexpat.c | ||
| 80 | +++ b/Modules/pyexpat.c | ||
| 81 | @@ -1882,6 +1882,11 @@ MODULE_INITFUNC(void) | ||
| 82 | capi.SetStartDoctypeDeclHandler = XML_SetStartDoctypeDeclHandler; | ||
| 83 | capi.SetEncoding = XML_SetEncoding; | ||
| 84 | capi.DefaultUnknownEncodingHandler = PyUnknownEncodingHandler; | ||
| 85 | +#if XML_COMBINED_VERSION >= 20100 | ||
| 86 | + capi.SetHashSalt = XML_SetHashSalt; | ||
| 87 | +#else | ||
| 88 | + capi.SetHashSalt = NULL; | ||
| 89 | +#endif | ||
| 90 | |||
| 91 | /* export using capsule */ | ||
| 92 | capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL); | ||
| 93 | -- | ||
| 94 | 2.22.0.vfs.1.1.57.gbaf16c8 | ||
| 95 | |||
