Tips

Cross-site scripting (XSS) tips

Cross-site scripting runs an attacker’s JavaScript in another user’s session, so it can read their data or act as them. Reflected, stored and DOM-based variants all come down to input reaching the page without the right encoding for where it lands.

Published tips, newest first. Payloads and commands are shown as plain text.

  • 🔧 Tool of the day: ppmap

    Client-side prototype pollution → XSS: 1⃣ heuristic scan for PP 2⃣ fingerprints known gadgets 3⃣ prints the XSS payload Ever found PP in the wild? 👇 https://github.com/kleiton0x00/ppmap #bugbounty #bugbountytips #infosec #cybersecurity #xss #pentesting

    Cross-site scripting (XSS)Tooling

  • 🦊 Tool: dalfox

    Parameter analysis + XSS scanning in one tool: cat urls.txt | dalfox pipe https://t.co/tIZZjdAQAE #bugbounty #xss #bugbountytips

    Cross-site scripting (XSS)Tooling

  • Test API docs for XSS

    When testing an API, look for API documentation pages that may be vulnerable to XSS. Check if the page uses template strings to build HTML, with values from the OpenAPI spec dropped inside, such as content="${something}" or <title>${something}</title>. Try setting the description

    Cross-site scripting (XSS)Discovery

    1 upvote

  • Test template fields for stored XSS

    Test template fields for stored cross-site scripting by submitting content with HTML markup, such as a link or text with angle brackets, and checking if it is executed in the context of a higher-privileged viewer. Try storing a template that contains angle brackets <> and confirm

    Cross-site scripting (XSS)Discovery

  • Bypass regex with global flag

    When a target uses a global regex (/g flag) to validate user input, try sending a large string with a disallowed character at the end to offset the lastIndex property. Then, send a second payload with the malicious input, which may be processed without being blocked by the regex.

    Cross-site scripting (XSS)Discovery

  • Test login redirects for XSS

    Try sending a Location header with a crafted link to target.com to see if it reflects and executes code. If the response redirects to a page that auto-submits a form, it may be vulnerable to XSS. Look for a response that executes code without requiring user interaction. You can…

    Cross-site scripting (XSS)Discovery

  • Test innerHTML sinks for DOM XSS

    Try injecting payloads in the location.search parameter to test for DOM XSS vulnerabilities in innerHTML sinks. This works because user-controlled input in the URL query string can be reflected in the page's DOM. To confirm, look for your payload being executed in the page's con…

    Cross-site scripting (XSS)Discovery

  • Test API doc renderers for XSS

    When testing API documentation tools, look for renderers that convert Markdown to HTML. Check if the renderer allows raw HTML in the input by searching for html: true in the code. Then, verify if the HTML output is properly sanitized. If not, it may be possible to inject malicio…

    Cross-site scripting (XSS)Discovery

  • Test for DOMPurify bypasses

    When a target uses DOMPurify for sanitization, look for custom hooks that may introduce vulnerabilities. Check the uponSanitizeAttribute, uponSanitizeElement, and afterSanitizeAttributes hooks for potential bypasses. Test for namespace confusion and attribute smuggling by inject…

    Cross-site scripting (XSS)Discovery

  • Test Blob URLs for origin recovery

    When a web application uses Blob URLs, test if you can recover the origin by copying and pasting the URL into a new tab. If the window.origin changes from 'null' to the application's origin, you may be able to execute arbitrary JavaScript on that origin. To automate this, use Ja…

    Cross-site scripting (XSS)Exploitation

  • Basecamp -> Cross-Account Stored XSS -> Admin Takeover (High)

    How -> 1. Collaborator hides HTML in an attachment attribute 2. Admin opens the edit form, editor normalizes it 3. Legacy code writes attacker HTML via innerHTML Fix -> sanitize after normalizing #bugbountytips pic.tw…

    Cross-site scripting (XSS)Exploitation

    1 upvote

Cross-site scripting (XSS): how to hunt it

Where to look

  • Every parameter, header and path segment that comes back in the response, and where it lands: HTML, an attribute, a script or a URL.
  • Client-side sinks such as innerHTML, document.write and location, fed by the URL fragment, postMessage or storage.
  • Rich text, Markdown, SVG and file names that are stored and shown to other users.
  • Filters and sanitisers you can get around with another context, another encoding or a parser difference.

What proves it

Show script running in the target’s origin on a test account of your own, such as reading a value only that user can see, say who sees the payload, and keep stored payloads harmless.

Read further

Writeups on Cross-site scripting (XSS), by hunters and researchers, most with a short summary.

Related classes