bWAPP - Cross Site Scripting Stored (User-Agent)

bWAPP – Cross Site Scripting Stored (User-Agent)

In this walk through, we will be going through the Cross Site Scripting Stored (User-Agent) vulnerability section from bWAPP Labs. We will be exploring and exploiting Stored Cross Scripting vulnerability in Stored User Agent header field and learn how application are affected because of it. So, let’s get started with the Hacking without any delay.

Cross Site Scripting Stored (User-Agent)

Security: Low

  • Setting the security level to Low.

Security level Low

  • The application page here displays the logged in user’s User Agent and save it in the database. It displays the user-agent saved in the DB by issuing a GET request to the xss_stored_4.php file.

XSS - Stored (User-Agent)

Burpsuite intercept

  • As we can see the the page is storing the User-Agent in the DOM.

Page source code


  • I intercepted the request via Burpsuite and changed the User-Agent to the below payload. Forwarding the request and turning the intercept to OFF gives us our pop-up alert.

<img src=x onerror=alert("Hacked")>;


Hacked pop up alert

Security: Medium

  • Setting the security level to Medium.

Security level Medium

  • I intercepted the request and used the below payload to generate the pop-up alert.

<img src=x onerror=alert(1)>;


XSS pop up alert

Security: High

  • Setting the security level to High.

Security level High

  • Not working in the high level due to HTML addlashes and entities

<img src=x onerror=alert(1)>;

Burpsuite intercept

Payload Stored

Also Read: bWAPP – Cross Site Scripting Stored (Change Secret)



So, we finally completed all the security levels for the bWAPP Cross Site Scripting Stored (User-Agent) Vulnerability. We looked into the various ways how application has been set up in various levels and how we can bypass the security controls implemented. Stored-XSS attacks can be mitigated by performing input sanitization on endpoints, whitelist the allowed characters in the input and using a WAF. Along with that, we can prevent data from any untrusted source to be dynamically written to the HTML document. On that note, i will take your leave and will meet you in next one with another bWAPP vulnerability writeup, till then “Keep Hacking”.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top