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
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
410
台湾モデルに学ぶ詐欺広告対策:市民参加の必要性
dd2030
0
280
その推薦システムの評価指標、ユーザーの感覚とズレてるかも
kuri8ive
1
350
AIスーパーコンピュータにおけるLLM学習処理性能の計測と可観測性 / AI Supercomputer LLM Benchmarking and Observability
yuukit
1
760
通時的な類似度行列に基づく単語の意味変化の分析
rudorudo11
0
200
製造業主導型経済からサービス経済化における中間層形成メカニズムのパラダイムシフト
yamotty
0
530
AIを叩き台として、 「検証」から「共創」へと進化するリサーチ
mela_dayo
0
190
The mathematics of transformers
gpeyre
0
150
AI Agentの精度改善に見るML開発との共通点 / commonalities in accuracy improvements in agentic era
shimacos
6
1.4k
世界モデルにおける分布外データ対応の方法論
koukyo1994
7
2k
COFFEE-Japan PROJECT Impact Report(海ノ向こうコーヒー)
ontheslope
0
1.1k
Upgrading Multi-Agent Pathfinding for the Real World
kei18
0
530
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
91
Git: the NoSQL Database
bkeepers
PRO
432
67k
Automating Front-end Workflow
addyosmani
1370
200k
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
GraphQLとの向き合い方2022年版
quramy
50
14k
GitHub's CSS Performance
jonrohan
1032
470k
Making Projects Easy
brettharned
120
6.6k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
300
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1k
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パターンを学習させて ペイロードを生成できたら良さそう • 答えは全てクライアントにある