Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
The face of X-Content-Type-Options which you ma...
Search
Yu Yagihashi
April 24, 2018
Programming
440
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The face of X-Content-Type-Options which you may not know
LT向け資料。ざっっっっっっくりなのでまさかりはマジかんべん。 #roppongijs #2
Yu Yagihashi
April 24, 2018
More Decks by Yu Yagihashi
See All by Yu Yagihashi
A Security Engineer in the Web Re-architecture Project
yagihashoo
0
1.2k
A talk about XSS thousand knocks(Shibuya.XSS techtalk#10)
yagihashoo
5
3.2k
katagaitai勉強会#6 EasyなWeb編 / katagaitaiCTF#6 Web
yagihashoo
1
1.3k
Other Decks in Programming
See All in Programming
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
510
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
320
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
AmebaブログはKMPから卒業します
kmars0605
0
200
Workers Cache を知る
syumai
0
370
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.2k
AWSに止められる覚悟してますか?
morizo_1984
2
540
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.7k
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
A Tale of Four Properties
chriscoyier
163
24k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Making Projects Easy
brettharned
120
6.8k
Into the Great Unknown - MozCon
thekraken
41
2.8k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Fireside Chat
paigeccino
43
4.1k
Done Done
chrislema
187
17k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Discover your Explorer Soul
emna__ayadi
2
1.3k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
The Language of Interfaces
destraynor
162
27k
Transcript
あなたの知らない(かもしれない) X-Content-Type-Options Yu YAGIHASHI(@yagihashoo) @Roppongi.js#2
None
None
Content Sniffing • Content-Typeヘッダの内容に関係なく、レスポンスボディの内容に 応じてIEがContent-Typeを勝手に判断する機能 →と思っていませんか? • 正確なContent-Typeが設定されていても無視されるのが特に悪質で、 その解決策としてX-Content-Type-Optionsヘッダによるこの機能の 制御・無効化が一般的となった
• 具体的には、HTMLタグを含む画像ファイルを開くとHTMLとして 認識されてしまうことによるXSSなど
FirefoxとかChromeにもあるよ • 画像を開くとHTMLに!みたいなトンデモ仕様はない(はず) • (LTなので)細かい挙動は調べていないが、どちらかというと内容よりも コンテキストに応じて既存のContent-Typeヘッダの値を無視し、 別のContent-Typeとしてロードする挙動をするように見える • 例えば、.jsファイルのContent-Typeがなぜかtext/htmlであっても script要素のsrc属性で指定し、ロードできるなど
FirefoxとかChromeにもあるよ HTML PNGファイルだよ〜 は?JSとして読むわ <script src=“hoge.png”></script> \x89PNG~~~~~~ Content-Type: image/png
ごく一般的なGIFファイル GIF8=1;alert("あなたの知らない(かもしれない)X-Content-Type-Options")
fileコマンドでも
PHPでも
シナリオ HTML Content-Security-Policy: default-src ‘self’ GIF(仮) <script src=“hoge.gif”></script> なんか悪い感じのJSコード GIF(仮)
シナリオ HTML Content-Security-Policy: default-src ‘self’ GIF(仮) <script src=“hoge.gif”></script> なんか悪い感じのJSコード GIF(仮)
XSSの脆弱性があるが、いい感じのCSPヘッダに よって悪い感じのコードはそもそも動かない
シナリオ HTML Content-Security-Policy: default-src ‘self’ GIF(仮) <script src=“hoge.gif”></script> なんか悪い感じのJSコード GIF(仮)
攻撃者が自由に画像ファイルを 同一オリジンにアップロードできる
シナリオ HTML Content-Security-Policy: default-src ‘self’ GIF(仮) <script src=“hoge.gif”></script> なんか悪い感じのJSコード GIF(仮)
XSSで埋め込んだscript要素から 同一オリジンにアップロードした 悪い感じのGIFファイルを参照する
シナリオ HTML Content-Security-Policy: default-src ‘self’ GIF(仮) <script src=“hoge.gif”></script> なんか悪い感じのJSコード GIF(仮)
CSPでいい感じなのに XSSできてしまう!!!
さいごに • やることは変わらないです。X-C-T-O: nosniff、ちゃんと付けましょう。