Skip to content

In-depth lesson · XSS

Typical fixes

Every point the XSS reports back under this heading, best-backed first, each with the reports it is seen in.

Back to the lesson 1 to 50 of 476
  1. Apply context-appropriate output encoding for HTML, attribute and JavaScript contexts.

    Seen in 20 reports
  2. Sanitise uploaded files and serve them with a safe content type or force download.

    Seen in 9 reports
  3. HTML-encode filenames, names and user text before inserting them into pages, and use text insertion rather than HTML insertion where markup is not intended.

    Seen in 6 reports
  4. Properly encode and validate user-supplied input reflected in URLs.

    Seen in 5 reports
  5. Encode name fields before inserting them into email templates.

    Seen in 4 reports
  6. Encode user input before reflecting it into HTML responses.

    Seen in 4 reports
  7. Listeners should validate the sender origin before acting on message content.

    Seen in 4 reports
  8. Validate actual file content and serve uploads with a safe content type rather than trusting the extension.

    Seen in 4 reports
  9. Validate actual file content with magic bytes and serve uploads with a safe Content-Type and a restrictive CSP or sandbox.

    Seen in 4 reports
  10. Validate the actual content of uploaded files rather than trusting the extension, and serve user files from a separate origin.

    Seen in 4 reports
  11. Apply context-aware output encoding when writing URL parameters into the DOM.

    Seen in 3 reports
  12. Check the sender origin against an exact allowlist and sanitise message content before inserting it.

    Seen in 3 reports
  13. Disable the TRACE method on the web server.

    Seen in 3 reports
  14. Do not modify sanitised output afterwards, and re-sanitise after any server-side rewrite.

    Seen in 3 reports
  15. Encode or filter HTML characters in reflected URL content.

    Seen in 3 reports
  16. Encode reflected input and block event-handler attributes on all elements, not just script tags.

    Seen in 3 reports
  17. Encode user input on output rather than relying on blacklists of tags or attributes.

    Seen in 3 reports
  18. Encode user input on output rather than relying on client-side or keyword filters.

    Seen in 3 reports
  19. Escape user messages before rendering them as HTML.

    Seen in 3 reports
  20. Reject control characters and javascript schemes in return and redirect URLs, and parse URLs consistently with browsers.

    Seen in 3 reports
  21. Sanitise SVG content and restrict active content before serving uploaded files.

    Seen in 3 reports
  22. Sanitise SVG uploads and serve them from a separate origin with a strict CSP.

    Seen in 3 reports
  23. Serve uploaded files with a safe content type and a Content-Disposition header, and do not serve user HTML from the application origin.

    Seen in 3 reports
  24. Validate and encode user-supplied data in device management endpoints.

    Seen in 3 reports
  25. Validate link targets in markup renderers and reject javascript: URLs.

    Seen in 3 reports
  26. Validate that redirect parameters are safe http(s) URLs and reject javascript: schemes.

    Seen in 3 reports
  27. Validate URL schemes against an allowlist before placing values into href or iframe sources.

    Seen in 3 reports
  28. Apply output encoding to user input reflected by incentive endpoints.

    Seen in 2 reports
  29. Check the origin of incoming postMessage events before acting on them.

    Seen in 2 reports
  30. Encode and validate parameters written into HTML attributes.

    Seen in 2 reports
  31. Encode quotes in parameters inserted into HTML attributes.

    Seen in 2 reports
  32. Encode the quote character and angle brackets when reflecting input into an HTML attribute value.

    Seen in 2 reports
  33. Escape the code parameter before placing it in inline JavaScript.

    Seen in 2 reports
  34. Escape the url parameter before inserting it into the DOM.

    Seen in 2 reports
  35. Filter after the final decoding step rather than before a second decode.

    Seen in 2 reports
  36. HTML-encode filenames before inserting them into directory listings.

    Seen in 2 reports
  37. HTML-encode report parameters before rendering them.

    Seen in 2 reports
  38. HTML-encode user values inserted into email bodies.

    Seen in 2 reports
  39. Make sure CSP applies to Blob URLs and to pages that load third-party scripts.

    Seen in 2 reports
  40. Normalise cookie names consistently between browser and server and avoid disclosing cookies in errors.

    Seen in 2 reports
  41. Output-encode the search query in results pages.

    Seen in 2 reports
  42. Redirect targets should be validated as http(s) URLs on the trusted host before assignment.

    Seen in 2 reports
  43. Reject javascript: and data: schemes in integration base URL fields.

    Seen in 2 reports
  44. Require CSRF tokens and the X-Requested-With header on state-changing requests such as adding favourites or logging in.

    Seen in 2 reports
  45. Sanitise and encode the returnUrl parameter and username value before inserting them into the DOM.

    Seen in 2 reports
  46. Sanitise and encode user input before including it in email HTML.

    Seen in 2 reports
  47. Sanitise chat messages server-side and output-encode them before rendering.

    Seen in 2 reports
  48. Sanitise embedded markup in editor paste handling and restrict data: URL image sources.

    Seen in 2 reports
  49. Sanitise HTML in diagram labels and syntax before inserting rendered Mermaid diagrams into the page.

    Seen in 2 reports
  50. Sanitise SVG uploads or restrict script content in them, as with profile picture uploads.

    Seen in 2 reports