Index: CHANGES =================================================================== --- CHANGES (revision 1757402) +++ CHANGES (working copy) @@ -4,3 +4,6 @@ *) core: CVE-2016-5387: Mitigate [f]cgi "httpoxy" issues. [Dominic Scheirlinck , Yann Ylavic] + *) core: Limit to ten the number of tolerated empty lines between request. + [Yann Ylavic] + Index: include/httpd.h =================================================================== --- include/httpd.h (revision 1757402) +++ include/httpd.h (working copy) @@ -205,6 +205,10 @@ #ifndef DEFAULT_LIMIT_REQUEST_FIELDS #define DEFAULT_LIMIT_REQUEST_FIELDS 100 #endif +/** default/hard limit on number of leading/trailing empty lines */ +#ifndef DEFAULT_LIMIT_BLANK_LINES +#define DEFAULT_LIMIT_BLANK_LINES 10 +#endif /** * The default default character set name to add if AddDefaultCharset is --- server/protocol.c.applied-r1392347-1635762 2016-08-23 10:39:57.086305825 -0500 +++ server/protocol.c 2016-08-23 11:49:41.335217096 -0500 @@ -563,12 +563,7 @@ unsigned int major = 1, minor = 0; /* Assume HTTP/1.0 if non-"HTTP" protocol */ char http[5]; apr_size_t len; - int num_blank_lines = 0; - int max_blank_lines = r->server->limit_req_fields; - - if (max_blank_lines <= 0) { - max_blank_lines = DEFAULT_LIMIT_REQUEST_FIELDS; - } + int num_blank_lines = DEFAULT_LIMIT_BLANK_LINES; /* Read past empty lines until we get a real request line, * a read error, the connection closes (EOF), or we timeout. @@ -615,7 +610,7 @@ r->protocol = apr_pstrdup(r->pool, "HTTP/1.0"); return 0; } - } while ((len <= 0) && (++num_blank_lines < max_blank_lines)); + } while ((len <= 0) && (--num_blank_lines >= 0)); #ifdef AP_DEBUG_THE_REQUEST ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, @@ -629,6 +624,13 @@ uri = ap_getword_white(r->pool, &ll); + if (!*r->method || !*uri) { + r->status = HTTP_BAD_REQUEST; + r->proto_num = HTTP_VERSION(1,0); + r->protocol = apr_pstrdup(r->pool, "HTTP/1.0"); + return 0; + } + /* Provide quick information about the request method as soon as known */ r->method_number = ap_method_number_of(r->method); @@ -637,6 +639,11 @@ } ap_parse_uri(r, uri); + if (r->status != HTTP_OK) { + r->proto_num = HTTP_VERSION(1,0); + r->protocol = apr_pstrdup(r->pool, "HTTP/1.0"); + return 0; + } if (ll[0]) { r->assbackwards = 0;