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 51 to 100 of 476
  1. Send a restrictive Content-Security-Policy that does not allow data: scripts.

    Seen in 2 reports
  2. Serve uploaded PDFs with a download disposition or from a separate origin so embedded JavaScript cannot run in the site origin.

    Seen in 2 reports
  3. Set text content instead of using innerHTML or jQuery.append with untrusted values.

    Seen in 2 reports
  4. Set the correct JSON content type and add the nosniff header so responses cannot be sniffed as HTML.

    Seen in 2 reports
  5. Strip active content from uploaded PDFs and SVGs and serve them with a download disposition.

    Seen in 2 reports
  6. Update the sanitiser to handle CDATA sections and data-* attributes.

    Seen in 2 reports
  7. Use textContent instead of innerHTML when inserting user-controlled text such as filenames.

    Seen in 2 reports
  8. Validate allowed characters in name fields and encode them in email templates.

    Seen in 2 reports
  9. Validate and encode parameters in drilldown components.

    Seen in 2 reports
  10. Validate that redirect targets are safe relative paths before assigning to a navigation sink.

    Seen in 2 reports
  11. Validate the forwarded-proto header as a simple protocol string and do not skip the whitelist based on the path prefix.

    Seen in 2 reports
  12. Validate the origin of incoming messages and avoid wildcard targetOrigin when sending them.

    Seen in 2 reports
  13. Account for browser-specific parsing quirks such as namespace switching, animation attributes, XSLT and Safari's image import behaviour in SVG sanitisers.

    Seen in 1 report
  14. Account for control characters when filtering javascript: URIs.

    Seen in 1 report
  15. Add a CSRF token check to the save endpoint and HTML-encode stored action names on output.

    Seen in 1 report
  16. Add a CSRF token to the saving form and mark session cookies HttpOnly.

    Seen in 1 report
  17. Add authorisation checks and output encoding to the AJAX endpoint.

    Seen in 1 report
  18. Add CSRF protection to profile update endpoints so self-XSS cannot be forced onto victims.

    Seen in 1 report
  19. Add input validation and output encoding for the page size parameter.

    Seen in 1 report
  20. Add origin checks to the cookie-setting endpoint and encode cookie values reflected into the page.

    Seen in 1 report
  21. Add rel=noopener to links opened in a new tab and complete the URI scheme allow-list.

    Seen in 1 report
  22. Add the sandbox attribute to rendered iframes to block script execution and top-level navigation.

    Seen in 1 report
  23. Anchor the hostname check and reject protocol-relative URLs.

    Seen in 1 report
  24. Apply HTML-specific escaping to all branding fields rather than checking one parameter against a blocklist.

    Seen in 1 report
  25. Apply htmlspecialchars to comment text before echoing it.

    Seen in 1 report
  26. Apply output encoding to name fields and enforce authorisation checks on profile lookups.

    Seen in 1 report
  27. Apply output encoding to the display name on every page that renders it, not only on the profile page.

    Seen in 1 report
  28. Apply output encoding to XML responses and add CSRF protections to the POST endpoint.

    Seen in 1 report
  29. Apply the fragment-only URL check to namespaced attributes as well.

    Seen in 1 report
  30. Apply the same filename sanitisation to FTP uploads as to manual rename.

    Seen in 1 report
  31. Apply the same HTML escaping to the new byline placeholder as to the credits placeholder.

    Seen in 1 report
  32. Apply the same sanitisation to dialog titles as elsewhere.

    Seen in 1 report
  33. Apply the session check to GET requests as well as POST.

    Seen in 1 report
  34. Attempted attacks against the Flash file were redirected to a 404 page.

    Seen in 1 report
  35. Authenticate messages to the element picker and sanitise option fields.

    Seen in 1 report
  36. Automatically fetch newly released fixed library versions.

    Seen in 1 report
  37. Avoid building HTML strings from unescaped values and assigning them to innerHTML in privileged pages.

    Seen in 1 report
  38. Avoid innerHTML for search input and use text insertion instead.

    Seen in 1 report
  39. Avoid mark_safe with string formatting on user input and rely on Django's automatic escaping.

    Seen in 1 report
  40. Bind CAPTCHA tokens to the user's session and encode reflected input.

    Seen in 1 report
  41. Bind CSRF tokens to the user session.

    Seen in 1 report
  42. Bind login tokens to the original session.

    Seen in 1 report
  43. Block javascript: URLs entered in the address bar or received via redirects.

    Seen in 1 report
  44. Block javascript: URLs used as the target of HTTP redirects.

    Seen in 1 report
  45. Build absolute links from a configured canonical URL rather than the request Host header.

    Seen in 1 report
  46. Check authorisation on every nested identifier, not just the top-level one.

    Seen in 1 report
  47. Check file extension, MIME type and content server-side before storing and serving uploaded files.

    Seen in 1 report
  48. Check that redirect targets are safe http(s) URLs.

    Seen in 1 report
  49. Check that URLs from the search backend use http or https before creating an omnibox match.

    Seen in 1 report
  50. Check the context before replacing the current document in the XSLT error handler.

    Seen in 1 report