|
|
b9ffd2 |
From c660debb97f4f422255a82fef2d77804552c043a Mon Sep 17 00:00:00 2001
|
|
|
b9ffd2 |
From: Christian Heimes <christian@python.org>
|
|
|
b9ffd2 |
Date: Tue, 15 Jan 2019 18:16:30 +0100
|
|
|
b9ffd2 |
Subject: [PATCH] bpo-35746: Fix segfault in ssl's cert parser
|
|
|
b9ffd2 |
|
|
|
b9ffd2 |
CVE-2019-5010, Fix a NULL pointer deref in ssl module. The cert parser did
|
|
|
b9ffd2 |
not handle CRL distribution points with empty DP or URI correctly. A
|
|
|
b9ffd2 |
malicious or buggy certificate can result into segfault.
|
|
|
b9ffd2 |
|
|
|
b9ffd2 |
Signed-off-by: Christian Heimes <christian@python.org>
|
|
|
b9ffd2 |
---
|
|
|
b9ffd2 |
Lib/test/talos-2019-0758.pem | 22 +++++++++++++++++++
|
|
|
b9ffd2 |
Lib/test/test_ssl.py | 22 +++++++++++++++++++
|
|
|
b9ffd2 |
.../2019-01-15-18-16-05.bpo-35746.nMSd0j.rst | 3 +++
|
|
|
b9ffd2 |
Modules/_ssl.c | 4 ++++
|
|
|
b9ffd2 |
4 files changed, 51 insertions(+)
|
|
|
b9ffd2 |
create mode 100644 Lib/test/talos-2019-0758.pem
|
|
|
b9ffd2 |
create mode 100644 Misc/NEWS.d/next/Security/2019-01-15-18-16-05.bpo-35746.nMSd0j.rst
|
|
|
b9ffd2 |
|
|
|
b9ffd2 |
diff --git a/Lib/test/talos-2019-0758.pem b/Lib/test/talos-2019-0758.pem
|
|
|
b9ffd2 |
new file mode 100644
|
|
|
b9ffd2 |
index 000000000000..13b95a77fd8a
|
|
|
b9ffd2 |
--- /dev/null
|
|
|
b9ffd2 |
+++ b/Lib/test/talos-2019-0758.pem
|
|
|
b9ffd2 |
@@ -0,0 +1,22 @@
|
|
|
b9ffd2 |
+-----BEGIN CERTIFICATE-----
|
|
|
b9ffd2 |
+MIIDqDCCApKgAwIBAgIBAjALBgkqhkiG9w0BAQswHzELMAkGA1UEBhMCVU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AMAsGCSqG
|
|
|
b9ffd2 |
+SIb3DQEBCwOCAQEAvqantx2yBlM11RoFiCfi+AfSblXPdrIrHvccepV4pYc/yO6p
|
|
|
b9ffd2 |
+t1f2dxHQb8rWH3i6cWag/EgIZx+HJQvo0rgPY1BFJsX1WnYf1/znZpkUBGbVmlJr
|
|
|
b9ffd2 |
+t/dW1gSkNS6sPsM0Q+7HPgEv8CPDNK5eo7vU2seE0iWOkxSyVUuiCEY9ZVGaLVit
|
|
|
b9ffd2 |
+p0C78nZ35Pdv4I+1cosmHl28+es1WI22rrnmdBpH8J1eY6WvUw2xuZHLeNVN0TzV
|
|
|
b9ffd2 |
+Q3qq53AaCWuLOD1AjESWuUCxMZTK9DPS4JKXTK8RLyDeqOvJGjsSWp3kL0y3GaQ+
|
|
|
b9ffd2 |
+10T1rfkKJub2+m9A9duin1fn6tHc2wSvB7m3DA==
|
|
|
b9ffd2 |
+-----END CERTIFICATE-----
|
|
|
b9ffd2 |
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
|
|
|
b9ffd2 |
index 7f6b93148f45..1fc657f4d867 100644
|
|
|
b9ffd2 |
--- a/Lib/test/test_ssl.py
|
|
|
b9ffd2 |
+++ b/Lib/test/test_ssl.py
|
|
|
b9ffd2 |
@@ -115,6 +115,7 @@ def data_file(*name):
|
|
|
b9ffd2 |
BADKEY = data_file("badkey.pem")
|
|
|
b9ffd2 |
NOKIACERT = data_file("nokia.pem")
|
|
|
b9ffd2 |
NULLBYTECERT = data_file("nullbytecert.pem")
|
|
|
b9ffd2 |
+TALOS_INVALID_CRLDP = data_file("talos-2019-0758.pem")
|
|
|
b9ffd2 |
|
|
|
b9ffd2 |
DHFILE = data_file("ffdh3072.pem")
|
|
|
b9ffd2 |
BYTES_DHFILE = os.fsencode(DHFILE)
|
|
|
b9ffd2 |
@@ -348,6 +349,27 @@ def test_parse_cert(self):
|
|
|
b9ffd2 |
self.assertEqual(p['crlDistributionPoints'],
|
|
|
b9ffd2 |
('http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl',))
|
|
|
b9ffd2 |
|
|
|
b9ffd2 |
+ def test_parse_cert_CVE_2019_5010(self):
|
|
|
b9ffd2 |
+ p = ssl._ssl._test_decode_cert(TALOS_INVALID_CRLDP)
|
|
|
b9ffd2 |
+ if support.verbose:
|
|
|
b9ffd2 |
+ sys.stdout.write("\n" + pprint.pformat(p) + "\n")
|
|
|
b9ffd2 |
+ self.assertEqual(
|
|
|
b9ffd2 |
+ p,
|
|
|
b9ffd2 |
+ {
|
|
|
b9ffd2 |
+ 'issuer': (
|
|
|
b9ffd2 |
+ (('countryName', 'UK'),), (('commonName', 'cody-ca'),)),
|
|
|
b9ffd2 |
+ 'notAfter': 'Jun 14 18:00:58 2028 GMT',
|
|
|
b9ffd2 |
+ 'notBefore': 'Jun 18 18:00:58 2018 GMT',
|
|
|
b9ffd2 |
+ 'serialNumber': '02',
|
|
|
b9ffd2 |
+ 'subject': ((('countryName', 'UK'),),
|
|
|
b9ffd2 |
+ (('commonName',
|
|
|
b9ffd2 |
+ 'codenomicon-vm-2.test.lal.cisco.com'),)),
|
|
|
b9ffd2 |
+ 'subjectAltName': (
|
|
|
b9ffd2 |
+ ('DNS', 'codenomicon-vm-2.test.lal.cisco.com'),),
|
|
|
b9ffd2 |
+ 'version': 3
|
|
|
b9ffd2 |
+ }
|
|
|
b9ffd2 |
+ )
|
|
|
b9ffd2 |
+
|
|
|
b9ffd2 |
def test_parse_cert_CVE_2013_4238(self):
|
|
|
b9ffd2 |
p = ssl._ssl._test_decode_cert(NULLBYTECERT)
|
|
|
b9ffd2 |
if support.verbose:
|
|
|
b9ffd2 |
diff --git a/Misc/NEWS.d/next/Security/2019-01-15-18-16-05.bpo-35746.nMSd0j.rst b/Misc/NEWS.d/next/Security/2019-01-15-18-16-05.bpo-35746.nMSd0j.rst
|
|
|
b9ffd2 |
new file mode 100644
|
|
|
b9ffd2 |
index 000000000000..dffe347eec84
|
|
|
b9ffd2 |
--- /dev/null
|
|
|
b9ffd2 |
+++ b/Misc/NEWS.d/next/Security/2019-01-15-18-16-05.bpo-35746.nMSd0j.rst
|
|
|
b9ffd2 |
@@ -0,0 +1,3 @@
|
|
|
b9ffd2 |
+[CVE-2019-5010] Fix a NULL pointer deref in ssl module. The cert parser did
|
|
|
b9ffd2 |
+not handle CRL distribution points with empty DP or URI correctly. A
|
|
|
b9ffd2 |
+malicious or buggy certificate can result into segfault.
|
|
|
b9ffd2 |
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
|
|
|
b9ffd2 |
index 4e3352d9e661..0e720e268d93 100644
|
|
|
b9ffd2 |
--- a/Modules/_ssl.c
|
|
|
b9ffd2 |
+++ b/Modules/_ssl.c
|
|
|
b9ffd2 |
@@ -1515,6 +1515,10 @@ _get_crl_dp(X509 *certificate) {
|
|
|
b9ffd2 |
STACK_OF(GENERAL_NAME) *gns;
|
|
|
b9ffd2 |
|
|
|
b9ffd2 |
dp = sk_DIST_POINT_value(dps, i);
|
|
|
b9ffd2 |
+ if (dp->distpoint == NULL) {
|
|
|
b9ffd2 |
+ /* Ignore empty DP value, CVE-2019-5010 */
|
|
|
b9ffd2 |
+ continue;
|
|
|
b9ffd2 |
+ }
|
|
|
b9ffd2 |
gns = dp->distpoint->name.fullname;
|
|
|
b9ffd2 |
|
|
|
b9ffd2 |
for (j=0; j < sk_GENERAL_NAME_num(gns); j++) {
|