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.
-
Check the message origin and insert CSS as text rather than using innerHTML.
Seen in 1 report
-
Check the origin of postMessage events and sanitise dataKey before inserting it into the DOM.
Seen in 1 report
-
Check the URL scheme in the Home button's drop handler.
Seen in 1 report
-
Check the URL scheme is http or https before loading it into a WebView.
Seen in 1 report
-
Claim or remove cloud storage buckets referenced by shipped HTML files.
-
Clear the parsed fragment on every error path so setHTML fails closed.
Seen in 1 report
-
Compare the correct identifier in the ownership check so untrusted input is validated.
Seen in 1 report
-
Decode CSS escape sequences before checking for image URLs.
Seen in 1 report
-
Derive the content type from the file's actual type or force a download instead of always serving text/html.
Seen in 1 report
-
Disable directory listing on public storage and add access controls.
Seen in 1 report
-
Disable HTML parsing in generic popup layouts and escape user-supplied messages.
Seen in 1 report
-
Disable raw HTML in the Markdown renderer or sanitise its output before writing it to the page.
-
Disallow base tags and other dangerous markup in the markdown filter.
Seen in 1 report
-
Disallow javascript: URLs through the custom open-url scheme and show the full address in the address bar.
Seen in 1 report
-
Do not allow absolute same-origin URLs in SVG use elements in the sanitiser allowlist.
Seen in 1 report
-
Do not allow domains that host user-uploaded SWF files in script-src.
Seen in 1 report
-
Do not allow the style attribute on div tags in the HTML sanitiser allow-list.
Seen in 1 report
-
Do not assign user input to innerHTML; sanitise it first.
Seen in 1 report
-
Do not expose the origin server address behind a WAF.
Seen in 1 report
-
Do not let user-supplied trusted sites inject or override CSP directives.
Seen in 1 report
-
Do not load user-supplied HTML in a WebView with JavaScript enabled without sanitising it.
Seen in 1 report
-
Do not override the default MIME type to text/html for JSON responses.
Seen in 1 report
-
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
-
Do not pass untrusted Intent extras into JavaScript functions that set innerHTML.
-
Do not proxy permissionless storage onto the application origin, keep tokens out of localStorage, and tighten the CSP.
Seen in 1 report
-
Do not rely on client-side validation; sanitise user input on the server before rendering it as HTML.
Seen in 1 report
-
Do not rely on nonces embedded in the DOM as the only CSRF defence.
Seen in 1 report
-
Do not rely on quote filtering; encode output and restrict mass assignment.
Seen in 1 report
-
Do not rely on the AngularJS expression sandbox; keep AngularJS updated and avoid evaluating user input as expressions.
Seen in 1 report
-
Do not rely solely on an external script to move content into a sandboxed iframe.
Seen in 1 report
-
Do not ship example scripts that echo request parameters in release packages.
Seen in 1 report
-
Do not treat user ID zero as a valid session match and filter stored values on output.
Seen in 1 report
-
Do not trust a null origin and restrict the dispatcher to an allowlist of methods.
Seen in 1 report
-
Do not trust global variables that can be created by DOM clobbering, and encode query data before document.write.
Seen in 1 report
-
Do not trust the client content type and do not serve uploaded files as HTML.
Seen in 1 report
-
Do not trust the client-supplied forwarded-host header when locating the CDN host.
Seen in 1 report
-
Do not unescape HTML entities before stripping tags.
-
Do not write document.URL into script or HTML sinks and encode single quotes in URL credentials.
Seen in 1 report
-
Encode and type-cast the cID parameter before concatenating it into an attribute.
Seen in 1 report
-
Encode and validate the error description parameter before reflection.
Seen in 1 report
-
Encode attachment file names before rendering them.
Seen in 1 report
-
Encode comment content on output.
Seen in 1 report
-
Encode complaint text on output in the admin page.
Seen in 1 report
-
Encode coupon parameter values before reflecting them.
-
Encode decoded path segments before inserting them into the response.
Seen in 1 report
-
Encode folder names on output and check the caller's authorisation for the supplied company identifier.
Seen in 1 report
-
Encode invitation message text before inserting it into outgoing email bodies.
Seen in 1 report
-
Encode or validate a returnUrl value before inserting it into an inline JavaScript event handler.
Seen in 1 report
-
Encode or validate path content echoed on error pages.
Seen in 1 report
-
Encode or validate the error parameter before reflecting it.
Seen in 1 report