This lab uses CSP and AngularJS.
To solve the lab, perform a attack that bypasses CSP, escapes the AngularJS sandbox, and alerts document.cookie
.
After accessing the lab, I intercepted the search request and sent it to the Burp Suite repeater for analysis:
In the response, I noticed that my input was being reflected. However, standard XSS payloads wouldn't work due to the web application's Content Security Policy (CSP) and the presence of a sandbox. Therefore, I decided to test some AngularJS CSP bypass payloads from the XSS by PortSwigger.
First, I tried injecting this payload:
But I encountered an error:
This indicated that my payload couldn't exceed 80 characters in length. I moved to a shorter payload:
To meet the lab's requirement of alerting document.cookie
, I modified the payload. Additionally, since the ng-focus
attribute requires the input to be focused, and this payload lacked the autofocus
attribute, I needed to manually focus on the input tag.
Here is the modified payload:
now this payload hopefully going to work so i will go to the exploit server where iw ill be hosting my malicious HTML page which will be having my final payload so whenever the victim visits it the exploit gets triggered.
Building the malicious html page payload:
To trigger the exploit, I used the exploit server to host a malicious HTML page containing the payload. When the victim visits this page, they will be redirected to the lab page with the AngularJS CSP bypass payload, which will trigger the XSS.
Here's the HTML page with the payload with the #x
at the end of the URL which focuses on the input tag with the id
of x
, triggering the ng-focus
event.:
To ensure the payload is properly handled, I URL-encoded it:
Finally, I stored the HTML page code on the exploit server and delivered it to the victim by pressing the "Deliver exploit to victim" button. This successfully bypassed the CSP, triggered the XSS, and solved the lab.