From 92ab1b052a9df860ea9cfe16d078d1e7577b80dd Mon Sep 17 00:00:00 2001 From: sxt1001 Date: Fri, 5 Feb 2021 10:54:40 +0800 Subject: [PATCH] fix CVE-2020-27783 (cherry picked from commit aa459788cf73b99b1022b2d8f9c93bdb8d2f095a) --- backport-CVE-2020-27783-1.patch | 49 ++++++++++++ backport-CVE-2020-27783-2.patch | 136 ++++++++++++++++++++++++++++++++ python-lxml.spec | 21 +++-- 3 files changed, 200 insertions(+), 6 deletions(-) create mode 100644 backport-CVE-2020-27783-1.patch create mode 100644 backport-CVE-2020-27783-2.patch diff --git a/backport-CVE-2020-27783-1.patch b/backport-CVE-2020-27783-1.patch new file mode 100644 index 0000000..3ae5153 --- /dev/null +++ b/backport-CVE-2020-27783-1.patch @@ -0,0 +1,49 @@ +From 89e7aad6e7ff9ecd88678ff25f885988b184b26e Mon Sep 17 00:00:00 2001 +From: Stefan Behnel +Date: Sun, 18 Oct 2020 10:06:46 +0200 +Subject: [PATCH] Prevent combinations of through into the output. ++ html = '', ++ lxml.html.tostring(clean_html(s))) ++ + + def test_suite(): + suite = unittest.TestSuite() +-- +1.8.3.1 + diff --git a/backport-CVE-2020-27783-2.patch b/backport-CVE-2020-27783-2.patch new file mode 100644 index 0000000..69a3070 --- /dev/null +++ b/backport-CVE-2020-27783-2.patch @@ -0,0 +1,136 @@ +From a105ab8dc262ec6735977c25c13f0bdfcdec72a7 Mon Sep 17 00:00:00 2001 +From: Stefan Behnel +Date: Thu, 26 Nov 2020 09:20:52 +0100 +Subject: [PATCH] Prevent combinations of and ' ++ return True + return False + + def clean_html(self, html): +diff --git a/src/lxml/html/tests/test_clean.py b/src/lxml/html/tests/test_clean.py +index 3c8ee25..0e669f9 100644 +--- a/src/lxml/html/tests/test_clean.py ++++ b/src/lxml/html/tests/test_clean.py +@@ -113,6 +113,16 @@ class CleanerTest(unittest.TestCase): + b'', + lxml.html.tostring(clean_html(s))) + ++ def test_sneaky_js_in_math_style(self): ++ # This gets parsed as -> ++ # thus passing any tag/script/whatever content through into the output. ++ html = '' ++ s = lxml.html.fragment_fromstring(html) ++ ++ self.assertEqual( ++ b'', ++ lxml.html.tostring(clean_html(s))) ++ + + def test_suite(): + suite = unittest.TestSuite() +diff --git a/src/lxml/html/tests/test_clean.txt b/src/lxml/html/tests/test_clean.txt +index 275be07..18e6c7e 100644 +--- a/src/lxml/html/tests/test_clean.txt ++++ b/src/lxml/html/tests/test_clean.txt +@@ -104,7 +104,11 @@ + >>> print(Cleaner(page_structure=False, comments=False).clean_html(doc)) + + +- ++ + + + +@@ -126,7 +130,11 @@ + >>> print(Cleaner(page_structure=False, safe_attrs_only=False).clean_html(doc)) + + +- ++ + + + a link +@@ -190,7 +198,11 @@ + + + +- ++ + + + a link +-- +1.8.3.1 + diff --git a/python-lxml.spec b/python-lxml.spec index cedcb03..79857f9 100644 --- a/python-lxml.spec +++ b/python-lxml.spec @@ -6,13 +6,16 @@ the simplicity of a native Python API, mostly compatible but superior to the wel The latest release works with all CPython versions from 2.7 to 3.7. Name: python-%{modname} -Version: 4.6.2 -Release: 1 +Version: 4.5.2 +Release: 2 Summary: XML processing library combining libxml2/libxslt with the ElementTree API License: BSD URL: https://files.pythonhosted.org Source0: https://files.pythonhosted.org/packages/db/f7/43fecb94d66959c1e23aa53d6161231dca0e93ec500224cf31b3c4073e37/lxml-4.6.2.tar.gz +Patch6000: backport-CVE-2020-27783-1.patch +Patch6001: backport-CVE-2020-27783-2.patch + BuildRequires: gcc libxml2-devel libxslt-devel %description %{_description} @@ -28,7 +31,7 @@ BuildRequires: python3-devel python3-setuptools python3-Cython %package_help %prep -%autosetup -n %{modname}-%{version} +%autosetup -n %{modname}-%{version} -p1 %build export WITH_CYTHON=true @@ -49,9 +52,15 @@ export WITH_CYTHON=true %files help %doc README.rst src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -%changelog -* Mon Feb 1 2021 wangjie - 4.6.2-1 -- upgrade 4.6.2-1 +%changelog +* Fri Feb 05 2021 shixuantong - 4.5.2-2 +- fix CVE-2020-27783 + +* Tue Jan 05 2020 shixuantong - 4.5.2-1 +- update version to 4.5.2 + +* Fri Aug 21 2020 shixuantong - 4.2.3-5 +- add release version for rebuild * Fri Oct 30 2020 wuchaochao - 4.5.2-2 - Type:bufix -- Gitee