Skip to content
CORS Disclosed report Advanced

Lack of CSRF header validation at https://g-mail.grammarly.com/profile

The CORS configuration on g-mail.grammarly.com accepted any subdomain over HTTP as a trusted origin, and the profile endpoint did not validate a CSRF token. An attacker who can perform a man-in-the-middle attack could read the victim's email and subscription settings and change those settings.

orlserg Follow

Originally disclosed on HackerOne

Medium 4.2 View original
  • Triaged in 10 hours
  • Fixed in 2 months
  • Paid in 32 hours
  • Disclosed after 4 months

Hello!

Description

I found that setting up a CORS in some places will check the protocol, but it allows using http scheme. In addition, any subdomain is considered trusted. If the origin is http://www.grammarly.com, then the server will respond: Access-Control-Allow-Origin: http://www.grammarly.com. That can lead to leakage of user data and unauthorized actions on behalf of the user.

burp.png
burp.png From the original on HackerOne

In fact, this means that an attacker can use the MITM attack (Wi-Fi, local networks, etc.) to substitute client requests, thus replacing the origin.

####Important note: I very carefully read the program policy and focus on the fact that MITM attack is not made on the existent grammarly sites.

How it works

CORS.png
CORS.png From the original on HackerOne

If an attacker can perform a mitm attack on a user, he can replace the requested content of any unencrypted request and produce a 302 redirect of the user to http: //evil.grammarly.com. Since the request is not unencrypted, the attacker can also replace the response and implement javascript that performs a requests to vulnerable endpoints. Thus, the vulnerable enpoint will think that the request came from the origin of the trust it trusts and will execute the request.

Using a header to send a CSRF token protects against such attacks. But I found a place where verification of the transferred token is not performed.

This vulnerability was perfectly described by James Kettle on OWASP AppSec EU 2017. You can watch the description of the vulnerability on the link to his presentation. https://youtu.be/wgkj4ZgxI4c?t=1139

Vulnerable enpoints

  1. The malicious javascript will look like:
JavaScript
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       document.getElementById("response-node").innerHTML = this.responseText;
   }
};
xhttp.open("GET", "https://g-mail.grammarly.com/profile", true);
xhttp.withCredentials = true;
xhttp.send();

The response will contain the user's email address and subscription settings:

{"id":749327815,"email":"[email protected]","preferenceFields":[{"name":"Weekly Progress Reports","description":"Get a weekly report with statistics and insights on how you are writing with Grammarly.","order":49,"value":true},{"name":"Product Updates","description":"Important info on new features and products. We may also ask for your feedback on occasion.","order":50,"value":true},{"name":"Grammarly Offers","description":"These emails may include special upgrade offers, limited-time events, or coupons. ","order":50,"value":true},{"name":"The Grammarly Blog","description":"A weekly newsletter that includes fun tips on all things writing.","order":50,"value":true},{"name":"Grammarly Business","description":"Updates and information on our products for multi-person teams.","order":55,"value":true}],"unsubscribe":false}
  1. The malicious javascript will look like:
JavaScript
var xhttp = new XMLHttpRequest();
var data = new FormData();
data.append("email", "████████");
data.append("unsubscribe", "false");
(...)
xhttp.open("POST", "https://g-mail.grammarly.com/profile", true);
xhttp.withCredentials = true;
xhttp.send(data);

The request will change the subscription settings. It looks like CSRF.

Now I'm trying to find more places to increase the impact.

Impact

CORS misconfiguration lead to leakage of user data and unauthorized actions on behalf of the user.

The original report as published on HackerOne, by orlserg. 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 CORS policy reflected any subdomain origin without requiring HTTPS, and the profile endpoint did not verify a CSRF token.

Impact

An attacker who can intercept traffic could read a user's email and subscription preferences and change those settings; the report notes that the man-in-the-middle attack is not performed against existing Grammarly sites.

What the attacker needed

Attacker can perform a MITM attack; victim uses an unencrypted connection

How it was found

  1. Perform a man-in-the-middle attack on the user's unencrypted traffic.
  2. Replace the requested content and redirect the user to an HTTP subdomain.
  3. Serve JavaScript that sends a credentialed request to the profile endpoint.
  4. Read the response containing the user's email and subscription settings.
  5. Send a POST request to change the subscription settings.

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 subdomain, even over plain HTTP, so someone who can tamper with an insecure connection could make the browser treat a malicious page as trusted. The profile page also did not check a CSRF token, a secret value meant to prove a request came from the real site, so the attacker could read and change account settings.

What is CORS?

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

More from Superhuman (formerly Grammarly)

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.