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
React and XSS
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yunosuke Yamada
October 16, 2022
Programming
390
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
React and XSS
Yunosuke Yamada
October 16, 2022
More Decks by Yunosuke Yamada
See All by Yunosuke Yamada
AI時代に成長するエンジニアに必要なスキルとは.pdf
yunosukey
0
260
Gemini CLIでもセキュアで堅牢な開発をしたい!
yunosukey
1
660
DevOps/MLOpsに学ぶエージェントの可観測性
yunosukey
1
1.2k
Agent Development Kitで作るマルチエージェントアプリケーション(AIAgent勉強会)
yunosukey
4
1.9k
Agent Development Kitで作るマルチエージェントアプリケーション(GCNT2025)
yunosukey
0
94
AIエージェントのオブザーバビリティについて
yunosukey
1
940
OpenTelemetry + LLM = OpenLLMetry!?
yunosukey
2
1.2k
クラウド開発環境Cloud Workstationsの紹介
yunosukey
0
480
フロントエンドオブザーバビリティ on Google Cloud
yunosukey
1
390
Other Decks in Programming
See All in Programming
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
370
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
200
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
140
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
180
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
150
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
310
アクセシビリティから考える情報設計
high_g_engineer
0
370
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
380
AIエージェント時代のコードレビューを設計する
nogu66
6
2.7k
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
450
自分的「カンファレンスの楽しみ方」
syumai
0
200
スマート反転とウェブアクセシビリティ
camiha
0
200
Featured
See All Featured
Paper Plane
katiecoart
PRO
3
53k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
480
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
WENDY [Excerpt]
tessaabrams
13
39k
Being A Developer After 40
akosma
91
590k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
530
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Transcript
ReactとXSS 2021/07/15 山田悠之介
XSS (Cross-site scripting) 悪意のあるスクリプトを閲覧者のブラウザで実行すること 反射型 XSS、格納型 XSS、DOM Based XSS などの種類があるが
いずれも XSS するためには文字列として入力したスクリプトを 標的となるサイトで実行させなければならない 2
React React では XSS 対策として文字列はエスケープされる。 https://ja.reactjs.org/docs/jsx-in-depth.html#string-literals 3
生成される HTML export default function Home() { const script =
` <script> while (1) { alert('!'); } </script>`; return <main>{script}</main>; } ↓ <main><script> while (1) { alert('!'); } </script></main> 4
innerHTML 標準の JS や jQuery で HTML を動的に生成するときには innerHTML を使っていた。
React では... 5
dangerouslySetInnerHTML https://ja.reactjs.org/docs/dom- elements.html#dangerouslysetinnerhtml export default function Home() { const script
= ... const html = { __html: script }; return ( <main> <div dangerouslySetInnerHTML={html} />; </main> ); } 6
href, src export default function Home() { const script =
` javascript: while (1) { alert('!'); }`; return ( <main> <a href={script}>link</a> </main> ); } 7
"javascript:"は deprecated https://reactjs.org/blog/2019/08/08/react- v16.9.0.html#deprecating-javascript-urls 将来的にはエラーにする 8
その他 DOM 要素の取得 (findDOMNode, createRef) からの innerHTML createElement SSR +
Redux eval(React 関係ないけど) 9
回避するには ユーザの入力を無害化する DOMPurify 10
import DOMPurify from "isomorphic-dompurify"; export default function Home() { const
script = "<script>...</script>Hello"; const html = { __html: DOMPurify.sanitize(script) }; return ( <main> <div dangerouslySetInnerHTML={html} /> </main> ); } ↓ <main><div>Hello</div></main> 11
参考資料 https://zenn.dev/yuuhu04/books/xss-anti-pattern-of-react- and-vue 最初に読んだ https://pragmaticwebsecurity.com/articles/spasecurity/react -xss-part1.html part3 まである 網羅的 12
Thank you 13