Affects Version/s: 4.5.7
Fix Version/s: None
Component/s: HttpClient (classic)
Note: This vulnerability has already been reported using a private channel. Unfortunately, it was deemed as non-issue by maintainers. I'm posting it here for public visibility.
HttpClient in versions 4.5.7 and below is vulnerable to CRLF injection when adding or setting headers on an HTTP request. Attacker who can control the value of any header in a request created using HttpClient could exploit this vulnerability to add arbitrary headers and attack internal services, like a webserver, Redis, memcached, etc.
The current version of HttpClient does not properly filter unicode values, resulting in the sequence '\u560d\u560a' being converted to `\r\n` and causing unintended behavior. When the value (or part of the value) of any header set when constructing an HTTP request using HttpClient is controlled by an attacker, it allows them to insert arbitrary content to the new line of the HTTP header.
Proof of concept
Consider this piece of code, where variable "attackerControlledValue" simulates an attacker-controlled input.
We set up a netcat listener on port 8080 and run this code:
We can see in the netcat output that the header "X-But-Not-This-One" is present in the request, which means the injection succeeded.
- By adding arbitrary HTTP headers it's possible to bypass authentication of some simple web services
- Several simple services that communicate over HTTP (Redis, memcached) can be exploited by injecting valid commands
Here are some related CRLF injection vulnerabilities in other software:
- CVE-2016-5699 in Python’s stdlib https://nvd.nist.gov/vuln/detail/CVE-2016-5699
- CVE-2017-6508 in wget https://nvd.nist.gov/vuln/detail/CVE-2017-6508
- CVE-2016-4993 in Undertow web server https://nvd.nist.gov/vuln/detail/CVE-2016-4993
- CVE-2019-9740 in Python's stdlib again https://nvd.nist.gov/vuln/detail/CVE-2019-9740