python3: fix CVE-2020-14422
PATCH 1/2 python3: fix CVE-2020-14422
From: Lee Chee Yang <[email protected]>
Signed-off-by Lee Chee Yang <[email protected]>
--- .../python/python3/CVE-2020-14422.patch | 79 ++++++++++++++++++++++ meta/recipes-devtools/python/python3_3.7.7.bb | 3 +- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/python/python3/CVE-2020-14422.patch
meta/recipes-devtools/python/python3/CVE-2020-14422.patch new file +79 -0
@@ -0,0 +1,79 @@ +From b98e7790c77a4378ec4b1c71b84138cb930b69b7 Mon Sep 17 00:00:00 2001 +From: Tapas Kundu <[email protected]> +Date: Wed, 1 Jul 2020 00:50:21 +0530 +Subject: [PATCH] [3.7] bpo-41004: Resolve hash collisions for IPv4Interface + and IPv6Interface (GH-21033) (GH-21231) + +CVE-2020-14422 +The __hash__() methods of classes IPv4Interface and IPv6Interface had issue +of generating constant hash values of 32 and 128 respectively causing hash collisions. +The fix uses the hash() function to generate hash values for the objects +instead of XOR operation +(cherry picked from commit b30ee26e366bf509b7538d79bfec6c6d38d53f28) + +Co-authored-by: Ravi Teja P <[email protected]> + +Signed-off-by: Tapas Kundu <[email protected]> + +Upstream-Status: Backport [https://github.com/python/cpython/commit/b98e7790c77a4378ec4b1c71b84138cb930b69b7] +CVE: CVE-2020-14422 +Signed-off-by: Chee Yang Lee <[email protected]> + +--- + Lib/ipaddress.py | 4 ++-- + Lib/test/test_ipaddress.py | 11 +++++++++++ + .../Security/2020-06-29-16-02-29.bpo-41004.ovF0KZ.rst | 1 + + 3 files changed, 14 insertions(+), 2 deletions(-) + create mode 100644 Misc/NEWS.d/next/Security/2020-06-29-16-02-29.bpo-41004.ovF0KZ.rst + +diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py +index 80249288d73ab..54882934c3dc1 100644 +--- a/Lib/ipaddress.py ++++ b/Lib/ipaddress.py +@@ -1442,7 +1442,7 @@ def __lt__(self, other): + return False + + def __hash__(self): +- return self._ip ^ self._prefixlen ^ int(self.network.network_address) ++ return hash((self._ip, self._prefixlen, int(self.network.network_address))) + + __reduce__ = _IPAddressBase.__reduce__ + +@@ -2088,7 +2088,7 @@ def __lt__(self, other): + return False + + def __hash__(self): +- return self._ip ^ self._prefixlen ^ int(self.network.network_address) ++ return hash((self._ip, self._prefixlen, int(self.network.network_address))) + + __reduce__ = _IPAddressBase.__reduce__ + +diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py +index 455b893fb126f..1fb6a929dc2d9 100644 +--- a/Lib/test/test_ipaddress.py ++++ b/Lib/test/test_ipaddress.py +@@ -2091,6 +2091,17 @@ def testsixtofour(self): + sixtofouraddr.sixtofour) + self.assertFalse(bad_addr.sixtofour) + ++ # issue41004 Hash collisions in IPv4Interface and IPv6Interface ++ def testV4HashIsNotConstant(self): ++ ipv4_address1 = ipaddress.IPv4Interface("1.2.3.4") ++ ipv4_address2 = ipaddress.IPv4Interface("2.3.4.5") ++ self.assertNotEqual(ipv4_address1.__hash__(), ipv4_address2.__hash__()) ++ ++ # issue41004 Hash collisions in IPv4Interface and IPv6Interface ++ def testV6HashIsNotConstant(self): ++ ipv6_address1 = ipaddress.IPv6Interface("2001:658:22a:cafe:200:0:0:1") ++ ipv6_address2 = ipaddress.IPv6Interface("2001:658:22a:cafe:200:0:0:2") ++ self.assertNotEqual(ipv6_address1.__hash__(), ipv6_address2.__hash__()) + + if __name__ == '__main__': + unittest.main() +diff --git a/Misc/NEWS.d/next/Security/2020-06-29-16-02-29.bpo-41004.ovF0KZ.rst b/Misc/NEWS.d/next/Security/2020-06-29-16-02-29.bpo-41004.ovF0KZ.rst +new file mode 100644 +index 0000000000000..f5a9db52fff52 +--- /dev/null ++++ b/Misc/NEWS.d/next/Security/2020-06-29-16-02-29.bpo-41004.ovF0KZ.rst +@@ -0,0 +1 @@ ++CVE-2020-14422: The __hash__() methods of ipaddress.IPv4Interface and ipaddress.IPv6Interface incorrectly generated constant hash values of 32 and 128 respectively. This resulted in always causing hash collisions. The fix uses hash() to generate hash values for the tuple of (address, mask length, network address).
meta/recipes-devtools/python/python3_3.7.7.bb +2 -1
@@ -23,12 +23,13 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ file://0003-setup.py-pass-missing-libraries-to-Extension-for-mul.patch \ file://0001-Lib-sysconfig.py-fix-another-place-where-lib-is-hard.patch \ file://0001-Makefile-fix-Issue36464-parallel-build-race-problem.patch \ - file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \ + file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \ file://crosspythonpath.patch \ file://reformat_sysconfig.py \ file://0001-Use-FLAG_REF-always-for-interned-strings.patch \ file://0001-test_locale.py-correct-the-test-output-format.patch \ file://0001-bpo-39503-CVE-2020-8492-Fix-AbstractBasicAuthHandler.patch \ + file://CVE-2020-14422.patch \ " SRC_URI_append_class-native = " \
Signature · 1 line
2.7.4
PATCH 2/2 perl: fix CVE-2020-10543 & CVE-2020-10878
From: Lee Chee Yang <[email protected]>
Signed-off-by Lee Chee Yang <[email protected]>
--- .../perl/files/CVE-2020-10543.patch | 36 +++++ .../perl/files/CVE-2020-10878_1.patch | 152 +++++++++++++++++++++ .../perl/files/CVE-2020-10878_2.patch | 36 +++++ meta/recipes-devtools/perl/perl_5.30.1.bb | 3 + 4 files changed, 227 insertions(+) create mode 100644 meta/recipes-devtools/perl/files/CVE-2020-10543.patch create mode 100644 meta/recipes-devtools/perl/files/CVE-2020-10878_1.patch create mode 100644 meta/recipes-devtools/perl/files/CVE-2020-10878_2.patch
meta/recipes-devtools/perl/files/CVE-2020-10543.patch new file +36 -0
@@ -0,0 +1,36 @@ +From 897d1f7fd515b828e4b198d8b8bef76c6faf03ed Mon Sep 17 00:00:00 2001 +From: John Lightsey <[email protected]> +Date: Wed, 20 Nov 2019 20:02:45 -0600 +Subject: [PATCH] regcomp.c: Prevent integer overflow from nested regex + quantifiers. + +(CVE-2020-10543) On 32bit systems the size calculations for nested regular +expression quantifiers could overflow causing heap memory corruption. + +Fixes: Perl/perl5-security#125 +(cherry picked from commit bfd31397db5dc1a5c5d3e0a1f753a4f89a736e71) + +Upstream-Status: Backport [https://github.com/perl/perl5/commit/897d1f7fd515b828e4b198d8b8bef76c6faf03ed] +CVE: CVE-2020-10543 +Signed-off-by: Lee Chee Yang <[email protected]> +--- + regcomp.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/regcomp.c b/regcomp.c +index 93c8d98fbb0..5f86be8086d 100644 +--- a/regcomp.c ++++ b/regcomp.c +@@ -5489,6 +5489,12 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, + RExC_precomp))); + } + ++ if ( ( minnext > 0 && mincount >= SSize_t_MAX / minnext ) ++ || min >= SSize_t_MAX - minnext * mincount ) ++ { ++ FAIL("Regexp out of space"); ++ } ++ + min += minnext * mincount; + is_inf_internal |= deltanext == SSize_t_MAX + || (maxcount == REG_INFTY && minnext + deltanext > 0);
meta/recipes-devtools/perl/files/CVE-2020-10878_1.patch new file +152 -0
152 lines not on this page · raw message
meta/recipes-devtools/perl/files/CVE-2020-10878_2.patch new file +36 -0
@@ -0,0 +1,36 @@ +From 3295b48defa0f8570114877b063fe546dd348b3c Mon Sep 17 00:00:00 2001 +From: Karl Williamson <[email protected]> +Date: Thu, 20 Feb 2020 17:49:36 +0000 +Subject: [PATCH] regcomp: use long jumps if there is any possibility of + overflow + +(CVE-2020-10878) Be conservative for backporting, we'll aim to do +something more aggressive for bleadperl. + +(cherry picked from commit 9d7759db46f3b31b1d3f79c44266b6ba42a47fc6) + +Upstream-Status: Backport [https://github.com/perl/perl5/commit/3295b48defa0f8570114877b063fe546dd348b3c] +CVE: CVE-2020-10878 +Signed-off-by: Lee Chee Yang <[email protected]> +--- + regcomp.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/regcomp.c b/regcomp.c +index 4ba2980db66..73c35a67020 100644 +--- a/regcomp.c ++++ b/regcomp.c +@@ -7762,6 +7762,13 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, + + /* We have that number in RExC_npar */ + RExC_total_parens = RExC_npar; ++ ++ /* XXX For backporting, use long jumps if there is any possibility of ++ * overflow */ ++ if (RExC_size > U16_MAX && ! RExC_use_BRANCHJ) { ++ RExC_use_BRANCHJ = TRUE; ++ flags |= RESTART_PARSE; ++ } + } + else if (! MUST_RESTART(flags)) { + ReREFCNT_dec(Rx);
meta/recipes-devtools/perl/perl_5.30.1.bb +3 -0
@@ -23,6 +23,9 @@ SRC_URI = "https://www.cpan.org/src/5.0/perl-${PV}.tar.gz;name=perl \ file://0001-tests-adjust-to-correctly-exclude-unbuilt-extensions.patch \ file://determinism.patch \ file://racefix.patch \ + file://CVE-2020-10543.patch \ + file://CVE-2020-10878_1.patch \ + file://CVE-2020-10878_2.patch \ " SRC_URI_append_class-native = " \ file://perl-configpm-switch.patch \
Signature · 1 line
2.7.4