Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
Mamba-in-Mamba: Centralized Mamba-Cross-Scan in Tokenized Mamba Model for Hyperspectral Image Classification
satai
3
330
Combining Deep Learning and Street View Imagery to Map Smallholder Crop Types
satai
3
310
第二言語習得研究における 明示的・暗示的知識の再検討:この分類は何に役に立つか,何に役に立たないか
tam07pb915
0
400
学習型データ構造:機械学習を内包する新しいデータ構造の設計と解析
matsui_528
4
2.2k
投資戦略202508
pw
0
580
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1k
Thirty Years of Progress in Speech Synthesis: A Personal Perspective on the Past, Present, and Future
ktokuda
0
140
ForestCast: Forecasting Deforestation Risk at Scale with Deep Learning
satai
2
100
J-RAGBench: 日本語RAGにおける Generator評価ベンチマークの構築
koki_itai
0
1.1k
生成AI による論文執筆サポート・ワークショップ ─ サーベイ/リサーチクエスチョン編 / Workshop on AI-Assisted Paper Writing Support: Survey/Research Question Edition
ks91
PRO
0
120
POI: Proof of Identity
katsyoshi
0
120
Agentic AI フレームワーク戦略白書 (2025年度版)
mickey_kubo
1
110
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
23
The Language of Interfaces
destraynor
162
25k
Building an army of robots
kneath
306
46k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
31
The Invisible Side of Design
smashingmag
302
51k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
260
Rails Girls Zürich Keynote
gr2m
95
14k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
26
Navigating Team Friction
lara
191
16k
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パターンを学習させて ペイロードを生成できたら良さそう • 答えは全てクライアントにある