Description
The product receives data from an HTTP agent/component (e.g., web server, proxy, browser, etc.), but it does not neutralize or incorrectly neutralizes CR and LF characters before the data is included in outgoing HTTP headers.
HTTP agents or components may include a web server, load balancer, reverse proxy, web caching proxy, application firewall, web browser, etc. Regardless of the role, they are expected to maintain coherent, consistent HTTP communication state across all components. However, including unexpected data in an HTTP header allows an attacker to specify the entirety of the HTTP message that is rendered by the client HTTP agent (e.g., web browser) or back-end HTTP agent (e.g., web server), whether the message is part of a request or a response. When an HTTP request contains unexpected CR and LF characters, the server may respond with an output stream that is interpreted as "splitting" the stream into two different HTTP messages instead of one. CR is carriage return, also given by %0d or \r, and LF is line feed, also given by %0a or \n. In addition to CR and LF characters, other valid/RFC compliant special characters and unique character encodings can be utilized, such as HT (horizontal tab, also given by %09 or \t) and SP (space, also given as + sign or %20). These types of unvalidated and unexpected data in HTTP message headers allow an attacker to control the second "split" message to mount attacks such as server-side request forgery, cross-site scripting, and cache poisoning attacks. HTTP response splitting weaknesses may be present when:
Potential Impact
Integrity, Access Control
Modify Application Data, Gain Privileges or Assume Identity
Demonstrative Examples
String author = request.getParameter(AUTHOR_PARAM);...Cookie cookie = new Cookie("author", author);cookie.setMaxAge(cookieExpiration);response.addCookie(cookie);HTTP/1.1 200 OK...Set-Cookie: author=Jane Smith...Wiley Hacker\r\nHTTP/1.1 200 OK\r\nHTTP/1.1 200 OK...Set-Cookie: author=Wiley HackerHTTP/1.1 200 OK...Mitigations & Prevention
Construct HTTP headers very carefully, avoiding the use of non-validated input data.
Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. If an input does not strictly conform to specifications, reject it or transform it into something that conforms. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across r
Use and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified, a downstream component may choose a different encoding, either by assuming a default encoding or automatically inferring which encoding is being used, which can be erroneous. When the encodings are inconsistent, the downstream component might treat some character or byte sequences as special, even
Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
Detection Methods
- Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2020-15811 | Chain: Proxy uses a substring search instead of parsing the Transfer-Encoding header (CWE-697), allowing request splitting (CWE-113) and cache poisoning |
| CVE-2021-41084 | Scala-based HTTP interface allows request splitting and response splitting through header names, header values, status reasons, and URIs |
| CVE-2018-12116 | Javascript-based framework allows request splitting through a path option of an HTTP request |
| CVE-2004-2146 | Application accepts CRLF in an object ID, allowing HTTP response splitting. |
| CVE-2004-1656 | Shopping cart allows HTTP response splitting to perform HTML injection via CRLF in a parameter for a url |
| CVE-2005-2060 | Bulletin board allows response splitting via CRLF in parameter. |
| CVE-2004-2512 | Response splitting via CRLF in PHPSESSID. |
| CVE-2005-1951 | e-commerce app allows HTTP response splitting using CRLF in object id parameters |
Related Weaknesses
Taxonomy Mappings
- PLOVER: — HTTP response splitting
- 7 Pernicious Kingdoms: — HTTP Response Splitting
- WASC: 25 — HTTP Response Splitting
- Software Fault Patterns: SFP24 — Tainted input to command
Frequently Asked Questions
What is CWE-113?
CWE-113 (Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting')) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product receives data from an HTTP agent/component (e.g., web server, proxy, browser, etc.), but it does not neutralize or incorrectly neutralizes CR and LF characters before the data is included...
How can CWE-113 be exploited?
Attackers can exploit CWE-113 (Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting')) to modify application data, gain privileges or assume identity. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-113?
Key mitigations include: Construct HTTP headers very carefully, avoiding the use of non-validated input data.
What is the severity of CWE-113?
CWE-113 is classified as a Variant-level weakness (Low-Medium abstraction). It has been observed in 8 real-world CVEs.