From 1b6dc2b543446401fd38795f1ccf2b93633f01c0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 31 Jul 2016 00:51:48 +0200 Subject: [PATCH 1/2] TLS: only reuse connections with the same client cert CVE-2016-5420 Bug: https://curl.haxx.se/docs/adv_20160803B.html Upstream-commit: 11ec5ad4352bba384404c56e77c7fab9382fd22d Signed-off-by: Kamil Dudka --- lib/sslgen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sslgen.c b/lib/sslgen.c index 3036bb2..79cbb6f 100644 --- a/lib/sslgen.c +++ b/lib/sslgen.c @@ -90,6 +90,7 @@ Curl_ssl_config_matches(struct ssl_config_data* data, (data->verifyhost == needle->verifyhost) && safe_strequal(data->CApath, needle->CApath) && safe_strequal(data->CAfile, needle->CAfile) && + safe_strequal(data->clientcert, needle->clientcert) && safe_strequal(data->random_file, needle->random_file) && safe_strequal(data->egdsocket, needle->egdsocket) && safe_strequal(data->cipher_list, needle->cipher_list)) -- 2.5.5 From 1a7116f8607868b26355c512e5844a9b85f16daf Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 22 Aug 2016 10:24:35 +0200 Subject: [PATCH 2/2] nss: refuse previously loaded certificate from file ... when we are not asked to use a certificate from file Upstream-commit: 7700fcba64bf5806de28f6c1c7da3b4f0b38567d Signed-off-by: Kamil Dudka --- lib/nss.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/nss.c b/lib/nss.c index 1f02988..7b4fe57 100644 --- a/lib/nss.c +++ b/lib/nss.c @@ -760,10 +760,10 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock, struct ssl_connect_data *connssl = (struct ssl_connect_data *)arg; struct SessionHandle *data = connssl->data; const char *nickname = connssl->client_nickname; + static const char pem_slotname[] = "PEM Token #1"; if(connssl->obj_clicert) { /* use the cert/key provided by PEM reader */ - static const char pem_slotname[] = "PEM Token #1"; SECItem cert_der = { 0, NULL, 0 }; void *proto_win = SSL_RevealPinArg(sock); struct CERTCertificateStr *cert; @@ -825,6 +825,12 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock, if(NULL == nickname) nickname = "[unknown]"; + if(!strncmp(nickname, pem_slotname, sizeof(pem_slotname) - 1U)) { + failf(data, "NSS: refusing previously loaded certificate from file: %s", + nickname); + return SECFailure; + } + if(NULL == *pRetKey) { failf(data, "NSS: private key not found for certificate: %s", nickname); return SECFailure; -- 2.7.4