Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DOM Based XSSの自動検出の話
Search
tanakayu
November 21, 2016
Research
3
2.5k
DOM Based XSSの自動検出の話
Shibuya.XSS#8
tanakayu
November 21, 2016
Tweet
Share
Other Decks in Research
See All in Research
[IBIS 2025] 深層基盤モデルのための強化学習驚きから理論にもとづく納得へ
akifumi_wachi
19
9.5k
ロボット学習における大規模検索技術の展開と応用
denkiwakame
1
200
国際論文を出そう!ICRA / IROS / RA-L への論文投稿の心構えとノウハウ / RSJ2025 Luncheon Seminar
koide3
13
7.2k
SkySense V2: A Unified Foundation Model for Multi-modal Remote Sensing
satai
3
470
スキマバイトサービスにおける現場起点でのデザインアプローチ
yoshioshingyouji
0
280
Community Driveプロジェクト(CDPJ)の中間報告
smartfukushilab1
0
160
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
ForestCast: Forecasting Deforestation Risk at Scale with Deep Learning
satai
3
360
AWSの耐久性のあるRedis互換KVSのMemoryDBについての論文を読んでみた
bootjp
1
450
地域丸ごとデイサービス「Go トレ」の紹介
smartfukushilab1
0
880
Can AI Generated Ambrotype Chain the Aura of Alternative Process? In SIGGRAPH Asia 2024 Art Papers
toremolo72
0
130
Satellites Reveal Mobility: A Commuting Origin-destination Flow Generator for Global Cities
satai
3
480
Featured
See All Featured
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
54
How to Talk to Developers About Accessibility
jct
2
120
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
110
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
920
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
KATA
mclloyd
PRO
34
15k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
The SEO Collaboration Effect
kristinabergwall1
0
350
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
1
93
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Transcript
DOM Based XSSを 全自動検出したい話 tanakayu 11/14 @Shibuya.XSS#8
今日話すこと •DOM Based XSSを全自動検出するには • DOM Based XSS の検出手法事情 •
実際に既存ツールを用いて実験してみる • 結果をもってより良いものを目指してみる ユーザに依存せず正確かつ自動的に検出したい
昨今のXSS事情 •サーバ型XSSに大きな変化はなし •クライアント型XSS(DOM Based XSS)はよ り複雑さを増している •DOM Based XSS の検出手法は現在も提案され
続けている
DOM Based XSS •クライアントサイドスクリプトに起因するXSS •Source(入力箇所)の文字列がSink(出力箇 所)でエスケープされていない際に起こりうる •http://example.jp# Source Sink 【脆弱なコード例】
<script>alert(1)</script>
探し方 •JavaScriptを頑張って読む • SourceからSinkの流れを頭で想像しながら追う • JavaScript力が求められる •ブラウザのデバッガを使いつつ頑張る • 値の受け渡し等を実際に動作を確認しながら追う •
デバッガ力が求められる
•JavaScriptを頑張って読む • SourceからSinkの流れを頭で想像しながら追う • JavaScript力が求められる •ブラウザのデバッガを使いつつ頑張る • 値の受け渡し等を実際に動作を確認しながら追う • デバッガ力が求められる
探し方(自動編) 静的解析 動的解析
静的解析 •ソースコードからSourceとSinkを探査 • 正規表現でのパターンマッチとか ScanJS:https://github.com/mozilla/scanjs
問題 •ダイナミックなコード生成 •Anonymous function •難読化 ⇒XSSの可否はユーザが確認 Jjencode: http://utf-8.jp/public/jjencode.html 今回の目的には合わない...
動的解析 •テイント解析 1. Sourceにテイントタグを付与 2. テイントタグの伝搬を追跡 3. Sinkの状態を確認 Source Sink
Propagation tag tag document.URL location.search location.hash document.write innerHTML window.location String.slice() String.split() String.replace() … … … tag Check!
既存ツール •DOMinator • Firefox(SpiderMonkeyを改造) • 元祖 •Tainted PhantomJS • QtWebKit(JavaScriptCoreを改造)
• BlackHat Asia 2014 •Hookish • Chrome拡張 • BlackHat US 2015 TaintedPhantomJS:https://github.com/neraliu/tainted-phantomjs/ DOMinator Pro:https://www.blueclosure.com/ Hookish:http://hookish.skepticfx.com/
Tainted PhantomJS •テイント解析とJavaScript(alert())動作で 脆弱か判定 •Tainted? • True or False •Alert?
• True or False
実験 •Firing Range • Google製のWebセキュリティ検査ツールのテスト ベッド https://public-firing-range.appspot.com/
結果(良い点) •FalsePositiveはゼロ • Taint & Alert の二重チェック • 定義されているSource/Sinkについては追えている •URLを渡すだけで実際にXSSできるところまで
確認することができる
結果(惜しい点) •定義されていないSinkが検出できない • URLや他リソースがSinkとなるもの • iframe, document.location, etc.. •発火にユーザ操作が必要なものを検出できない •
<a href=…, <form action=…, etc.. •location.search等の一部Sourceは完全検出できない (taint判定は可能) • ブラウザに依存する問題
改良 •検出ロジックの追加 • JavaScriptの動作と、それが攻撃コードによるもの かを確認 ⇒alert()で表示する文字列の確認 •攻撃コードの追加 • javascript:alert(1) •
data;text/html,alert(1) • etc… •攻撃完了後に使用したペイロードの存在を確認 • <a href=“javascript:alert(1)”>
いざ、再びのFiring Range •ユーザ操作が必要なものを検出できない • <a href=…、<form action=… •URLや他リソースがSinkとなるものが検出でき ない •
iframe、document.location、… •location.search等の一部Sourceは完全検出で きない(taint判定は可能) • ブラウザに依存する問題 クリア!! クリア!! ムリ!!
最終結果 •Sinkカバー率が上がった •ブラウザに依存する問題はどうにもならない document write innerHtml document writeln document. write
innerHtml document. writeln a.href embed.src document. location eval function form.action iframe.src range.creat eContextua lFragment object.data script.href setTimeout script.src Sourceをlocation.hashとした時に検出できたSink一覧
まとめと展望 •動的解析結構いいんじゃない? • 結構見つけてくれた • 検査結果の信頼性も高い •ソースコードからXSSパターンを学習させて ペイロードを生成できたら良さそう • 答えは全てクライアントにある