XSS Cheat Sheet (Basic)

Introduction

Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into websites. There is 3 types of XSS Attack:

  • Reflected XSS

    Attack where the malicious script runs from another website through the web browser

  • Stored XSS

    Stored attacks are those where the injected script is permanently stored on the target servers

  • DOM-Based XSS

    A type of XSS that has payloads found in the DOM rather than within the HTML code.

Also a regularly updated cheatsheet of XSS by PortSwigger

A tip would be to simple copy all the payloads {All tags -> All Events -> All Browsers} and run in Intruder

Where to find

This vulnerability can appear in all features of the application. If you want to find Dom-based XSS, you can find it by reading the javascript source code.

How to exploit

  1. Basic payload

  1. Add ' or " to escape the payload from value of an HTML tag

  • Example source code

  • After input the payload

  1. Add --> to escape the payload if input lands in HTML comments.

  • Example source code

  • After input the payload

  1. Add when the input inside or between opening/closing tags, tag can be <a>,<title>,<script> and any other HTML tags

  • Example source code

  • After input the payload

  1. Use when input inside an attribute’s value of an HTML tag but > is filtered

  • Example source code

  • After input the payload

  1. Use when input inside <script> tags

  • Example source code

  • After input the payload

XSS Cheat Sheet (Advanced)

  1. Use when input lands in a script block, inside a string delimited value.

  • Example source code

  • After input the payload

  1. Same like Number 7. But inside a string delimited value but quotes are escaped by a backslash.

  • Example source code

  • If we input payload '-alert(1)-' it will be like this

The quotes are escaped by a backslash so we need to bypass them

  • After input the payload

  1. Use when there’s multi reflection in the same line of JS code

  • Example source code

  • After input the payload

  1. Use when input inside a string delimited value and inside a single logical block like function or conditional (if, else, etc).

  • Example source code

  • After input the payload

Payload number 2 uses when quote escaped by backslash

  1. Use when input lands inside backticks delimited strings

  • Example source code

  • After input the payload

  1. Uses when there is multiple reflections on same page. (Double Reflection)

  • After input the payload

  1. Uses when there is multiple reflections on same page. (Triple Reflection)

  • After input the payload

  1. XSS in filename (File Upload) Use when uploaded filename is reflected somewhere in target page

  1. XSS in metadata (File Upload) Use when uploaded metada is reflected somewhere in target page (using exiftool)

  1. XSS with SVG file (File Upload)

  1. XSS via markdown

  1. XSS in XML page

Add a "-->" to payload if input lands in a comment section

Add a "]]>" if input lands in a CDATA section

XSS Cheat Sheet (Bypass)

  1. Mixed Case

  1. Unclosed Tags

  1. Uppercase Payloads

  1. Encoded XSS

  1. JS Lowercased Input

  1. PHP Email Validation Bypass

  1. PHP URL Validation Bypass

  1. Inside Comments Bypass

Bypass WAF

  1. Cloudflare

  1. Cloudfront

  1. Cloudbric

  1. Comodo WAF

  1. ModSecurity

  1. Imperva

  1. AWS

If you want to see the other payload for other WAF, check this link

References

Last updated