-
Notifications
You must be signed in to change notification settings - Fork 9
Added harness to cover CVE-2023-45229: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dandurisrihari
wants to merge
4
commits into
intel:main
Choose a base branch
from
dandurisrihari:CVE-2023-45229_harness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b93fe43
Added harness to cover
dandurisrihari 9cffc62
Updated with correct seed to trigger
dandurisrihari e332eed
updated the test harness with patch fix code form edk2 and added more…
dandurisrihari b081535
Merge branch 'intel:main' into CVE-2023-45229_harness
dandurisrihari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/Dhcp6SeekStsOption_45.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
...HostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/Dhcp6SeekStsOption_previous_cve_fix_crash.bin
Binary file not shown.
1 change: 1 addition & 0 deletions
1
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/random_45bytes.bin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ��J������j�o[���ߵ�KmU@(j�k�ˍ���� |
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_01_minimal.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_02_valid_ia.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_03_ia_ta.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_04_status_code.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_05_nested.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_06_multi_opt.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_07_all_ff.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_08_zero_len.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_09_iaaddr.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/seed_10_error_code.bin
Binary file not shown.
Binary file added
BIN
+45 Bytes
HBFA/UefiHostFuzzTestCasePkg/Seed/Dhcp6SeekStsOption/zeros_45bytes.bin
Binary file not shown.
125 changes: 125 additions & 0 deletions
125
...fiHostFuzzTestCasePkg/TestCase/NetworkPkg/TestDhcp6SeekStsOption/TestDhcp6SeekStsOption.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| /** @file | ||
|
|
||
|
|
||
| **/ | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <assert.h> | ||
|
|
||
| #include <Uefi.h> | ||
|
|
||
| #include <Library/BaseLib.h> | ||
| #include <Library/DebugLib.h> | ||
| #include <Library/BaseMemoryLib.h> | ||
| #include <Library/MemoryAllocationLib.h> | ||
| #include <Library/Dhcp6SeekStsOptionStubLib.h> | ||
|
|
||
| #define DHCPV6_PACKED_OPTION_DATA 24 | ||
|
|
||
|
|
||
| VOID | ||
| FixBuffer ( | ||
| UINT8 *TestBuffer | ||
| ) | ||
| { | ||
| } | ||
|
|
||
| UINTN | ||
| EFIAPI | ||
| GetMaxBufferSize ( | ||
| VOID | ||
| ) | ||
| { | ||
| return ( | ||
| sizeof(EFI_DHCP6_IA_DESCRIPTOR) // IaDescriptor | ||
| + sizeof(EFI_DHCP6_HEADER) // DHCP6 Header | ||
| + DHCPV6_PACKED_OPTION_DATA // Max Length of DHCPv6 packed option data | ||
| ); | ||
| } | ||
|
|
||
| VOID | ||
| EFIAPI | ||
| RunTestHarness( | ||
| IN VOID *TestBuffer, | ||
| IN UINTN TestBufferSize | ||
| ) | ||
| { | ||
| DHCP6_INSTANCE *Instance; | ||
| EFI_DHCP6_PACKET *Packet; | ||
| UINT8 **Option; | ||
|
|
||
| Instance = (DHCP6_INSTANCE *)AllocateZeroPool (sizeof (DHCP6_INSTANCE)); | ||
| if (!Instance) { | ||
| printf("Allocation failed!\n"); | ||
| return; | ||
| } | ||
| Packet = (EFI_DHCP6_PACKET *)AllocateZeroPool (sizeof (EFI_DHCP6_PACKET) + DHCPV6_PACKED_OPTION_DATA); | ||
| if (!Packet) { | ||
| printf("Allocation failed!\n"); | ||
| FreePool(Instance); | ||
| return; | ||
| } | ||
| Option = (UINT8 **)AllocateZeroPool (sizeof (UINT8 *)); | ||
| if (!Option) { | ||
| printf("Allocation failed!\n"); | ||
| FreePool(Packet); | ||
| FreePool(Instance); | ||
| return; | ||
| } | ||
| Instance->Config = (EFI_DHCP6_CONFIG_DATA *)AllocateZeroPool (sizeof (EFI_DHCP6_CONFIG_DATA)); | ||
| if (!Instance->Config) { | ||
| printf("Allocation failed!\n"); | ||
| FreePool(Option); | ||
| FreePool(Packet); | ||
| FreePool(Instance); | ||
| return; | ||
| } | ||
|
|
||
| // Packet and IaDescriptor are fed from TestBuffer | ||
| // IaDescriptor is 8 bytes (sizeof(EFI_DHCP6_IA_DESCRIPTOR)) | ||
| // Dhcp6 Header + Options is sizeof(EFI_DHCP6_HEADER) + DHCPV6_PACKED_OPTION_DATA bytes | ||
| // Total minimum TestBufferSize = 8 + sizeof(EFI_DHCP6_HEADER) + 24 bytes | ||
|
|
||
| if (TestBufferSize < (sizeof(EFI_DHCP6_IA_DESCRIPTOR) + sizeof(EFI_DHCP6_HEADER) + DHCPV6_PACKED_OPTION_DATA)) { | ||
| printf("TestBufferSize is too small!\n"); | ||
| FreePool(Instance->Config); | ||
| FreePool(Option); | ||
| FreePool(Packet); | ||
| FreePool(Instance); | ||
| return; | ||
| } | ||
|
|
||
| // 1. Initialize Instance->Config->IaDescriptor, Packet options buffer from TestBuffer | ||
| EFI_STATUS Status = InitializeDhcp6SeekStsOption(&Instance->Config->IaDescriptor, (EFI_DHCP6_HEADER *)&Packet->Dhcp6, DHCPV6_PACKED_OPTION_DATA, TestBuffer, TestBufferSize); | ||
|
|
||
| // Initialize packed option data buffer length | ||
|
|
||
| // Size of the EFI_DHCP6_PACKET buffer. | ||
| Packet->Size = sizeof (EFI_DHCP6_PACKET) + DHCPV6_PACKED_OPTION_DATA; | ||
|
|
||
| // Length of the EFI_DHCP6_PACKET from the first byte of the Header field | ||
| // to the last byte of the Option[] field. | ||
| Packet->Length = sizeof(EFI_DHCP6_HEADER) + DHCPV6_PACKED_OPTION_DATA; | ||
|
|
||
|
|
||
| if (EFI_ERROR (Status)) { | ||
| FreePool(Instance->Config); | ||
| FreePool(Option); | ||
| FreePool(Packet); | ||
| FreePool(Instance); | ||
| return; | ||
| } | ||
|
|
||
| // 2. Call the function under test | ||
| Dhcp6SeekStsOption( Instance, Packet, Option); | ||
|
|
||
| // 3. Clean up allocated resources | ||
| FreePool(Instance->Config); | ||
| FreePool(Option); | ||
| FreePool(Packet); | ||
| FreePool(Instance); | ||
|
|
||
| return; | ||
| } |
54 changes: 54 additions & 0 deletions
54
...HostFuzzTestCasePkg/TestCase/NetworkPkg/TestDhcp6SeekStsOption/TestDhcp6SeekStsOption.inf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ## @file | ||
| # Client-side DHCPv6 services. | ||
| # | ||
| # This driver produces EFI DHCPv6 Protocol which is used to get IPv6 addresses | ||
| # and other configuration parameters from DHCPv6 servers. | ||
| # | ||
| # (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> | ||
| # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> | ||
| # | ||
| # SPDX-License-Identifier: BSD-2-Clause-Patent | ||
| # | ||
| ## | ||
|
|
||
| [Defines] | ||
| INF_VERSION = 0x00010005 | ||
| BASE_NAME = TestDhcp6SeekStsOption | ||
| FILE_GUID = 95E3669D-34BE-4775-A651-7EA41B69D89E | ||
| MODULE_TYPE = USER_DEFINED | ||
| VERSION_STRING = 1.0 | ||
| ENTRY_POINT = Dhcp6DriverEntryPoint | ||
|
|
||
| # | ||
| # The following information is for reference only and not required by the build tools. | ||
| # | ||
| # VALID_ARCHITECTURES = IA32 X64 EBC | ||
| # | ||
| # DRIVER_BINDING = gDhcp6DriverBinding | ||
| # COMPONENT_NAME = gDhcp6ComponentName | ||
| # COMPONENT_NAME2 = gDhcp6ComponentName2 | ||
| # | ||
|
|
||
| [Sources] | ||
| TestDhcp6SeekStsOption.c | ||
|
|
||
| [Packages] | ||
| MdePkg/MdePkg.dec | ||
| MdeModulePkg/MdeModulePkg.dec | ||
| NetworkPkg/NetworkPkg.dec | ||
| UefiHostTestPkg/UefiHostTestPkg.dec | ||
| UefiHostFuzzTestCasePkg/UefiHostFuzzTestCasePkg.dec | ||
|
|
||
| [LibraryClasses] | ||
| UefiLib | ||
| BaseLib | ||
| BaseMemoryLib | ||
| MemoryAllocationLib | ||
| UefiDriverEntryPoint | ||
| UefiBootServicesTableLib | ||
| UefiRuntimeServicesTableLib | ||
| DebugLib | ||
| NetLib | ||
| UdpIoLib | ||
| Dhcp6SeekStsOptionStubLib | ||
| ToolChainHarnessLib |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you verify the source for these files (e.g. was this source from the EDKII repository)?