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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.8k
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
350
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
250
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
730
FreeBSDでZabbixを動かす
kenkino
0
310
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
130
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
350
XHTMLが残したもの
yosuke_furukawa
PRO
2
830
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
330
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
550
速習iPhone Duo対応
yuukiw00w
1
660
Jetpack Compose メカニズム
skydoves
0
450
Featured
See All Featured
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
510
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Fireside Chat
paigeccino
43
4k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
700
A better future with KSS
kneath
240
18k
Ethics towards AI in product and experience design
skipperchong
2
380
We Have a Design System, Now What?
morganepeng
55
8.3k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
700
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1k
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、ちゃんと付けましょう。