An open API service indexing awesome lists of open source software.

https://github.com/qeeqbox/dom-based-cross-site-scripting

A threat actor may inject malicious content into webapp. The payload is not reflected in the HTTP request and response, then executed in the victim's browser
https://github.com/qeeqbox/dom-based-cross-site-scripting

cross dom example infosecsimplified metadata qeeqbox scripting site vulnerability xss xss-vulnerability

Last synced: 3 months ago
JSON representation

A threat actor may inject malicious content into webapp. The payload is not reflected in the HTTP request and response, then executed in the victim's browser

Awesome Lists containing this project

README

          

An application enables users to control the Document Object Model (DOM) environment. A threat actor can exploit this feature by injecting a malicious payload into a trusted web application. When users interact with this malicious payload, their browsers execute it. This vulnerability is not reflected in the HTTP request or response and occurs on the client side.

Clone this current repo recursively
```sh
git clone --recurse-submodules https://github.com/qeeqbox/dom-based-cross-site-scripting
```
Run the webapp using Python
```sh
python3 dom-based-cross-site-scripting/vulnerable-web-app/webapp.py
```
Open the webapp in your browser 127.0.0.1:5142


Right-click on the page and click on View Page source, the page source will show the static content, one of the contents is JavaScript that handles the fragment identifier (# symbol) in the URL, which is meant to move users into specific sections of the page


If you type the URL + #test, it will take you to the test section, it does not exist but the test keyword gets embedded in the page


A threat actor could embed a malicious payload and send it to a victim using social engineering attacks. If the victim falls for it, their browser will execute a malicious payload

## Code
This logic will check the current URL for fragment identifiers. If # is part of the URL, it will pass it to the flash_message() function
```js
jQuery(document).ready(function($) {
if (window.location.hash) {
let hash_value = window.location.hash.substring(1);
flash_message(`Moving to ${decodeURIComponent(hash_value)} section`)
}
});
```
The flash_message() function embeds the user-controlled input directly into a div box without sanitizing it
```py
function flash_message(msg) {
$("#error-dialog-box").html(msg)
$("#error-dialog-box").dialog("open");
}
```