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 101 to 150 of 476
  1. Check the message origin and insert CSS as text rather than using innerHTML.

    Seen in 1 report
  2. Check the origin of postMessage events and sanitise dataKey before inserting it into the DOM.

    Seen in 1 report
  3. Check the URL scheme in the Home button's drop handler.

    Seen in 1 report
  4. Check the URL scheme is http or https before loading it into a WebView.

    Seen in 1 report
  5. Claim or remove cloud storage buckets referenced by shipped HTML files.

    Seen in 1 report
  6. Clear the parsed fragment on every error path so setHTML fails closed.

    Seen in 1 report
  7. Compare the correct identifier in the ownership check so untrusted input is validated.

    Seen in 1 report
  8. Decode CSS escape sequences before checking for image URLs.

    Seen in 1 report
  9. Derive the content type from the file's actual type or force a download instead of always serving text/html.

    Seen in 1 report
  10. Disable directory listing on public storage and add access controls.

    Seen in 1 report
  11. Disable HTML parsing in generic popup layouts and escape user-supplied messages.

    Seen in 1 report
  12. Disable raw HTML in the Markdown renderer or sanitise its output before writing it to the page.

    Seen in 1 report
  13. Disallow base tags and other dangerous markup in the markdown filter.

    Seen in 1 report
  14. Disallow javascript: URLs through the custom open-url scheme and show the full address in the address bar.

    Seen in 1 report
  15. Do not allow absolute same-origin URLs in SVG use elements in the sanitiser allowlist.

    Seen in 1 report
  16. Do not allow domains that host user-uploaded SWF files in script-src.

    Seen in 1 report
  17. Do not allow the style attribute on div tags in the HTML sanitiser allow-list.

    Seen in 1 report
  18. Do not assign user input to innerHTML; sanitise it first.

    Seen in 1 report
  19. Do not expose the origin server address behind a WAF.

    Seen in 1 report
  20. Do not let user-supplied trusted sites inject or override CSP directives.

    Seen in 1 report
  21. Do not load user-supplied HTML in a WebView with JavaScript enabled without sanitising it.

    Seen in 1 report
  22. Do not override the default MIME type to text/html for JSON responses.

    Seen in 1 report
  23. Do not pass intent extras straight into a WebView, and avoid binding a WebView with a JavaScript bridge to a sensitive origin.

    Seen in 1 report
  24. Do not pass untrusted Intent extras into JavaScript functions that set innerHTML.

    Seen in 1 report
  25. Do not proxy permissionless storage onto the application origin, keep tokens out of localStorage, and tighten the CSP.

    Seen in 1 report
  26. Do not rely on client-side validation; sanitise user input on the server before rendering it as HTML.

    Seen in 1 report
  27. Do not rely on nonces embedded in the DOM as the only CSRF defence.

    Seen in 1 report
  28. Do not rely on quote filtering; encode output and restrict mass assignment.

    Seen in 1 report
  29. Do not rely on the AngularJS expression sandbox; keep AngularJS updated and avoid evaluating user input as expressions.

    Seen in 1 report
  30. Do not rely solely on an external script to move content into a sandboxed iframe.

    Seen in 1 report
  31. Do not ship example scripts that echo request parameters in release packages.

    Seen in 1 report
  32. Do not treat user ID zero as a valid session match and filter stored values on output.

    Seen in 1 report
  33. Do not trust a null origin and restrict the dispatcher to an allowlist of methods.

    Seen in 1 report
  34. Do not trust global variables that can be created by DOM clobbering, and encode query data before document.write.

    Seen in 1 report
  35. Do not trust the client content type and do not serve uploaded files as HTML.

    Seen in 1 report
  36. Do not trust the client-supplied forwarded-host header when locating the CDN host.

    Seen in 1 report
  37. Do not unescape HTML entities before stripping tags.

    Seen in 1 report
  38. Do not write document.URL into script or HTML sinks and encode single quotes in URL credentials.

    Seen in 1 report
  39. Encode and type-cast the cID parameter before concatenating it into an attribute.

    Seen in 1 report
  40. Encode and validate the error description parameter before reflection.

    Seen in 1 report
  41. Encode attachment file names before rendering them.

    Seen in 1 report
  42. Encode comment content on output.

    Seen in 1 report
  43. Encode complaint text on output in the admin page.

    Seen in 1 report
  44. Encode coupon parameter values before reflecting them.

    Seen in 1 report
  45. Encode decoded path segments before inserting them into the response.

    Seen in 1 report
  46. Encode folder names on output and check the caller's authorisation for the supplied company identifier.

    Seen in 1 report
  47. Encode invitation message text before inserting it into outgoing email bodies.

    Seen in 1 report
  48. Encode or validate a returnUrl value before inserting it into an inline JavaScript event handler.

    Seen in 1 report
  49. Encode or validate path content echoed on error pages.

    Seen in 1 report
  50. Encode or validate the error parameter before reflecting it.

    Seen in 1 report