NetworkPkg: SECURITY PATCH CVE-2023-45237
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4542 Bug Overview: PixieFail Bug #9 CVE-2023-45237 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N CWE-338 Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) Use of a Weak PseudoRandom Number Generator Change Overview: Updates all Instances of NET_RANDOM (NetRandomInitSeed ()) to either > > EFI_STATUS > EFIAPI > PseudoRandomU32 ( > OUT UINT32 *Output > ); > or (depending on the use case) > > EFI_STATUS > EFIAPI > PseudoRandom ( > OUT VOID *Output, > IN UINTN OutputLength > ); > This is because the use of Example: The following code snippet PseudoRandomU32 () function is used: > > UINT32 Random; > > Status = PseudoRandomU32 (&Random); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); > return Status; > } > This also introduces a new PCD to enable/disable the use of the secure implementation of algorithms for PseudoRandom () and instead depend on the default implementation. This may be required for some platforms where the UEFI Spec defined algorithms are not available. > > PcdEnforceSecureRngAlgorithms > If the platform does not have any one of the UEFI defined secure RNG algorithms then the driver will assert. Cc: Saloni Kasbekar <saloni.kasbekar@intel.com> Cc: Zachary Clark-williams <zachary.clark-williams@intel.com> Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com> Reviewed-by: Saloni Kasbekar <saloni.kasbekar@intel.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Functions implementation related with DHCPv4 for UefiPxeBc Driver.
|
||||
|
||||
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
@@ -1381,6 +1381,12 @@ PxeBcDhcp4Discover (
|
||||
UINT8 VendorOptLen;
|
||||
UINT32 Xid;
|
||||
|
||||
Status = PseudoRandomU32 (&Xid);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Mode = Private->PxeBc.Mode;
|
||||
Dhcp4 = Private->Dhcp4;
|
||||
Status = EFI_SUCCESS;
|
||||
@@ -1471,7 +1477,6 @@ PxeBcDhcp4Discover (
|
||||
//
|
||||
// Set fields of the token for the request packet.
|
||||
//
|
||||
Xid = NET_RANDOM (NetRandomInitSeed ());
|
||||
Token.Packet->Dhcp4.Header.Xid = HTONL (Xid);
|
||||
Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16)((IsBCast) ? 0x8000 : 0x0));
|
||||
CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));
|
||||
|
@@ -2180,7 +2180,7 @@ PxeBcDhcp6Discover (
|
||||
UINTN ReadSize;
|
||||
UINT16 OpCode;
|
||||
UINT16 OpLen;
|
||||
UINT32 Xid;
|
||||
UINT32 Random;
|
||||
EFI_STATUS Status;
|
||||
UINTN DiscoverLenNeeded;
|
||||
|
||||
@@ -2198,6 +2198,12 @@ PxeBcDhcp6Discover (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
Status = PseudoRandomU32 (&Random);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
DiscoverLenNeeded = sizeof (EFI_PXE_BASE_CODE_DHCPV6_PACKET);
|
||||
Discover = AllocateZeroPool (DiscoverLenNeeded);
|
||||
if (Discover == NULL) {
|
||||
@@ -2207,8 +2213,7 @@ PxeBcDhcp6Discover (
|
||||
//
|
||||
// Build the discover packet by the cached request packet before.
|
||||
//
|
||||
Xid = NET_RANDOM (NetRandomInitSeed ());
|
||||
Discover->TransactionId = HTONL (Xid);
|
||||
Discover->TransactionId = HTONL (Random);
|
||||
Discover->MessageType = Request->Dhcp6.Header.MessageType;
|
||||
RequestOpt = Request->Dhcp6.Option;
|
||||
DiscoverOpt = Discover->DhcpOptions;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||
Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
@@ -892,6 +893,13 @@ PxeBcCreateIp6Children (
|
||||
PXEBC_PRIVATE_PROTOCOL *Id;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
UINTN Index;
|
||||
UINT32 Random;
|
||||
|
||||
Status = PseudoRandomU32 (&Random);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to generate random number using EFI_RNG_PROTOCOL: %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Private->Ip6Nic != NULL) {
|
||||
//
|
||||
@@ -935,9 +943,9 @@ PxeBcCreateIp6Children (
|
||||
}
|
||||
|
||||
//
|
||||
// Generate a random IAID for the Dhcp6 assigned address.
|
||||
// Set a random IAID for the Dhcp6 assigned address.
|
||||
//
|
||||
Private->IaId = NET_RANDOM (NetRandomInitSeed ());
|
||||
Private->IaId = Random;
|
||||
if (Private->Snp != NULL) {
|
||||
for (Index = 0; Index < Private->Snp->Mode->HwAddressSize; Index++) {
|
||||
Private->IaId |= (Private->Snp->Mode->CurrentAddress.Addr[Index] << ((Index << 3) & 31));
|
||||
|
Reference in New Issue
Block a user