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

admin 2022年1月7日02:51:38CWE(弱点枚举)评论15 views6640字阅读22分8秒阅读模式

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.

可能的缓解方案

Implementation

策略: 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);
cookie.setMaxAge(cookieExpiration);
response.addCookie(cookie);

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:

result

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

attack

Wiley HackerrnHTTP/1.1 200 OKrn

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

result

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:

None

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.

None

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.

None

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

None

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.

None

分析过的案例

标识 说明 链接
CVE-2004-2146 Application accepts CRLF in an object ID, allowing HTTP response splitting. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-2146
CVE-2004-1620 HTTP response splitting via CRLF in parameter related to URL. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-1620
CVE-2004-1656 HTTP response splitting via CRLF in parameter related to URL. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-1656
CVE-2005-2060 Bulletin board allows response splitting via CRLF in parameter. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-2060
CVE-2005-2065 Bulletin board allows response splitting via CRLF in parameter. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-2065
CVE-2004-2512 Response splitting via CRLF in PHPSESSID. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-2512
CVE-2005-1951 Chain: Application accepts CRLF in an object ID, allowing HTTP response splitting. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-1951
CVE-2004-1687 Chain: HTTP response splitting via CRLF in parameter related to URL. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-1687

Notes

分类映射

映射的分类名 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

引用

文章来源于互联网:scap中文网

特别标注: 本站(CN-SEC.COM)所有文章仅供技术研究,若将其信息做其他用途,由用户承担全部法律及连带责任,本站不承担任何法律及连带责任,请遵守中华人民共和国安全法.
  • 我的微信
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月7日02:51:38
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                  CWE-113 HTTP头部中CRLF序列转义处理不恰当(HTTP响应分割) http://cn-sec.com/archives/612696.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: