diff --git a/backport-CVE-2019-20907.patch b/backport-CVE-2019-20907.patch new file mode 100644 index 0000000000000000000000000000000000000000..130758fa8125cbde455b4dd18c652948413c7150 --- /dev/null +++ b/backport-CVE-2019-20907.patch @@ -0,0 +1,1081 @@ +From 1fa6ef2bc7cee1c8e088dd8b397d9b2d54036dbc Mon Sep 17 00:00:00 2001 +From: Rajarishi Devarajan +Date: Sun, 12 Jul 2020 23:47:42 +0200 +Subject: [PATCH] bpo-39017 Fix infinite loop in the tarfile module + +Add a check for length = 0 in the _proc_pax function to avoid running into an infinite loop + +Signed-off-by:Rajarishi Devarajan +--- + Lib/tarfile.py | 2 + + Lib/test/recursion.tar | 1017 +++++++++++++++++ + Lib/test/test_tarfile.py | 7 + + .../2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst | 1 + + 4 files changed, 1027 insertions(+) + create mode 100644 Lib/test/recursion.tar + create mode 100644 Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst + +diff --git a/Lib/tarfile.py b/Lib/tarfile.py +index 85119a4..00b102b 100755 +--- a/Lib/tarfile.py ++++ b/Lib/tarfile.py +@@ -1231,6 +1231,8 @@ class TarInfo(object): + + length, keyword = match.groups() + length = int(length) ++ if length == 0: ++ raise InvalidHeaderError("invalid header") + value = buf[match.end(2) + 1:match.start(1) + length - 1] + + # Normally, we could just use "utf-8" as the encoding and "strict" +diff --git a/Lib/test/recursion.tar b/Lib/test/recursion.tar +new file mode 100644 +index 0000000..a56ed9c +--- /dev/null ++++ b/Lib/test/recursion.tar +@@ -0,0 +1,1017 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ cpython/recursion.tar at master · python/cpython · GitHub ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ Skip to content ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++
++ ++ ++ ++ ++
++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++
++
++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++
++ ++
++

++ ++ ++ / ++ ++ cpython ++ ++ ++

++ ++ ++
++ ++ ++ ++
++ ++ ++
++ ++
++
++ ++ ++ ++ ++ ++ ++ ++ Permalink ++ ++ ++ ++ ++ ++
++ ++
++ ++ ++ ++ Branch: ++ master ++ ++ ++ ++ ++
++ ++ ++ ++
++
++
++ ++ ++ ++ Go to file ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++ ++ ++
++ ++
++
++ ++ @rishi93 ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++
++ ++ Latest commit ++ 5a8d121 ++ Jul 15, 2020 ++ ++ ++ ++ ++ ++ ++ History ++ ++ ++
++
++
Avoid infinite loop when reading specially crafted TAR files using the tarfile module
++(CVE-2019-20907).
++ ++
++ ++
++
++ ++ ++ ++ 1 ++ ++ contributor ++ ++ ++
++ ++

++ Users who have contributed to this file ++

++
++ ++
++
++
++
++ ++ ++ ++ ++ ++ ++
++ ++
++
++ ++ ++ 1 lines (1 sloc) ++ ++ 516 Bytes ++
++ ++
++ ++
++ Raw ++ Blame ++
++ ++
++ ++ ++ ++ ++ ++ ++
++
++
++ ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++
bcaller00010002755 g00000 X=
++ ++ ++ ++
++ ++
++ ++ ++ ++ ++
++ ++ ++
++ ++ ++
++
++ ++ ++ ++ ++
++
++ ++
++
++ ++ ++
++ ++ ++ ++ ++ ++ ++
++ ++ ++ You can’t perform that action at this time. ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py +index 7d2eec8..ce820d1 100644 +--- a/Lib/test/test_tarfile.py ++++ b/Lib/test/test_tarfile.py +@@ -395,6 +395,13 @@ class CommonReadTest(ReadTest): + with self.assertRaisesRegex(tarfile.ReadError, "unexpected end of data"): + tar.extractfile(t).read() + ++ def test_length_zero_header(self): ++ # bpo-39017 (CVE-2019-20907): reading a zero-length header should fail ++ # with an exception ++ with self.assertRaisesRegex(tarfile.ReadError, "file could not be opened successfully"): ++ with tarfile.open(support.findfile('recursion.tar')) as tar: ++ pass ++ + class MiscReadTestBase(CommonReadTest): + def requires_name_attribute(self): + pass +diff --git a/Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst b/Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst +new file mode 100644 +index 0000000..ad26676 +--- /dev/null ++++ b/Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst +@@ -0,0 +1 @@ ++Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). +-- +2.19.1 + diff --git a/python3.spec b/python3.spec index bc3c85cabaad36f81fe632387da6200ff32bbc67..cb5b84f7f62ea5b4a8951f232b79ab94dae35c9e 100644 --- a/python3.spec +++ b/python3.spec @@ -3,7 +3,7 @@ Summary: Interpreter of the Python3 programming language URL: https://www.python.org/ Version: 3.7.4 -Release: 10 +Release: 11 License: Python %global branchversion 3.7 @@ -105,6 +105,7 @@ Patch6000: CVE-2019-16056.patch Patch6001: CVE-2019-16935.patch Patch6002: CVE-2019-17514.patch Patch6003: CVE-2019-9674.patch +Patch6004: backport-CVE-2019-20907.patch Patch9000: python3-add-generic-os-support.patch @@ -198,6 +199,7 @@ rm Lib/ensurepip/_bundled/*.whl %patch6001 -p1 %patch6002 -p1 %patch6003 -p1 +%patch6004 -p1 %patch9000 -p1 @@ -801,6 +803,12 @@ export BEP_GTDLIST="$BEP_GTDLIST_TMP" %{_mandir}/*/* %changelog +* Tue Aug 4 2020 wenzhanli - 3.7.4-11 +- Type:cves +- ID:NA +- SUG:NA +- DESC:Fix CVE-2019-20907 + * Mon Jun 1 2020 hanxinke - 3.7.4-10 - Type:bugfix - ID:NA