Reference articles on history, science, culture and more
Encyclopedia

HTTP response splitting

Class of internet software vulnerability

Image credit is listed at the end of this article.

HTTP response splitting is a form of web application vulnerability, resulting from the failure of the application or its environment to properly sanitize input values. It can be used to perform cross-site scripting attacks, cross-user defacement, web cache poisoning, and similar exploits.

The attack consists of making the server print a carriage return (CR, ASCII 0x0D) line feed (LF, ASCII 0x0A) sequence followed by content supplied by the attacker in the header section of its response, typically by including them in input fields sent to the application. Per the HTTP standard (RFC 2616), headers are separated by one CRLF and the response's headers are separated from its body by two. Therefore, the failure to remove CRs and LFs allows the attacker to set arbitrary headers, take control of the body, or break the response into two or more separate responses, hence the name.

01Prevention

The generic solution is to URL-encode strings before inclusion into HTTP headers such as Location or Set-Cookie.

Typical examples of sanitization include casting to integers or aggressive regular expression replacement. Most modern server-side scripting languages and runtimes, like PHP since version 5.1.2 and Node.js since 4.6.0 (previous versions supported it, but the protection could've been bypassed, which was discovered in 2016) as well as Web frameworks, such as Django since version 1.8.4 support sanitization of HTTP responses against this type of vulnerability.

Watch videos about HTTP response splittingExplainers and documentaries on YouTube (opens in a new tab)

Sources and credits

This article is adapted from the Wikipedia article HTTP response splitting, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.

Images, from Wikimedia Commons:

  • HTTP logo.svg by IETF HTTP Working Group (HTTPbis), Public domain

Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.