Skip to content

Commit d9d9e66

Browse files
SoumyaWindhongxu-jia
authored andcommitted
ovmf: Fix CVE-2023-45234
EDK2's Network Package is susceptible to a buffer overflow vulnerability when processing DNS Servers option from a DHCPv6 Advertise message. This vulnerability can be exploited by an attacker to gain unauthorized access and potentially lead to a loss of Confidentiality, Integrity and/or Availability. References: https://nvd.nist.gov/vuln/detail/CVE-2023-45234 Upstream-patches: tianocore/edk2@1b53515 tianocore/edk2@458c582 Signed-off-by: Soumya Sambu <[email protected]>
1 parent c84eb03 commit d9d9e66

File tree

3 files changed

+641
-0
lines changed

3 files changed

+641
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
From 1b53515d53d303166b2bbd31e2cc7f16fd0aecd7 Mon Sep 17 00:00:00 2001
2+
From: Doug Flick <[email protected]>
3+
Date: Fri, 26 Jan 2024 05:54:52 +0800
4+
Subject: [PATCH] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45234 Patch
5+
6+
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4539
7+
8+
Bug Details:
9+
PixieFail Bug #6
10+
CVE-2023-45234
11+
CVSS 8.3 : CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:H
12+
CWE-119 Improper Restriction of Operations within the Bounds of
13+
a Memory Buffer
14+
15+
Buffer overflow when processing DNS Servers option in a DHCPv6
16+
Advertise message
17+
18+
Change Overview:
19+
20+
Introduces a function to cache the Dns Server and perform sanitizing
21+
on the incoming DnsServerLen to ensure that the length is valid
22+
23+
> + EFI_STATUS
24+
> + PxeBcCacheDnsServerAddresses (
25+
> + IN PXEBC_PRIVATE_DATA *Private,
26+
> + IN PXEBC_DHCP6_PACKET_CACHE *Cache6
27+
> + )
28+
29+
Additional code cleanup
30+
31+
Cc: Saloni Kasbekar <[email protected]>
32+
Cc: Zachary Clark-williams <[email protected]>
33+
34+
Signed-off-by: Doug Flick [MSFT] <[email protected]>
35+
Reviewed-by: Saloni Kasbekar <[email protected]>
36+
37+
CVE: CVE-2023-45234
38+
39+
Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/1b53515d53d303166b2bbd31e2cc7f16fd0aecd7]
40+
41+
Signed-off-by: Soumya Sambu <[email protected]>
42+
---
43+
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 71 +++++++++++++++++++++++++---
44+
1 file changed, 65 insertions(+), 6 deletions(-)
45+
46+
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
47+
index 425e0cf806..2b2d372889 100644
48+
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
49+
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
50+
@@ -3,6 +3,7 @@
51+
52+
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
53+
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
54+
+ Copyright (c) Microsoft Corporation
55+
56+
SPDX-License-Identifier: BSD-2-Clause-Patent
57+
58+
@@ -1312,6 +1313,65 @@ PxeBcSelectDhcp6Offer (
59+
}
60+
}
61+
62+
+/**
63+
+ Cache the DHCPv6 DNS Server addresses
64+
+
65+
+ @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
66+
+ @param[in] Cache6 The pointer to PXEBC_DHCP6_PACKET_CACHE.
67+
+
68+
+ @retval EFI_SUCCESS Cache the DHCPv6 DNS Server address successfully.
69+
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
70+
+ @retval EFI_DEVICE_ERROR The DNS Server Address Length provided by a untrusted
71+
+ option is not a multiple of 16 bytes (sizeof (EFI_IPv6_ADDRESS)).
72+
+**/
73+
+EFI_STATUS
74+
+PxeBcCacheDnsServerAddresses (
75+
+ IN PXEBC_PRIVATE_DATA *Private,
76+
+ IN PXEBC_DHCP6_PACKET_CACHE *Cache6
77+
+ )
78+
+{
79+
+ UINT16 DnsServerLen;
80+
+
81+
+ DnsServerLen = NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen);
82+
+ //
83+
+ // Make sure that the number is nonzero
84+
+ //
85+
+ if (DnsServerLen == 0) {
86+
+ return EFI_DEVICE_ERROR;
87+
+ }
88+
+
89+
+ //
90+
+ // Make sure the DnsServerlen is a multiple of EFI_IPv6_ADDRESS (16)
91+
+ //
92+
+ if (DnsServerLen % sizeof (EFI_IPv6_ADDRESS) != 0) {
93+
+ return EFI_DEVICE_ERROR;
94+
+ }
95+
+
96+
+ //
97+
+ // This code is currently written to only support a single DNS Server instead
98+
+ // of multiple such as is spec defined (RFC3646, Section 3). The proper behavior
99+
+ // would be to allocate the full space requested, CopyMem all of the data,
100+
+ // and then add a DnsServerCount field to Private and update additional code
101+
+ // that depends on this.
102+
+ //
103+
+ // To support multiple DNS servers the `AllocationSize` would need to be changed to DnsServerLen
104+
+ //
105+
+ // This is tracked in https://bugzilla.tianocore.org/show_bug.cgi?id=1886
106+
+ //
107+
+ Private->DnsServer = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS));
108+
+ if (Private->DnsServer == NULL) {
109+
+ return EFI_OUT_OF_RESOURCES;
110+
+ }
111+
+
112+
+ //
113+
+ // Intentionally only copy over the first server address.
114+
+ // To support multiple DNS servers, the `Length` would need to be changed to DnsServerLen
115+
+ //
116+
+ CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS));
117+
+
118+
+ return EFI_SUCCESS;
119+
+}
120+
+
121+
/**
122+
Handle the DHCPv6 offer packet.
123+
124+
@@ -1335,6 +1395,7 @@ PxeBcHandleDhcp6Offer (
125+
UINT32 SelectIndex;
126+
UINT32 Index;
127+
128+
+ ASSERT (Private != NULL);
129+
ASSERT (Private->SelectIndex > 0);
130+
SelectIndex = (UINT32)(Private->SelectIndex - 1);
131+
ASSERT (SelectIndex < PXEBC_OFFER_MAX_NUM);
132+
@@ -1342,15 +1403,13 @@ PxeBcHandleDhcp6Offer (
133+
Status = EFI_SUCCESS;
134+
135+
//
136+
- // First try to cache DNS server address if DHCP6 offer provides.
137+
+ // First try to cache DNS server addresses if DHCP6 offer provides.
138+
//
139+
if (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] != NULL) {
140+
- Private->DnsServer = AllocateZeroPool (NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen));
141+
- if (Private->DnsServer == NULL) {
142+
- return EFI_OUT_OF_RESOURCES;
143+
+ Status = PxeBcCacheDnsServerAddresses (Private, Cache6);
144+
+ if (EFI_ERROR (Status)) {
145+
+ return Status;
146+
}
147+
-
148+
- CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS));
149+
}
150+
151+
if (Cache6->OfferType == PxeOfferTypeDhcpBinl) {
152+
--
153+
2.40.0
154+

0 commit comments

Comments
 (0)