Welcome! Log In Create A New Profile

Advanced

[nginx] Disabled duplicate "Host" headers (ticket #1724).

Maxim Dounin
February 20, 2020 10:56AM
details: https://hg.nginx.org/nginx/rev/4f18393a1d51
branches:
changeset: 7627:4f18393a1d51
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Feb 20 16:51:07 2020 +0300
description:
Disabled duplicate "Host" headers (ticket #1724).

Duplicate "Host" headers were allowed in nginx 0.7.0 (revision b9de93d804ea)
as a workaround for some broken Motorola phones which used to generate
requests with two "Host" headers[1]. It is believed that this workaround
is no longer relevant.

[1] http://mailman.nginx.org/pipermail/nginx-ru/2008-May/017845.html

diffstat:

src/http/ngx_http_request.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)

diffs (24 lines):

diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1755,10 +1755,18 @@ ngx_http_process_host(ngx_http_request_t
ngx_int_t rc;
ngx_str_t host;

- if (r->headers_in.host == NULL) {
- r->headers_in.host = h;
+ if (r->headers_in.host) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent duplicate host header: \"%V: %V\", "
+ "previous value: \"%V: %V\"",
+ &h->key, &h->value, &r->headers_in.host->key,
+ &r->headers_in.host->value);
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
}

+ r->headers_in.host = h;
+
host = h->value;

rc = ngx_http_validate_host(&host, r->pool, 0);
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Disabled duplicate "Host" headers (ticket #1724).

Maxim Dounin 130 February 20, 2020 10:56AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 94
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready