Slide 1

Slide 1 text

🔐 ATTACKING THE FRONTEND CodingWithCallum™️ Lightning Talk

Slide 2

Slide 2 text

COMMON ISSUES Code injection How does the web app handle unexpected data XSS "Cross Site Scripting" Attacker submitted code run in browser CSP by itself cannot prevent XSS HTML elements can run code!

Slide 3

Slide 3 text

REACT Context sensitive output encoding out of the box until you use something with the word dangerous in front of it React will protect you from yourself

Slide 4

Slide 4 text

DANGEROUSLYSETINNERHTML Don't use this + the linter will yell at you if you do Needs DOMPurify if you need to use it {dangerouslySetInnerHTML: DOMPurify.sanitize({html})}

Slide 5

Slide 5 text

ESCAPE HATCHES Bypass react and access native DOM APIs Direct DOM Manipulation Good news: React is deprecating this should be disallowed findDOMNode innerHTML createRef is not

Slide 6

Slide 6 text

ENCODING URLS Avoid taking full URL as an input Do URL sanitisation Nextjs does this for us Should allowlist certain urls

Slide 7

Slide 7 text

RESOURCE URLS Javascript & Resource URLs can be a potential sink are being disallowed from React 17+ data. still runs

Slide 8

Slide 8 text

BEST PRACTICES "If you are going to the DOM directly, talk to security" CSRF Cookies should have samesite set (or better be secure)

Slide 9

Slide 9 text

RESOURCES is a deliberately vulnerable app you can play around with React has a guide on A collection of escape hatches exploring React.__SECRET_INTERNALS_DO_NOT _USE_OR_YOU_WILL_BE_FIRED ReactVulna escape hatches Its-fine

Slide 10

Slide 10 text

No content