19.09.2017 Views

the-web-application-hackers-handbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13 n Attacking Users: O<strong>the</strong>r Techniques 535<br />

GET http://mdsec.net/settings/12/Default.aspx?Language=English%0d%0a<br />

Content-Length:+22%0d%0a%0d%0a%0d%0afoo%0d%0a%0d%0aHTTP/<br />

1.1+200+OK%0d%0aContent-Length:+2307%0d%0a%0d%0a%0d%0a%0d%0a<br />

Administrator+login0d%0a[...long URL...] HTTP/1.1<br />

Host: mdsec.net<br />

Proxy-Connection: Keep-alive<br />

GET http://mdsec.net/admin/ HTTP/1.1<br />

Host: mdsec.net<br />

Proxy-Connection: Close<br />

4. The proxy server opens a TCP connection to <strong>the</strong> <strong>application</strong> and sends<br />

<strong>the</strong> two requests pipelined in <strong>the</strong> same way.<br />

5. The <strong>application</strong> responds to <strong>the</strong> first request with <strong>the</strong> attacker’s injected<br />

HTTP content, which looks exactly like two separate HTTP responses.<br />

6. The proxy server receives <strong>the</strong>se two apparent responses and interprets <strong>the</strong><br />

second as being <strong>the</strong> response to <strong>the</strong> attacker’s second pipelined request,<br />

which was for <strong>the</strong> URL http://mdsec.net/admin/. The proxy caches this<br />

second response as <strong>the</strong> contents of this URL. (If <strong>the</strong> proxy has already stored<br />

a cached copy of <strong>the</strong> page, <strong>the</strong> attacker can cause it to rerequest <strong>the</strong> URL<br />

and update its cache with <strong>the</strong> new version by inserting an appropriate<br />

If-Modified-Since header into his second request and a Last-Modified<br />

header into <strong>the</strong> injected response.)<br />

7. The <strong>application</strong> issues its actual response to <strong>the</strong> attacker’s second request,<br />

containing <strong>the</strong> au<strong>the</strong>ntic contents of <strong>the</strong> URL http://mdsec.net/admin/.<br />

The proxy server does not recognize this as being a response to a request<br />

that it actually issued and <strong>the</strong>refore discards it.<br />

8. A user accesses http://mdsec.net/admin/ via <strong>the</strong> proxy server and receives<br />

<strong>the</strong> content of this URL that was stored in <strong>the</strong> proxy’s cache. This content<br />

is in fact <strong>the</strong> attacker’s Trojan login form, so <strong>the</strong> user’s credentials are<br />

compromised.<br />

The steps involved in this attack are illustrated in Figure 13-3.<br />

Request 1<br />

GET/home.php?uid=123<br />

%0d%0aContent-Length...<br />

causes split<br />

response<br />

HTTP/1.1 OK<br />

Request 2<br />

GET/admin<br />

cached<br />

HTTP/1.1 OK<br />

Response to request 1<br />

ignored HTTP/1.1 OK Response to request 2<br />

Figure 13-3: The steps involved in an HTTP response splitting attack that poisons a<br />

proxy server cache

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!