Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have Apache Accept LF vs CRLF in Request Headers

I have a legacy product that I'm trying to support on an Apache server and the server only after a recent update began rejecting request headers which only used LF for newlines and it's a tall order to rebuild it because of how old the code base is. Is there a setting somewhere that can be used or a mod_rewrite command that can be leveraged to allow request headers which use LF instead of CRLF or that will re-write LF's as CRLF's in request headers?

Example header from app:

Host: www.ourhostname.com:80\n
Accept-language: en\n
user_agent: Our Old Application\n
\n

If I hex edit the file to change the \n to \r\n, it works, but hex editing a file for release as an update isn't desired and I'm trying to find something server-side to get Apache to stop choking on LF's by themselves. Thanks in advance for any help on this problem!

like image 676
Nuvious Avatar asked Apr 23 '17 17:04

Nuvious


People also ask

What new line sequence is valid for HTTP headers?

The line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR.

Does http use carriage return?

Format of an HTTP RequestAn HTTP request contains a series of lines that each end with a carriage return and a line feed, represented as either <CR><LF> or \r\n .

What is carriage return in HTTP request?

CR = Carriage Return ( \r , 0x0D in hexadecimal, 13 in decimal) — moves the cursor to the beginning of the line without advancing to the next line. LF = Line Feed ( \n , 0x0A in hexadecimal, 10 in decimal) — moves the cursor down to the next line without returning to the beginning of the line.

What are headers in HTTP requests?

An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate it's preferred media formats, while a response can use header to indicate the media format of the returned body.


1 Answers

we had the same problem and found Apache's fixed vulnerability:

important: Apache HTTP Request Parsing Whitespace Defects CVE-2016-8743 https://httpd.apache.org/security/vulnerabilities_24.html

These defects are addressed with the release of Apache HTTP Server 2.4.25 and coordinated by a new directive;

HttpProtocolOptions Strict

which is the default behavior of 2.4.25 and later. By toggling from 'Strict' behavior to 'Unsafe' behavior, some of the restrictions may be relaxed to allow some invalid HTTP/1.1 clients to communicate with the server, but this will reintroduce the possibility of the problems described in this assessment. Note that relaxing the behavior to 'Unsafe' will still not permit raw CTLs other than HTAB (where permitted), but will allow other RFC requirements to not be enforced, such as exactly two SP characters in the request line.

So, HttpProtocolOptions Unsafe directive may be your solution. We decided not to use it.

like image 190
KOLRH Avatar answered Oct 26 '22 23:10

KOLRH