Interview Prep/DevSecOps/Vulnerability Management and OWASP

Your DAST scan in staging finds reflected XSS in a React app. The developers say React escapes everything. Who is right?

IntermediateScenarioVulnerability Management and OWASP
Answer

Situation read → React escapes values rendered in JSX, but there are known escape hatches.

What I'd do →

  1. Look for dangerouslySetInnerHTML, href={userInput} (allows javascript: URLs), direct DOM writes (innerHTML, document.write) and server-rendered templates outside React.
  2. Fix the source: sanitise HTML with DOMPurify, validate URL schemes to http/https.
  3. Add a strict Content Security Policy as defence in depth:
    Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-r4nd0m'; object-src 'none'; base-uri 'none'
    
  4. Add a Semgrep rule (react-dangerouslysetinnerhtml) to PR scanning.

Why → Frameworks reduce XSS a lot but do not eliminate it. The DAST hit is real until proven otherwise.

Interview tip → Name the escape hatches; it shows you have actually read React code.

All DevSecOps questions Roadmap: Security in the pipeline

More on Vulnerability Management and OWASP