Blame SOURCES/edk2-NetworkPkg-HttpDxe-Set-the-HostName-for-the-verifica.patch

63d87e
From d28c0053e94b8e721307ac1698d86e5dfb328e6d Mon Sep 17 00:00:00 2001
63d87e
From: Laszlo Ersek <lersek@redhat.com>
63d87e
Date: Mon, 2 Dec 2019 12:32:04 +0100
63d87e
Subject: [PATCH 8/9] NetworkPkg/HttpDxe: Set the HostName for the verification
63d87e
 (CVE-2019-14553)
63d87e
MIME-Version: 1.0
63d87e
Content-Type: text/plain; charset=UTF-8
63d87e
Content-Transfer-Encoding: 8bit
63d87e
63d87e
RH-Author: Laszlo Ersek <lersek@redhat.com>
63d87e
Message-id: <20191117220052.15700-9-lersek@redhat.com>
63d87e
Patchwork-id: 92459
63d87e
O-Subject: [RHEL-8.2.0 edk2 PATCH 8/9] NetworkPkg/HttpDxe: Set the HostName for the verification (CVE-2019-14553)
63d87e
Bugzilla: 1536624
63d87e
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
63d87e
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
63d87e
63d87e
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
63d87e
63d87e
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=960
63d87e
CVE: CVE-2019-14553
63d87e
Set the HostName by consuming TLS protocol to enable the host name
63d87e
check so as to avoid the potential Man-In-The-Middle attack.
63d87e
63d87e
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
63d87e
Reviewed-by: Ye Ting <ting.ye@intel.com>
63d87e
Reviewed-by: Long Qin <qin.long@intel.com>
63d87e
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
63d87e
Acked-by: Laszlo Ersek <lersek@redhat.com>
63d87e
Message-Id: <20190927034441.3096-5-Jiaxin.wu@intel.com>
63d87e
Cc: David Woodhouse <dwmw2@infradead.org>
63d87e
Cc: Jian J Wang <jian.j.wang@intel.com>
63d87e
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
63d87e
Cc: Sivaraman Nainar <sivaramann@amiindia.co.in>
63d87e
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
63d87e
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
63d87e
(cherry picked from commit e2fc50812895b17e8b23f5a9c43cde29531b200f)
63d87e
---
63d87e
 NetworkPkg/HttpDxe/HttpProto.h    |  1 +
63d87e
 NetworkPkg/HttpDxe/HttpsSupport.c | 21 +++++++++++++++++----
63d87e
 2 files changed, 18 insertions(+), 4 deletions(-)
63d87e
63d87e
diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h
63d87e
index 6e1f517..34308e0 100644
63d87e
--- a/NetworkPkg/HttpDxe/HttpProto.h
63d87e
+++ b/NetworkPkg/HttpDxe/HttpProto.h
63d87e
@@ -82,6 +82,7 @@ typedef struct {
63d87e
   EFI_TLS_VERSION               Version;
63d87e
   EFI_TLS_CONNECTION_END        ConnectionEnd;
63d87e
   EFI_TLS_VERIFY                VerifyMethod;
63d87e
+  EFI_TLS_VERIFY_HOST           VerifyHost;
63d87e
   EFI_TLS_SESSION_STATE         SessionState;
63d87e
 } TLS_CONFIG_DATA;
63d87e
 
63d87e
diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c b/NetworkPkg/HttpDxe/HttpsSupport.c
63d87e
index 988bbcb..5dfb13b 100644
63d87e
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
63d87e
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
63d87e
@@ -623,13 +623,16 @@ TlsConfigureSession (
63d87e
   //
63d87e
   // TlsConfigData initialization
63d87e
   //
63d87e
-  HttpInstance->TlsConfigData.ConnectionEnd = EfiTlsClient;
63d87e
-  HttpInstance->TlsConfigData.VerifyMethod = EFI_TLS_VERIFY_PEER;
63d87e
-  HttpInstance->TlsConfigData.SessionState = EfiTlsSessionNotStarted;
63d87e
+  HttpInstance->TlsConfigData.ConnectionEnd       = EfiTlsClient;
63d87e
+  HttpInstance->TlsConfigData.VerifyMethod        = EFI_TLS_VERIFY_PEER;
63d87e
+  HttpInstance->TlsConfigData.VerifyHost.Flags    = EFI_TLS_VERIFY_FLAG_NO_WILDCARDS;
63d87e
+  HttpInstance->TlsConfigData.VerifyHost.HostName = HttpInstance->RemoteHost;
63d87e
+  HttpInstance->TlsConfigData.SessionState        = EfiTlsSessionNotStarted;
63d87e
 
63d87e
   //
63d87e
   // EfiTlsConnectionEnd,
63d87e
-  // EfiTlsVerifyMethod
63d87e
+  // EfiTlsVerifyMethod,
63d87e
+  // EfiTlsVerifyHost,
63d87e
   // EfiTlsSessionState
63d87e
   //
63d87e
   Status = HttpInstance->Tls->SetSessionData (
63d87e
@@ -654,6 +657,16 @@ TlsConfigureSession (
63d87e
 
63d87e
   Status = HttpInstance->Tls->SetSessionData (
63d87e
                                 HttpInstance->Tls,
63d87e
+                                EfiTlsVerifyHost,
63d87e
+                                &HttpInstance->TlsConfigData.VerifyHost,
63d87e
+                                sizeof (EFI_TLS_VERIFY_HOST)
63d87e
+                                );
63d87e
+  if (EFI_ERROR (Status)) {
63d87e
+    return Status;
63d87e
+  }
63d87e
+
63d87e
+  Status = HttpInstance->Tls->SetSessionData (
63d87e
+                                HttpInstance->Tls,
63d87e
                                 EfiTlsSessionState,
63d87e
                                 &(HttpInstance->TlsConfigData.SessionState),
63d87e
                                 sizeof (EFI_TLS_SESSION_STATE)
63d87e
-- 
63d87e
1.8.3.1
63d87e