]> git.ipfire.org Git - thirdparty/apache/httpd.git/commit
Add an option to enforce stricter HTTP conformance
authorWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 4 Nov 2016 14:20:16 +0000 (14:20 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 4 Nov 2016 14:20:16 +0000 (14:20 +0000)
commite514eb999b0e78e1e5ee7e15db2d1eaf62afe5dd
treeb2e8aa35ff7865c0874507c356c8841e10ccab9b
parentfb3f938dd04df3d5893ccf77360af0fd28e74efc
Add an option to enforce stricter HTTP conformance

This is a first stab, the checks will likely have to be revised.
For now, we check

 * if the request line contains control characters
 * if the request uri has fragment or username/password
 * that the request method is standard or registered with RegisterHttpMethod
 * that the request protocol is of the form HTTP/[1-9]+.[0-9]+,
   or missing for 0.9
 * if there is garbage in the request line after the protocol
 * if any request header contains control characters
 * if any request header has an empty name
 * for the host name in the URL or Host header:
   - if an IPv4 dotted decimal address: Reject octal or hex values, require
     exactly four parts
   - if a DNS host name: Reject non-alphanumeric characters besides '.' and
     '-'. As a side effect, this rejects multiple Host headers.
 * if any response header contains control characters
 * if any response header has an empty name
 * that the Location response header (if present) has a valid scheme and is
   absolute

If we have a host name both from the URL and the Host header, we replace the
Host header with the value from the URL to enforce RFC conformance.

There is a log-only mode, but the loglevels of the logged messages need some
thought/work. Currently, the  checks for incoming data log for 'core' and the
checks for outgoing data log for 'http'. Maybe we need a way to configure the
loglevels separately from the core/http loglevels.

change protocol number parsing in strict mode according to HTTPbis draft
- only accept single digit version components
- don't accept white-space after protocol specification

Clean up comment, fix log tags.
Submitted by: sf
Backports: r1426877, r1426879, r1426988, r1426992

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x-merge-http-strict@1768036 13f79535-47bb-0310-9956-ffa450edef68
CHANGES
include/ap_mmn.h
include/http_core.h
include/httpd.h
modules/http/http_filters.c
server/core.c
server/protocol.c
server/util.c
server/vhost.c