CWE-113 HTTP头部中CRLF序列转义处理不恰当(HTTP响应分割)

Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')

结构: Simple

Abstraction: Base

状态: Incomplete

被利用可能性: unkown


The software receives data from an upstream component, but does not neutralize or incorrectly neutralizes CR and LF characters before the data is included in outgoing HTTP headers.


Including unvalidated data in an HTTP header allows an attacker to specify the entirety of the HTTP response rendered by the browser. When an HTTP request contains unexpected CR (carriage return, also given by %0d or \r) and LF (line feed, also given by %0a or \n) characters the server may respond with an output stream that is interpreted as two different HTTP responses (instead of one). An attacker can control the second response and mount attacks such as cross-site scripting and cache poisoning attacks.

HTTP response splitting weaknesses may be present when:


  • cwe_Nature: ChildOf cwe_CWE_ID: 93 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: CanPrecede cwe_CWE_ID: 79 cwe_View_ID: 1000

  • cwe_Nature: ChildOf cwe_CWE_ID: 20 cwe_View_ID: 700 cwe_Ordinal: Primary


Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}


范围 影响 注释
['Integrity', 'Access Control'] ['Modify Application Data', 'Gain Privileges or Assume Identity'] CR and LF characters in an HTTP header may give attackers control of the remaining headers and body of the response the application intends to send, as well as allowing them to create additional responses entirely under their control.



策略: Input Validation

Construct HTTP headers very carefully, avoiding the use of non-validated input data.

MIT-5 Implementation

策略: Input Validation

Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a whitelist of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. 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 related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs (i.e., do not rely on a blacklist). A blacklist is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, blacklists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.

MIT-30 Implementation

策略: Output Encoding

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 if they are not special in the original encoding. Attackers might then be able to exploit this discrepancy and conduct injection attacks; they even might be able to bypass protection mechanisms that assume the original encoding is also being used by the downstream component.

MIT-20 Implementation

策略: Input Validation

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 whitelist validation schemes by introducing dangerous inputs after they have been checked.


The following code segment reads the name of the author of a weblog entry, author, from an HTTP request and sets it in a cookie header of an HTTP response.

bad Java

String author = request.getParameter(AUTHOR_PARAM);
Cookie cookie = new Cookie("author", author);

Assuming a string consisting of standard alpha-numeric characters, such as "Jane Smith", is submitted in the request the HTTP response including this cookie might take the following form:


HTTP/1.1 200 OK
Set-Cookie: author=Jane Smith

However, because the value of the cookie is formed of unvalidated user input the response will only maintain this form if the value submitted for AUTHOR_PARAM does not contain any CR and LF characters. If an attacker submits a malicious string, such as


Wiley Hacker\r\nHTTP/1.1 200 OK\r\n

then the HTTP response would be split into two responses of the following form:


HTTP/1.1 200 OK
Set-Cookie: author=Wiley Hacker HTTP/1.1 200 OK

Clearly, the second response is completely controlled by the attacker and can be constructed with any header and body content desired. The ability of attacker to construct arbitrary HTTP responses permits a variety of resulting attacks, including:


An attacker can make a single request to a vulnerable server that will cause the server to create two responses, the second of which may be misinterpreted as a response to a different request, possibly one made by another user sharing the same TCP connection with the sever.


The impact of a maliciously constructed response can be magnified if it is cached either by a web cache used by multiple users or even the browser cache of a single user.


Once attackers have control of the responses sent by an application, they have a choice of a variety of malicious content to provide users.


In addition to using a vulnerable application to send malicious content to a user, the same root vulnerability can also be leveraged to redirect sensitive content generated by the server and intended for the user to the attacker instead.



标识 说明 链接
CVE-2004-2146 Application accepts CRLF in an object ID, allowing HTTP response splitting.
CVE-2004-1620 HTTP response splitting via CRLF in parameter related to URL.
CVE-2004-1656 HTTP response splitting via CRLF in parameter related to URL.
CVE-2005-2060 Bulletin board allows response splitting via CRLF in parameter.
CVE-2005-2065 Bulletin board allows response splitting via CRLF in parameter.
CVE-2004-2512 Response splitting via CRLF in PHPSESSID.
CVE-2005-1951 Chain: Application accepts CRLF in an object ID, allowing HTTP response splitting.
CVE-2004-1687 Chain: HTTP response splitting via CRLF in parameter related to URL.



映射的分类名 ImNode ID Fit Mapped Node Name
PLOVER HTTP response splitting
7 Pernicious Kingdoms HTTP Response Splitting
WASC 25 HTTP Response Splitting
Software Fault Patterns SFP24 Tainted input to command


  • CAPEC-31
  • CAPEC-34
  • CAPEC-85