ModSecurity Trustwave

Cross-site Scripting (XSS) Evasion Challenge

The purpose of this challenge is to show possible XSS defenses by using ModSecurity and to identify any weaknesses.

Challenge Setup

The form on this page is vulnerable to reflected XSS. Data passed within the test parameter (either GET or POST) will be reflected back to this same page without any output encoding/escaping.

XSS Defense #1: Inbound Blacklist Regex Filters

We updates/added XSS filters from the following 3rd party sources:

XSS Defense #2: JS Sandbox Injection

This defensive layer uses ModSecurity's Data Modification capability (@rsub operator) to insert Gareth Heyes' (@garethheyes) JS Sandbox called MentalJS to the beginning of html responses.
It is important to understand what a JS sandbox is and how it works. You may be able to execute JS code however it is in a sandboxed environment. For example - preventing a JS alert popup box is not the goal here but rather protecting DOM elements from being accessed.
A separate MentalJS Smoketest is located here

XSS Defense #3: DOMPurify Injection

This defensive layer uses ModSecurity's Data Modification capability (@rsub operator) to insert Mario Heiderich (@0x6D6172696F) DOMPurify Code to the beginning of html responses.
A separate DOMPurify Smoketest is located here.

Challenge Goals

You must develop a single XSS payload that achieves BOTH of the following:

1. Filter Evasion

You must execute a reflected XSS attack accessing one of the DOM elements listed below WITHOUT triggering an XSS filter alert. XSS Fitler Alerts will be displayed below.

2. Execute JS and Access DOM Elements

You must either: 1) Bypass the MentalJS JS Sandbox protections, or 2) Bypass the DOMPurify filtering and successfully execute a reflected XSS attack that executes JS code in your browser. A successful attack will be able to access one of the following DOM elements:
  1. Trigger the youWon JS function
  2. Access document.location that is not undefined or sandboxed
  3. Access document.cookie that is not undefined or sandboxed
You may toggle On/Off the defenses by checking the box in the form below. This includes disable the MentalJS Sandbox/DOMPurify injection and also will add the X-XSS-Protection: 0 response header to temporarily disable any browser side XSS filtering. This will help to facilitate testing of working XSS payloads.

Challenge Submission

If you are successful, please notify us at any of the following places:

- security@modsecurity.org

- @ModSecurity on Twitter

- OWASP ModSecurity Core Rule Set Mail-list

- Report to GitHub Issues

Prizes

Each winner will receive a free copy of The Web Application Defender's Cookbook: Battling Hackers and Protecting Users

Web Application Defender's Cookbook

XSS Evasion Challenge Form/Results

XSS Filter Results (txn: U1Sfs8Co8AoAAEJ94vwAAAAW)

MOD_MSG

Last Data Submitted (is unescaped):

(none)



 method=GET enctype=application/x-www-form-urlencoded
 
Submit to GitHub Issues

Challenge Winners

  • TBD
  • TBD
  • TBD
  • TBD

Recent Attacks Submitted:

Client IP: 103.14.61.146 ()
Payload: ?%00";><script>alert(document.domain)</script>

Client IP: 103.14.61.146 ()
Payload: ?%00";><script>alert(document.domain);</script>

Client IP: 103.14.61.146 ()
Payload: iframe src=""srcdoc="<script>alert('Bypass message')</script>"

Client IP: 103.14.61.146 ()
Payload: <script>+-+-1-+-+alert(1)</script>

Client IP: 103.14.61.146 ()
Payload: <script>~'\u0061' ; \u0074\u0068\u0072\u006F\u0077 ~ \u0074\u0068\u0069\u0073. \u0061\u006C\u0065\u0072\u0074(~'\u0061')</script U+

Client IP: 103.14.61.146 ()
Payload: http://www.<script>alert(1)</script .com

Client IP: 103.14.61.146 ()
Payload: <script>alert('test');</script>

Client IP: 103.14.61.146 ()
Payload: <%<!--'%><script>alert(1);</script -->

Client IP: 84.82.221.58 (Netherlands)
Payload: <script> alert('hello'); </script>

Client IP: 114.246.124.26 (China)
Payload: (none)<script></script>

Client IP: 62.140.132.48 (Netherlands)
Payload: <script> alert('hello'); </script>

Client IP: 80.192.74.178 (United Kingdom)
Payload: '//>

Client IP: 80.192.74.178 (United Kingdom)
Payload: '//>

Client IP: 80.192.74.178 (United Kingdom)
Payload: '//>

Client IP: 80.192.74.178 (United Kingdom)
Payload: '//>