Skip to content

Commit

Permalink
Disabled HTTP/1.0 requests with Transfer-Encoding.
Browse files Browse the repository at this point in the history
The latest HTTP/1.1 draft describes Transfer-Encoding in HTTP/1.0 as having
potentially faulty message framing as that could have been forwarded without
handling of the chunked encoding, and forbids processing subsequest requests
over that connection: httpwg/http-core#879.

While handling of such requests is permitted, the most secure approach seems
to reject them.
  • Loading branch information
pluknet committed Aug 9, 2021
1 parent 02bd43d commit 7bcb50c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/http/ngx_http_request.c
Expand Up @@ -1983,6 +1983,14 @@ ngx_http_process_request_header(ngx_http_request_t *r)
}

if (r->headers_in.transfer_encoding) {
if (r->http_version < NGX_HTTP_VERSION_11) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
"client sent HTTP/1.0 request with "
"\"Transfer-Encoding\" header");
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
return NGX_ERROR;
}

if (r->headers_in.transfer_encoding->value.len == 7
&& ngx_strncasecmp(r->headers_in.transfer_encoding->value.data,
(u_char *) "chunked", 7) == 0)
Expand Down

0 comments on commit 7bcb50c

Please sign in to comment.