HackPath Academy

Advanced Web, API & Modern Stack

React & Next.js Attacks

XSS via dangerouslySetInnerHTML, SSRF in API routes, and SSR pitfalls.

Advanced · 14 min

Open the interactive lesson →

React escapes output by default, which prevents most XSS — but modern React/Next apps still have plenty of attack surface, especially on the server side that Next.js introduces.

Client-side (React)

Server-side (Next.js)

// DANGER — XSS if `bio` is attacker-controlled
<div dangerouslySetInnerHTML={{ __html: user.bio }} />
// Safer: render as text, or sanitise with DOMPurify first.

Take the quiz →