Skip to content

Bug class · Beginner

Cross-site scripting (XSS)

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

median public bounty
$800

Covers CWE 79, 80, 83, 87.

Things to try

All 5,473

Each line worked in a disclosed report. Test only what a program's scope allows.

Other 922

  • Craft a URL against an on-premises business application and check whether script runs or the victim is redirected to an attacker site.
  • Build a gem or documentation set containing crafted input and open the generated HTML to see whether script tags or event handlers survive.
  • Create a README in RDoc, Textile and reStructuredText formats containing a javascript: link and click it.
  • Put script payloads in contact and inquiry forms and wait for a callback from an internal admin panel.

URL parameters and reflected input 785

  • Craft a URL with a malicious iconURL parameter against the icon.jsp endpoint and check for reflection into an HTML attribute.
  • Enter a name in a form that echoes it back and try a simple script payload.
  • Open a site in a private window to appear as a new user and put a payload in the URL parameter shown in the compliance popup.
  • Put a crafted value in style or button-bg-color parameters and open the URL in old Internet Explorer.

DOM sinks and client-side rendering 549

  • Craft a fake AJAX response whose text contains a script field and pass it to the error handler to see if eval runs it.
  • Put a path traversal and a callback parameter in a tags parameter that is sent as an XHR and check whether the response is executed as JavaScript.
  • Test feedback pages for DOM-based script execution and check whether the same client-side code is reused on other pages of the sub-site.
  • Add a canvas, have a privileged extension call makeXRCompatible() on its WebGL context, then call makeXRCompatible() on the same context from the page before the GPU check finishes and walk the returned promise's prototype chain.

Stored content and page editing 413

  • Paste an HTML form into a note and publish it, then check whether the preview renders a working form that submits credentials elsewhere.
  • Paste attacker-crafted HTML into a rich text editor's paste handler and check whether the editor keeps event handlers or script when the content is saved or re-rendered.
  • Store markup in a user-controlled field and view it as another user.
  • Submit input containing script and check whether it is stored and executed for other users.

CMS input fields and parameters 313

  • Test CMS input fields and parameters for reflected and stored script execution across versions.
  • Craft a link with parameters to the bulk product editing page and check whether they are reflected unencoded.
  • Put markup with an event handler into a product name, then view that product name wherever the app echoes it back (question edit, importer list, filter) and check whether it is interpreted.
  • Create a product with a crafted name, post content against it, then delete the product so it is out of store and reopen the leftover content in the admin to see if the name still renders unsanitised.

Bypasses and variations

All 743
  • Break out of the surrounding attribute and inject an SVG element with an onload handler.
  • Chain a login CSRF so the victim is signed into the attacker's account and the self-XSS becomes reachable.
  • Encoding tricks such as base64, HTML entities and double URL encoding got payloads past WAFs.
  • The endpoint's Content Security Policy allowed a wildcard script host and lacked a base-uri directive, so injected markup could load attacker-controlled scripts on a mobile JavaScript endpoint.
  • A cross-origin iframe can bypass same-origin policy by opening a javascript: URL in a new window when multiwindow support is disabled.
  • A strict Content-Security-Policy blocked script execution in modern browsers, leaving only HTML injection.

Typical fixes

All 476
  • Apply context-appropriate output encoding for HTML, attribute and JavaScript contexts.
  • Sanitise uploaded files and serve them with a safe content type or force download.
  • 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.
  • Properly encode and validate user-supplied input reflected in URLs.
  • Encode name fields before inserting them into email templates.
  • Encode user input before reflecting it into HTML responses.

Start here: a reading path

Open the path

Clear reports in order, easiest first.

Guides and techniques

View all

The best explainers, cheat sheets and technique posts on XSS, from around the web.

Newest reports

All 6,399

Most recently disclosed.

New XSS reports by email

Follow XSS and get each week's new disclosures in one short email.

Free. New reports for what you follow, weekly by default. One-click unsubscribe. Privacy