﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
831	Possible incorrect handling of invalid headers with HTTP/2.0 and POST/PUT requests	Brian Stanback		"When an invalid header is encountered, it appears that all subsequent headers are also marked as invalid (whether they are or not).  I specifically noticed this happen when doing POST requests (GET requests appeared to be unaffected). Additionally, the issue does not show up with SPDY 3.1 or HTTP/1.x.

I was testing an http2 rollout with nginx v1.9.6 and noticed that when users had a particular extension enabled in Chrome (Alexa Traffic Rank), it would append a custom header containing illegal characters. Rather than ignore the individual header, nginx was stripping out valid headers including the POST body.

When setting error_log to debug, Nginx was logging the request as follows:

{{{
nginx.1    | 2015/11/11 21:45:40 [info] 21#21: *175 client sent invalid header: ""alexatoolbar-alx_ns_ph"" while processing HTTP/2 connection, client: 10.9.1.21, server: _, host: ""_""
nginx.1    | *175 client sent invalid header: ""cookie"" while processing HTTP/2 connection, client: 10.9.1.21, server: _, host: ""_""
nginx.1    | 2015/11/11 21:45:40 [info] 21#21: *175 client sent invalid header: ""x-requested-with"" while processing HTTP/2 connection, client: 10.9.1.21, server: _, host: ""_""
nginx.1    | 2015/11/11 21:45:40 [warn] 21#21: *175 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000001, client: 10.9.1.21, server: _, request: ""POST /api HTTP/2.0"", host: ""_""
}}}

An interesting side-effect - for some reason, It seems that when an invalid header is encountered, Nginx reports ""a client request body is buffered to a temporary file"" regardless of how large I set the buffer in client_body_buffer_size.)

I was able to avoid this behavior by adding the following configuration directive:

{{{
ignore_invalid_headers off;
}}}"	defect	closed	major		nginx-core	1.9.x	fixed	http2		Linux fc5d36d05eda 3.19.0-32-generic #37-Ubuntu SMP Wed Oct 21 10:23:06 UTC 2015 x86_64 Linux	"nginx version: nginx/1.9.6
built by gcc 5.2.0 (Alpine 5.2.0)
built with OpenSSL 1.0.2d 9 Jul 2015
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv6"
