aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2021-06-28 18:01:06 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2021-06-28 18:01:06 +0300
commita6c109fea5c13b8aa13ed95ca00a64d62601042b (patch)
treebd21103b535e3375e2e91aa789d1dd8aa0d13f4e /src/http/ngx_http_request.c
parent5f85bb3714a81d158f4d849ad5c61aec2737a9f0 (diff)
downloadnginx-a6c109fea5c13b8aa13ed95ca00a64d62601042b.tar.gz
nginx-a6c109fea5c13b8aa13ed95ca00a64d62601042b.zip
Disabled requests with both Content-Length and Transfer-Encoding.
HTTP clients are not allowed to generate such requests since Transfer-Encoding introduction in RFC 2068, and they are not expected to appear in practice except in attempts to perform a request smuggling attack. While handling of such requests is strictly defined, the most secure approach seems to reject them.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 5b2613870..2614b998c 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1985,8 +1985,15 @@ ngx_http_process_request_header(ngx_http_request_t *r)
&& ngx_strncasecmp(r->headers_in.transfer_encoding->value.data,
(u_char *) "chunked", 7) == 0)
{
- r->headers_in.content_length = NULL;
- r->headers_in.content_length_n = -1;
+ if (r->headers_in.content_length) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent \"Content-Length\" and "
+ "\"Transfer-Encoding\" headers "
+ "at the same time");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
r->headers_in.chunked = 1;
} else {