Skip to content
Snippets Groups Projects
Commit 870b9475 authored by Daniel Axtens's avatar Daniel Axtens Committed by Julian Andres Klode
Browse files

net/http: Error out on headers with LF without CR


In a similar vein to the previous patch, parse_line() would write
a NUL byte past the end of the buffer if there was an HTTP header
with a LF rather than a CRLF.

RFC-2616 says:

  Many HTTP/1.1 header field values consist of words separated by LWS
  or special characters. These special characters MUST be in a quoted
  string to be used within a parameter value (as defined in section 3.6).

We don't support quoted sections or continuation lines, etc.

If we see an LF that's not part of a CRLF, bail out.

Fixes: CVE-2022-28734

Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
parent f407a45b
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,15 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)
char *end = ptr + len;
while (end > ptr && *(end - 1) == '\r')
end--;
/* LF without CR. */
if (end == ptr + len)
{
data->errmsg = grub_strdup (_("invalid HTTP header - LF without CR"));
return GRUB_ERR_NONE;
}
*end = 0;
/* Trailing CRLF. */
if (data->in_chunk_len == 1)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment