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 →
- Look for
dangerouslySetInnerHTML,href={userInput}(allowsjavascript:URLs), direct DOM writes (innerHTML,document.write) and server-rendered templates outside React. - Fix the source: sanitise HTML with DOMPurify, validate URL schemes to
http/https. - 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' - 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.
More on Vulnerability Management and OWASP
A pentest report shows SQL injection in a search endpoint of a Java service. How do you handle it end to end?BeginnerA scanner reports 4,000 open CVEs across 300 images. The team can fix maybe 100 a month. How do you prioritise?IntermediateA user reports they can see another customer's invoice by changing the ID in the URL. What do you do?BeginnerA webhook feature lets users enter a URL, and a pentester used it to read the cloud metadata endpoint. How do you fix it?AdvancedA team still runs Log4j 2.14 in an internal service and says it is not internet-facing. How do you respond?IntermediateA security review finds passwords stored as unsalted MD5 hashes. How do you migrate without forcing every user to reset?Advanced