Skip to content

Commit

Permalink
CVE-2023-40547 - avoid incorrectly trusting HTTP headers
Browse files Browse the repository at this point in the history
When retrieving files via HTTP or related protocols, shim attempts to
allocate a buffer to store the received data.  Unfortunately, this means
getting the size from an HTTP header, which can be manipulated to
specify a size that's smaller than the received data.  In this case, the
code accidentally uses the header for the allocation but the protocol
metadata to copy it from the rx buffer, resulting in an out-of-bounds
write.

This patch adds an additional check to test that the rx buffer is not
larger than the allocation.

Resolves: CVE-2023-40547
Reported-by: Bill Demirkapi, Microsoft Security Response Center
Signed-off-by: Peter Jones <pjones@redhat.com>
  • Loading branch information
vathpela committed Dec 5, 2023
1 parent e801b0d commit 0226b56
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion httpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,13 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINT64 *buf_size)
}

if (*buf_size == 0) {
perror(L"Failed to get Content-Lenght\n");
perror(L"Failed to get Content-Length\n");
goto error;
}

if (*buf_size < rx_message.BodyLength) {
efi_status = EFI_BAD_BUFFER_SIZE;
perror(L"Invalid Content-Length\n");
goto error;
}

Expand Down

3 comments on commit 0226b56

@tail-call
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello hacker news

@arvidjohansen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terry

@Mr-P-D
Copy link

@Mr-P-D Mr-P-D commented on 0226b56 Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont understand why NVD gave it a 9.8 CVSS score when the attack vector is MITM ?

Please sign in to comment.