-
Security
Fix DOM-based XSS in my frontend
Traces user-controlled data into innerHTML, document.write, and other DOM sinks and replaces them with safe alternatives.
Free Prompt
What This Does / How This Helps
Follows attacker-controlled data through your frontend into the DOM APIs that execute it, and swaps those APIs for safe ones. Stored XSS gets the attention, but DOM-based XSS never touches your server. The payload rides in the URL fragment or a postMessage and your own client-side code injects it into the page. Server-side escaping cannot save you because the server never sees it. AI-generated frontend code loves innerHTML because it is the shortest path to rendering. This prompt finds every occurrence, traces where the data comes from, and converts rendering to safe APIs or a real sanitizer, with proof payloads for each fix.
Want to skip doing this by hand?
Fortivibe audits your app for all of the areas these prompts cover (and more).