← Back to scanner
2026-05-08

XSS Prevention: A Practical Checklist

Cross-site scripting is still one of the top web vulnerabilities. Here's how to prevent it.

Cross-site scripting (XSS) has been in the OWASP Top 10 for over a decade. It's still there because developers still make the same mistakes.

The three types

Prevention checklist

  1. Sanitize all user input on the server side
  2. Encode output based on context (HTML, JavaScript, URL, CSS)
  3. Use Content-Security-Policy headers
  4. Set HttpOnly flag on cookies
  5. Use frameworks that escape by default (React, Vue, Angular)
  6. Validate input with strict whitelists

The single most effective defense is a strong Content-Security-Policy header that restricts inline scripts.