15
HTTP Response Splitting By Sharath Unni @haxorhead

Http response splitting

Embed Size (px)

DESCRIPTION

HTTP Response Splitting or CRLF injection is an attack technique which enables various attacks such as web cache poisoning, cross user defacement, hijacking pages with sensitive user information and our favorite, cross-site scripting (XSS). This attack technique, and the derived attacks from it, are relevant to most web environments and is the result of the application’s failure to reject illegal user input, in this case, input containing malicious or unexpected characters. The talk will cover the concept of the attack and will take you through some use cases.

Citation preview

Page 1: Http response splitting

HTTP Response Splitting

By Sharath Unni@haxorhead

Page 2: Http response splitting

Involved parties

Root problem

Example

Web cache poisoning

XSS

Other derived attacks

Recommendations

Contents

Page 3: Http response splitting

There are always 3 parties (atleast) involved

Web server: hosts the application, with the vulnerability. (Tomcat, Apache, IIS etc.)

Target: An entity that interacts with the web server on behalf of the client. Eg: squid proxy

Attacker: initiates the attack

Involved parties

Page 4: Http response splitting

Failure to reject illegal user input Specifically input containing CR and LF

characters Carriage Return and Line Feed - %0d%0a (\

r\n) The data (user input) is included in an HTTP

response header without any validation. HTTP connection sharing Caching – less control over the site content,

improve performance, speed etc.

Root problem

Page 5: Http response splitting

Normal request:

http://www.the.site/new_page.asp?lang=german

Normal response:

HTTP/1.0 302 RedirectLocation: http://www.the.site/new_page.asp?lang=germanConnection: Keep-AliveContent-Length: 0

Example

Page 6: Http response splitting

Request (attacker):

http://www.the.site/welcome.asp?lang=Foo%0d%0aConnection:%20Keep-Alive%0d%0aContent-Length:%200%0d%0a%0d%0aHTTP/1.0%20200%20OK%0d%0aContent-Type:%20text/html%0a%0aContent-Length:%2020%0d%0a%0d%0a<html>Pwned!</html>

Response:

HTTP/1.0 302 RedirectLocation: http://www.the.site/new_page.asp?lang=FooConnection: Keep-AliveContent-Length: 0

HTTP/1.0 200 OKContent-Type: text/htmlContent-Length: 20

<html>Pwned!</html>Connection: Keep-AliveContent-Length: 0

Example

Page 7: Http response splitting

Attack overview:

Attacker sends 2 requests: 1. HTTP response splitter (with %0d%0a) 2. An innocent request

Proxy will match 1st request -> 1st reponse

2nd request (innocent) -> 2nd response in cache (Pwned!)

Web cache poisoning

Page 8: Http response splitting

Basic Concept

Page 9: Http response splitting

Attack sequence

9

302

302

200 (Pwned!)

1st attacker request (response splitter) 1st attacker request

(response splitter)

2nd attacker request(innocent /index.html)

2nd attacker request(innocent /index.html)

200 (Pwned!) 200

(Welcome)

Page 10: Http response splitting

XSS: The second response is controlled by the attacker and JavaScript or HTML code can be inserted.

Cross-Site Scripting

Page 11: Http response splitting

Evade CSP – Content Security Policy – instructs the client browser from which location and/or which type of resources are allowed to be loaded

Certain browsers will interpret the first occurrence of HTTP header

HTTP Response header

Content-Security-Policy: X-Content-Security-Policy

Lang=en_US%0d%0aX-Content-Security-Policy: allow *

CSP evasion via CRLF

Page 12: Http response splitting

CSP evasion

Page 13: Http response splitting

CSP evasion

Page 14: Http response splitting

For developers:◦ Validate user input and remove CRLF characters

(particularly when setting cookie and redirecting)

For proxy vendors:◦ Avoid sharing server TCP connections among

different virtual hosts.◦ Maintain request host header correctly from the

URL and not from the Host header.

Recommendations

Page 15: Http response splitting

Thank you@haxorhead