Skip to content

Commit f31453e

Browse files
Doug Flick via groups.iomergify[bot]
Doug Flick via groups.io
authored andcommitted
NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Patch
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4535 Bug Details: PixieFail Bug #2 CVE-2023-45230 CVSS 8.3 : CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:H CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer Changes Overview: > -UINT8 * > +EFI_STATUS > Dhcp6AppendOption ( > - IN OUT UINT8 *Buf, > - IN UINT16 OptType, > - IN UINT16 OptLen, > - IN UINT8 *Data > + IN OUT EFI_DHCP6_PACKET *Packet, > + IN OUT UINT8 **PacketCursor, > + IN UINT16 OptType, > + IN UINT16 OptLen, > + IN UINT8 *Data > ); Dhcp6AppendOption() and variants can return errors now. All callsites are adapted accordingly. It gets passed in EFI_DHCP6_PACKET as additional parameter ... > + // > + // Verify the PacketCursor is within the packet > + // > + if ( (*PacketCursor < Packet->Dhcp6.Option) > + || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) > + { > + return EFI_INVALID_PARAMETER; > + } ... so it can look at Packet->Size when checking buffer space. Also to allow Packet->Length updates. Lots of checks added. Cc: Saloni Kasbekar <[email protected]> Cc: Zachary Clark-williams <[email protected]> Signed-off-by: Doug Flick [MSFT] <[email protected]> Reviewed-by: Saloni Kasbekar <[email protected]>
1 parent 959f71c commit f31453e

File tree

4 files changed

+668
-239
lines changed

4 files changed

+668
-239
lines changed

NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h

+43
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,49 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE;
4545
#define DHCP6_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'S')
4646
#define DHCP6_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'I')
4747

48+
//
49+
// For more information on DHCP options see RFC 8415, Section 21.1
50+
//
51+
// The format of DHCP options is:
52+
//
53+
// 0 1 2 3
54+
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
55+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56+
// | option-code | option-len |
57+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58+
// | option-data |
59+
// | (option-len octets) |
60+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61+
//
62+
#define DHCP6_SIZE_OF_OPT_CODE (sizeof(UINT16))
63+
#define DHCP6_SIZE_OF_OPT_LEN (sizeof(UINT16))
64+
65+
//
66+
// Combined size of Code and Length
67+
//
68+
#define DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN (DHCP6_SIZE_OF_OPT_CODE + \
69+
DHCP6_SIZE_OF_OPT_LEN)
70+
71+
STATIC_ASSERT (
72+
DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN == 4,
73+
"Combined size of Code and Length must be 4 per RFC 8415"
74+
);
75+
76+
//
77+
// Offset to the length is just past the code
78+
//
79+
#define DHCP6_OPT_LEN_OFFSET(a) (a + DHCP6_SIZE_OF_OPT_CODE)
80+
STATIC_ASSERT (
81+
DHCP6_OPT_LEN_OFFSET (0) == 2,
82+
"Offset of length is + 2 past start of option"
83+
);
84+
85+
#define DHCP6_OPT_DATA_OFFSET(a) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN)
86+
STATIC_ASSERT (
87+
DHCP6_OPT_DATA_OFFSET (0) == 4,
88+
"Offset to option data should be +4 from start of option"
89+
);
90+
4891
#define DHCP6_PACKET_ALL 0
4992
#define DHCP6_PACKET_STATEFUL 1
5093
#define DHCP6_PACKET_STATELESS 2

0 commit comments

Comments
 (0)