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
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
420
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
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
180
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
100
ふつうのFeature Flag実践入門
irof
7
3.7k
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.3k
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
860
JavaDoc 再入門
nagise
0
310
dRuby over BLE
makicamel
2
330
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.2k
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
340
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
5.1k
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.6k
さぁV100、メモリをお食べ・・・
nilpe
0
130
Featured
See All Featured
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
210
Marketing to machines
jonoalderson
1
5.4k
Google's AI Overviews - The New Search
badams
0
1k
Agile that works and the tools we love
rasmusluckow
331
21k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
390
The agentic SEO stack - context over prompts
schlessera
0
800
How GitHub (no longer) Works
holman
316
150k
Six Lessons from altMBA
skipperchong
29
4.3k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
190
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
230
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、ちゃんと付けましょう。