Opened 5 years ago

Closed 4 years ago

#1752 closed defect (wontfix)

400 Bad Request when Content-Length header value starts with HT

Reported by: mstavrev@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.15.x
Keywords: HT used on Content-Length header value Cc:
uname -a: Linux docker-linux 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.15.9
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --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-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

Description

When client send HTTP request with a header of Content-Length that starts with horizontal tab character (HT=0x09), Ngins responds with HTTP 400 Bad Request.

According to HTTP RFC (https://tools.ietf.org/html/rfc2616#section-4.2):

"... The field value MAY be preceded by any amount of LWS, though a single SP is preferred."

LWS is defined as:

LWS = [CRLF] 1*( SP | HT )

So, it looks like a header such as:

Content-Type:<0x09>110\r\n

should not be treated as an error.

Change History (2)

comment:1 by mstavrev@…, 4 years ago

I cannot edit the description, where I've wrongly quoted "Content-Type" on the example instead of "Content-Length".

I've filed a PR (https://github.com/nginx/nginx/pull/48) that fixes the problem.

comment:2 by Maxim Dounin, 4 years ago

Resolution: wontfix
Status: newclosed

See the following mailing list messages:

http://mailman.nginx.org/pipermail/nginx-devel/2020-January/012940.html
http://mailman.nginx.org/pipermail/nginx-devel/2020-February/012993.html

As of now, we would prefer to keep parsing strict. We might consider adding HTAB support if more interoperability problems will be reported.

Note: See TracTickets for help on using tickets.