Clear Byte

Cross-Site Scripting (XSS)

Types of XSS

Stored XSS

Stored XSS happens when user input is stored on a server and retrieved unsafely. When an application accepts user input without validation, stores it in its servers, and then renders it on users' browser without sanitization, malicious JS code can make its way into the database and then to the victims browser.

Blind XSS

Blind XSS vulnerabilities are stored XSS vulnerabilities whose malicious input is stored by the server and executed in another part of the application or in another application you cannot see.

Reflected XSS

Reflected XSS vulnerabilities happen when user input is returned to the user without being stored in a database. The application takes in user input, processes it server-side, and immediately returns it to the user.

DOM-Based XSS

DOM-based XSS is similar to reflected XSS, except that in DOM-based XSS, the user input never leaves the user's browsers. In DOM-based XSS, the application takes in user input, processes it on the victim's browsers, and then returns it to the user.

Self-XSS

Self-XS attacks require victims to input a malicious payload themselves. To perform these, attackers must trick users into doing much more than simply viewing a page or browsing a particular URL.

Hunting for XSS

  1. Look for user input opportunities on the application. When user input is stored and used to construct a web page later, test the input field for stored XSS. If user input in a URL gets reflected back on the resulting web page, test for reflected and DOM XSS.
  2. Insert XSS payloads into the user input fields you've found. Insert payloads from lists online, a polyglot payload, or a generic test string.
  3. Confirm the impact of the payload by checking whether your browser runs your JavaScript code. Or in the case of a blind XSS, see if you can make the victim browser generate a request to your server.
  4. If you can't get any payloads to execute, try bypassing XSS protections.
  5. Automate the XSS hunting process with techniques.
  6. Consider the impact of the XSS you've found: who does it target? How many users can it affect? And what can you achieve with it? Can you escalate the attack by using what you've found?

Bypassing XSS Protection

  • Alternative JavaScript Syntax
  • Capitalization and Encoding
  • Filter Logic Errors

On this page