Java - XSS-Stored
Last updated
Last updated
Now that the app is running let's go hacking!
The application home page shows links to different pages.
By clicking in one of the links and on the Edit button,the application shows an input field box were we can try our injections.
Lets first inject a normal test string and see how our input is used in the application.
Now, clicking on save, the page content is updated.
In the source of the application we can see that this application will take the user input and save the page updates in the database. Thereafter, the page is reloaded and the new information is displayed via template variable.
Controller
HTML Template
The variable is then used in the index.html to display the content supplied by the user. But as you can see the tag being used is th:utext which means is not being escaped by the thymeleaf template engine . This indicates that is should be possible to perform a Cross Site Scripting (XSS) injection.
Now we have seen where the user input is stored in the database and reflected in the application we will have to look what dangerous HTML characters are not properly escaped so we can build our XSS payload. So for our first check we use the following string as an input:
The application automatically reloads the page with a redirection. Let's see how the payload is loaded in the HTTP response:
As you can see the application did not encode or blacklisted any of the dangerous HTML characters. Now lets try the XSS payload to see if this also is reflected back withouth any escaping or blacklist filtering.
Again the application is not encoding or blacklisted any of the dangerous HTML characters. This payload seems to work in the intercepting proxy. Now lets try it in our browser.
We can see the XSS alert pop-up and we have successfully performed the XSS attack.
Please refer to the OWASP testing guide for a full complete description about cross site scripting!