Vulnerability Exploitation playbook is third in the four-part tutorial series for the Azure WAF protection and detection lab. The purpose of the Azure WAF security protection lab is to demonstrate Azure WAF's capabilities in identifying and protecting against suspicious activities and potential attacks against your web applications. This playbook explains how to test Azure WAF's protections against a Cross Site Scripting (XSS) attack with emphasis on Azure WAF protection ruleset and logging capabilities. The lab does not include advanced application security concepts and is not intended to be a reference for application security testing as these areas are broader than the use cases demonstrated herein.
This playbook demonstrates the protection capabilities of Azure WAF against a simulated Server Side XSS injection (Stored XSS) attack from common, real-world, publicly available hacking and attack tools.
In this tutorial you will:
To inject the POC XSS exploit code in the OWASP Juice Shop application, we will connect to the Kali VM with RDP. Once connected, we will use Burp Suite (Community Edition), a powerful web application security research and analysis tool which is bundled in the Kali Linux distro. In this playbook, we will be using Burp Suite to inspect application requests and responses to understand what happens when injecting the POC XSS payload in the target web application is different scenarios.
Burp Suite works as a client-side proxy and your web browser should point to Burp's Proxy Listener so, it can intercept requests and responses.
Figure 1 - Launch Burp Suite
Figure 2 - Launch Burp Suite
a. http://owaspdirect-<deployment guid>.azurewebsites.net
b. http://juiceshopthruazwaf.com/
a. http://owaspdirect-<deployment guid>.azurewebsites.net/socket.io/
b. http://juiceshopthruazwaf.com/socket.io/
! IMPORTANT: For the scenarios demonstrated in this document, OWASP Juice Shop application was running on HTTP port 3000. This is not the case when you use the Azure WAF Attack Testing Lab Deployment Template as it configures the application to run on port 80, 443 and assigns it a URL. For the lab tutorials, you will connect to the application on HTTP port 80 only. The URL for the application will be http://owaspdirect-<deployment guid>.azurewebsites.net. <deployment guid> is unique to every deployment
After collecting and analyzing web application specific data from the various recon activities to detect vulnerabilities, an attacker can then successfully exploit the identified vulnerabilities with the intent to compromise a user or the application itself to elevate privileges. In this playbook, we will simulate a Cross Site Scripting (XSS) attack against the target application using a proof of concept (POC) exploit payload.
In this tutorial, you will perform a Server Side Cross Site Scripting (XSS) attack against the OWASP Juice Shop application two times.
! IMPORTANT: For the scenarios demonstrated in this document, OWASP Juice Shop application was running on HTTP port 3000. This is not the case when you use the Azure WAF Attack Testing Lab Deployment Template as it configures the application to run on port 80, 443 and assigns it a URL. For the lab tutorials, you will connect to the application on HTTP port 80 only. The URL for the application will be http://owaspdirect-<deployment guid>.azurewebsites.net. <deployment guid> is unique to every deployment
<iframe src="x-javascript:alert(`xss`)">
Raw Request and Response - Headers and Body
Request |
Response |
POST /api/Feedbacks/ HTTP/1.1 Host: juiceshopdirect.com:3000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://juiceshopdirect.com:3000/ Content-Type: application/json Content-Length: 105 Cookie: io=LsYFH7-IUxnCTaU5AAAW; language=en; welcomebanner_status=dismiss; cookieconsent_status=dismiss Connection: close
{"captchaId":7,"captcha":"3","comment":"<iframe src=\"javascript:alert(`xss`)\"> (anonymous)","rating":3} |
HTTP/1.1 201 Created Access-Control-Allow-Origin: * X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Feature-Policy: payment 'self' Location: /api/Feedbacks/11 Content-Type: application/json; charset=utf-8 Content-Length: 205 ETag: W/"cd-jaYV3gaD4F+1IP1EkEdoiAcNqfQ" Vary: Accept-Encoding Date: Sat, 10 Oct 2020 23:51:52 GMT Connection: close
{"status":"success","data":{"id":11,"comment":"<iframe src=\"javascript:alert(`xss`)\"> (anonymous)","rating":3,"updatedAt":"2020-10-10T23:51:52.834Z","createdAt":"2020-10-10T23:51:52.834Z","UserId":null}} |
We will now attempt to perform the injection of the same XSS payload in the Customer Feedback form on the Juice Shop website when going through Azure WAF on Application Gateway.
<iframe src="x-javascript:alert(`xss`)">
6. Upon clicking Submit, you will observe that the thank you message does not show up this time
7. Switching back to Burp, we can see the following request and response for the Feedback that we submitted in Step 5 above
Figure 1 – Request with XSS Payload in Burp Suite
Figure 2 – 403 Forbidden Response from Application Gateway in Burp Suite
Raw Request and Response - Headers and Body
Request |
Response |
POST /api/Feedbacks/ HTTP/1.1 Host: juiceshopthruazwaf.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://juiceshopthruazwaf.com/ Content-Type: application/json Content-Length: 107 Cookie: io=ygD2rhS_-3S5-Q_vAAF2; language=en; welcomebanner_status=dismiss; cookieconsent_status=dismiss Connection: close
{"captchaId":14,"captcha":"-6","comment":"<iframe src=\"javascript:alert(`xss`)\"> (anonymous)","rating":3} |
HTTP/1.1 403 Forbidden Server: Microsoft-Azure-Application-Gateway/v2 Date: Sun, 11 Oct 2020 02:26:32 GMT Content-Type: text/html Content-Length: 179 Connection: close
<html> <head><title>403 Forbidden</title></head> <body> <center><h1>403 Forbidden</h1></center> <hr><center>Microsoft-Azure-Application-Gateway/v2</center> </body> </html> |
Upon reviewing the HTTP requests and responses for the two attempts to inject POC XSS payload to the same instance of the Juice Shop application, we see the pattern as shown in the below table. This clearly indicates that the malicious XSS payload which could otherwise be stored in the application is not allowed through by Azure WAF.
XSS Exploitation Route |
Success |
Direct |
Yes |
Through WAF |
No |
Now let us use the Azure Monitor Workbook for WAF to understand how the WAF handled traffic with the XSS payload. This workbook visualizes security relevant WAF events across several filterable panels. It works with all WAF types, including Application Gateway, Front Door, and CDN, and can be filtered based on WAF type or a specific WAF instance.
Click here to deploy Azure Monitor Workbook for WAF to your subscription in Azure.
a. WAF actions filter
b. Top 40 Blocked Request URI addresses, filter to single URI address
c. Top 50 event trigger, filter by rule name
d. Message, full details
Note: For a detailed overview of these sections of the WAF workbook, please refer to the Overview of the Workbook Sections in the previous tutorial, Reconnaissance Playbook
Rule |
count_ |
Remote Command Execution: Unix Shell Expression Found |
1 |
XSS Attack Detected via libinjection |
1 |
XSS Filter - Category 4: Javascript URI Vector |
1 |
NoScript XSS InjectionChecker: HTML Injection |
1 |
NoScript XSS InjectionChecker: Attribute Injection |
1 |
IE XSS Filters - Attack Detected. |
1 |
XSS Filter - Category 5: Disallowed HTML Attributes |
1 |
Possible XSS Attack Detected - HTML Tag Handler |
1 |
SQL Injection Attack: SQL Tautology Detected. |
1 |
Detects basic SQL authentication bypass attempts 3/3 |
1 |
Restricted SQL Character Anomaly Detection (args): # of special characters exceeded (12) |
1 |
Cross Site Scripting (XSS) is one of the most common type of application security vulnerability and an external adversary can easily exploit a vulnerable application to compromise the application and its users to elevate their privileges.
For web applications secured with it, Azure WAF can protect against XSS attacks by detecting and blocking XSS payload at the network edge, with its out of the box ruleset.
Previous: Reconnaissance Playbook |
Next: Data Disclosure and Exfiltration Playbook |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.