"More on Wikipedia" link disclose "Referrer" and leak `window.opener` reference for arbitrary websites
The Grammarly browser extension's 'More on Wikipedia' link uses an HTTP URL, which allows a man-in-the-middle attacker to intercept the Referer header and obtain a window.opener reference to the originating page. This could leak sensitive tokens in URLs and enable exploitation of window.opener-dependent vulnerabilities on arbitrary websites.
- Triaged in 5 days
- Fixed in 46 days
- Paid in 12 days
- Disclosed after 7 months
Summary:
"Referrer" leak
http:// link to Wikipedia transferring Referrer header allows a remote attacker with MITM access to sniff Referrer URL for important tokens after following "More on Wikipedia" link.
Controllable page [MITM] with window.opener pointing to the navigation-initiated webpage
http:// link "More on Wikipedia" allows a remote attacker with MITM access to obtain a window.openerreference to the website initiating new window opening.
Description:
Grammarly extension shows a card with a meaning of the currently focused word on dblclick.
Some of these cards have "More on Wikipedia" link depending on the selected word. (e.g., AFAIR "our" word).
"More on Wikipedia" link is an HTTP link that discloses referrer and opener to the Wikipedia.
Since it's an HTTP link, a remote attacker could use MITM attack to hijack "Referrer" and window.opener.
Browsers Verified In:
Chrome: 68.0.3440.106 Grammarly: 14.868.1844
Steps To Reproduce:
IMPORTANT: Luckily for Grammarly, Wikipedia enables HSTS for all further requests, so you'll need a clean browser to repro this vulnerability.
Referrer
- Setup MITM. e.g., by modifying
/etc/hosts:127.0.0.1 en.wikipedia.org. Make sure no HSTS enabled for Wikipedia. - Start
referrer-mitm.js - Go to an arbitrary webpage
- Find a
<grammarly-card>with "More on Wikipedia" link (e.g., "Our"/"Your" words should work) - Follow the link
- Alert on
http://en.wikipedia.orgwith referrer
window.opener hijacking
- Setup MITM. e.g., by modifying
/etc/hosts:127.0.0.1 en.wikipedia.org. Make sure no HSTS enabled for Wikipedia. - Start
opener-mitm.js - Go to an arbitrary webpage
- Find a
<grammarly-card>with "More on Wikipedia" link - Follow the link
window.openernavigates tohttps://github.com/Metnew/uxss-db
NOTE: You could play with #405056 to pwn websites that don't share window.opener by default. #409400 is also great.
Supporting Material/References:
- Exploits attached
Impact
Referrer
A remote attacker with a MITM access could sniff URL of the active webpage after user will follow "More on Wikipedia" link.
RESULT: #738 and #6884 show how leaked "Referrer" could lead to a leak of sensitive info (tokens in URLs, sensitive URL params, etc.).
The impact is the same, however, it spreads on all websites, ignoring their level of defence.
window.opener
Leaked window.opener allows exploiting vulnerabilities relying on window.opener such as #409400 and #405056 on arbitrary origins, ignoring the level of defense of the webpages.
RESULT: Attacker obtains access to previously unexploitable pages those don't share opener.
Summary
The vulnerability requires a particular (high) level of user assistance: not all cards have "More on Wikipedia" link + navigation required.
I hope I correctly estimated a CVSS v3 score (5.2): Low Integrity (
window.opener) + Low Confidentiality (Referrer may disclose sensitive info) + High attack complexity. However, the score may not reflect the actual severity as usual (sadly for me, it's much closer to "Low", because of HSTS on Wikipedia).
The vulnerability is interesting, mostly because of window.opener reference, but in very rare cases "Referrer" may become even a more powerful attack vector.
Context
Grammarly's browser extension shows a card with the meaning of the currently focused word when the user double-clicks it. Some of these cards include a "More on Wikipedia" link, depending on the selected word; the researcher notes that words such as "our" and "your" produce one. The link points at Wikipedia over plain http://: following it from an extension-rendered card sends a Referrer header and a live window.opener reference over an unencrypted connection, which an attacker with MITM access can intercept.
The report was filed against the Grammarly Browser Extensions asset and is classified as a violation of secure design principles, with low severity. The researcher's own CVSS v3 estimate was 5.2, combining low integrity impact (window.opener), low confidentiality impact (the referrer may disclose sensitive information) and high attack complexity, while noting that the real severity is closer to Low because Wikipedia serves HSTS.
Setup
The researcher verified the behaviour in:
| Component | Version |
|---|---|
| Chrome | 68.0.3440.106 |
| Grammarly | 14.868.1844 |
The attack requires a man-in-the-middle position, which the researcher simulates by editing the hosts file so that Wikipedia resolves locally:
[redacted] en.wikipedia.org
One precondition matters throughout: Wikipedia enables HSTS for all further requests, so a browser that has already seen Wikipedia over HTTPS will refuse to talk to it over HTTP. The researcher calls this out explicitly: you need a clean browser with no HSTS state for Wikipedia to reproduce the issue. Two small scripts, referrer-mitm.js and opener-mitm.js, are started on the attacker side; the report refers to them as attached exploits but does not reproduce their contents.
Finding it
The extension renders a <grammarly-card> element for the focused word. When that card contains the "More on Wikipedia" link, the link is an HTTP URL rather than HTTPS. Two consequences follow from that single design choice:
- The navigation sends a
Referrerheader over an unencrypted connection, so anyone on the path can read the URL of the page the user was on. - The new window is opened with a
window.openerreference back to the page that initiated the navigation, and because the destination is plain HTTP, an attacker with MITM access can obtain that reference.
Neither behaviour is a memory-safety bug or an injection in the usual sense; the extension is simply trusting the transport for a link it generates itself.
Exploitation
Step 1: prepare the MITM and clear HSTS
Point en.wikipedia.org at a host you control, as in the hosts entry above, and make sure the browser has no HSTS entry for Wikipedia. Without a clean browser profile the browser upgrades the request and the attack does not fire.
Step 2: serve the referrer-collecting page
Start referrer-mitm.js on the attacker host. The report does not include the script's source, only its role: it answers the HTTP request for http://en.wikipedia.org and surfaces the Referrer header it received.
Step 3: trigger the card
Visit an arbitrary webpage and double-click a word that produces a card with the "More on Wikipedia" link. According to the report, "Our" and "Your" work.
Step 4: follow the link
Click "More on Wikipedia". The extension opens the HTTP URL, and the request carries the referrer of the page the user was reading.
Step 5: read the referrer
The attacker page alerts the referrer it received on http://en.wikipedia.org. That value is the URL of the active webpage the user came from, which is exactly the leak: any token or sensitive parameter embedded in that URL travels with it.
Step 6: hijack window.opener
For the second variant, start opener-mitm.js instead, repeat the same navigation, and the attacker page uses the window.opener reference to navigate the originating page. In the demonstration, window.opener navigates to:
https://github.com/Metnew/uxss-db
The researcher adds a note that this primitive can be combined with the issues tracked as #405056 to attack websites that do not share window.opener by default, and that #409400 is also a good fit. Those references are to other reports; their contents are not reproduced here.
Root cause
The extension generates an http:// link to Wikipedia inside its card UI. Because the scheme is HTTP, two browser behaviours that are normally contained become exposed to the network:
- The
Referrerheader is sent in the clear, so a MITM can read the URL of the page the user was on. - The opened window keeps a
window.openerreference to the initiating page, and an attacker with MITM access can obtain that reference and use it to navigate the opener.
Wikipedia's HSTS policy is the reason a clean browser is needed: once the browser has learned it, the HTTP request is upgraded and the attack does not fire. The report frames the impact as spreading to all websites regardless of their level of defence, precisely because the weakness sits in the link the extension emits rather than in any particular destination.
Impact
Referrer
A remote attacker with MITM access can sniff the URL of the active webpage after the user follows the "More on Wikipedia" link. The researcher points to #738 and #6884 as demonstrations of how a leaked referrer can expose sensitive information such as tokens in URLs and sensitive URL parameters. The impact is the same as in those cases, but here it applies to all websites, ignoring their level of defence.
window.opener
The leaked window.opener allows exploiting vulnerabilities that rely on window.opener, such as #409400 and #405056, on arbitrary origins, again ignoring the level of defence of the pages involved. The attacker gains access to pages that were previously not exploitable because they do not share opener.
The vulnerability requires a high level of user assistance: not every card carries the "More on Wikipedia" link, and the user has to navigate through it. The researcher also notes that the window.opener reference is the more interesting part, though in very rare cases the referrer may become the more powerful attack vector.
Fix
The report does not describe a fix or a change made in response.
Variants to test
- Look for other extension-generated links to external sites that use
http://rather thanhttps://. A positive result is a request to the plain-HTTP host that carries aReferrerheader naming the page the user was on. - Check whether those links open in a new window that retains
window.opener. A positive result is an attacker-served page that can navigate the originating tab throughwindow.opener. - Test on a clean browser profile with no HSTS state for the destination, since HSTS silently masks the issue on profiles that have visited the site over HTTPS before.
- Try other words and card types to see how broadly the link appears; the report only confirms that some cards have it and that "Our" and "Your" work.
- Combine a controllable opener with known
window.opener-dependent issues such as the ones the report cites, to see whether origins that normally do not shareopenerbecome reachable.
What happened, in plain words
Grammarly is a writing assistant. It exists as a website and as a browser extension, which is a small program you install into your browser (Chrome, in this report) that adds features to the pages you visit. One of those features is a little pop-up card: when you double-click a word on any page, the extension shows a card explaining what that word means.
Some of those cards contain a link labelled "More on Wikipedia", which takes you to the Wikipedia article about the word. The problem the researcher found is that this link points at Wikipedia over plain http:// instead of the encrypted https://. Plain HTTP is like sending a postcard: anyone who handles it along the way can read it. HTTPS is like a sealed envelope: people can see it is going somewhere, but not what is inside.
Because the link is plain HTTP, two pieces of information that a browser normally keeps private can be seen or used by someone sitting on the network between you and Wikipedia. That someone is called a man-in-the-middle, or MITM: a person or device that can intercept and alter traffic on its way, for example on public Wi-Fi.
The two leaked things are:
- The
Referrerheader: a small note the browser attaches to a request saying "the user came here from this page". If the page you were reading had a secret in its address (a token, for example), that secret travels in the note. - The
window.openerreference: a handle that a newly opened window keeps to the window that opened it. Normally it lets a pop-up talk back to its parent, for example to refresh it. In the wrong hands, it lets the attacker's page steer the page you came from.
The report was filed against Grammarly's browser extensions, is classified as a violation of secure design principles (meaning the design itself is unsafe, not that a specific line of code has a memory bug), and is rated low severity. The researcher estimated a CVSS v3 score of 5.2, a standard way of scoring how serious a flaw is, combining low integrity impact, low confidentiality impact and high attack complexity, while noting the real severity is closer to Low because Wikipedia uses HSTS (explained below).
The setup
The researcher tested on these versions:
| Component | Version |
|---|---|
| Chrome | 68.0.3440.106 |
| Grammarly | 14.868.1844 |
To play the role of the attacker on the network, the researcher did not need to sit in a café. They simulated the interception on their own machine by editing the hosts file. The hosts file is a small text file on your computer that maps website names to addresses, like a personal phone book that the browser checks before asking the internet. Adding an entry there makes the browser believe a website lives at an address the researcher chooses.
[redacted] en.wikipedia.org
Line by line: [redacted] is the special address that always means "this computer". en.wikipedia.org is the English Wikipedia's name. Together, the line tells the browser: whenever I ask for English Wikipedia, do not go to the real internet, go to a program running on my own machine. That program is the attacker's stand-in for Wikipedia.
One precondition matters throughout. Wikipedia uses HSTS, which stands for HTTP Strict Transport Security. It is a rule a website can send to your browser saying "from now on, only ever talk to me over HTTPS, never plain HTTP". Once your browser has learned that rule, it silently upgrades any HTTP request to Wikipedia into HTTPS, and the attack cannot happen. That is why the researcher insists on a clean browser, one that has never visited Wikipedia before and so has not learned the rule yet.
Two small scripts, referrer-mitm.js and opener-mitm.js, run on the attacker side. The report calls them attached exploits but does not show their contents, so we only know their roles, described below.
Finding it
The extension draws a <grammarly-card> element, a piece of the page that the extension inserts, for the word you double-click. When that card contains the "More on Wikipedia" link, the link is an HTTP address rather than HTTPS. Two consequences follow from that one design choice:
- When you follow the link, your browser sends a
Referrerheader over an unencrypted connection, so anyone on the path can read the address of the page you were on. - The new window is opened with a
window.openerreference back to the page that started the navigation, and because the destination is plain HTTP, an attacker with MITM access can obtain that reference.
Neither behaviour is a memory-safety bug or an injection in the usual sense. The extension is simply trusting the transport for a link it generates itself.
Exploitation
Step 1: prepare the MITM and clear HSTS
Point en.wikipedia.org at a host you control, as in the hosts entry above, and make sure the browser has no HSTS entry for Wikipedia. Without a clean browser profile the browser upgrades the request and the attack does not fire. This step exists because the attacker must be the one answering when the browser asks for Wikipedia over HTTP.
Step 2: serve the referrer-collecting page
Start referrer-mitm.js on the attacker host. The report does not include the script's source, only its role: it answers the HTTP request for http://en.wikipedia.org and surfaces the Referrer header it received. Think of it as a fake receptionist who writes down every visitor's previous address before letting them in.
Step 3: trigger the card
Visit an arbitrary webpage and double-click a word that produces a card with the "More on Wikipedia" link. According to the report, "Our" and "Your" work. Not every word produces such a card, which is part of why the attack needs a lot of user help.
Step 4: follow the link
Click "More on Wikipedia". The extension opens the HTTP address, and the request carries the referrer of the page the user was reading. This is the moment the postcard is sent in the open.
Step 5: read the referrer
The attacker page alerts the referrer it received on http://en.wikipedia.org. That value is the address of the active webpage the user came from, which is exactly the leak: any token or sensitive parameter embedded in that address travels with it. A token here means a short secret string, often placed in a web address, that proves who you are or grants access, much like a coat-check ticket: whoever holds it can claim the item.
Step 6: hijack window.opener
For the second variant, start opener-mitm.js instead, repeat the same navigation, and the attacker page uses the window.opener reference to navigate the originating page. In the demonstration, window.opener navigates to:
https://github.com/Metnew/uxss-db
This is a single web address. The attacker's fake Wikipedia page tells the tab that opened it, the page you were reading, to go to that address. In the demo it is a GitHub page; the point is that the attacker's page can navigate the tab that opened it.
The researcher adds a note that this primitive can be combined with the issues tracked as #405056 to attack websites that do not share window.opener by default, and that #409400 is also a good fit. Those references are to other reports; their contents are not reproduced here.
Root cause
The extension generates an http:// link to Wikipedia inside its card interface. Because the scheme is HTTP, two browser behaviours that are normally contained become exposed to the network:
- The
Referrerheader is sent in the clear, so a MITM can read the address of the page the user was on. - The opened window keeps a
window.openerreference to the initiating page, and the attacker controls the document that holds it, so the attacker can drive the opener's navigation.
Wikipedia's HSTS policy is the reason a clean browser is needed: once the browser has learned it, the HTTP request is upgraded and the attack does not fire. The report frames the impact as spreading to all websites regardless of their level of defence, precisely because the weakness sits in the link the extension emits rather than in any particular destination.
Impact
Referrer
A remote attacker with MITM access can sniff the address of the active webpage after the user follows the "More on Wikipedia" link. The researcher points to #738 and #6884 as demonstrations of how a leaked referrer can expose sensitive information such as tokens in addresses and sensitive address parameters. The impact is the same as in those cases, but here it applies to all websites, ignoring their level of defence.
window.opener
The leaked window.opener allows exploiting vulnerabilities that rely on window.opener, such as #409400 and #405056, on arbitrary origins, again ignoring the level of defence of the pages involved. An origin, in browser terms, is the combination of scheme, host and port that identifies who a page belongs to; pages from different origins are normally kept apart. The attacker gains access to pages that were previously not exploitable because they do not share opener.
The vulnerability requires a high level of user assistance: not every card carries the "More on Wikipedia" link, and the user has to navigate through it. The researcher also notes that the window.opener reference is the more interesting part, though in very rare cases the referrer may become the more powerful attack vector.
Fix
The report does not describe a fix or a change made in response.
Variants to test
- Look for other extension-generated links to external sites that use
http://rather thanhttps://. A positive result is a request to the plain-HTTP host that carries aReferrerheader naming the page the user was on. - Check whether those links open in a new window that retains
window.opener. A positive result is an attacker-served page that can navigate the originating tab throughwindow.opener. - Test on a clean browser profile with no HSTS state for the destination, since HSTS silently masks the issue on profiles that have visited the site over HTTPS before.
- Try other words and card types to see how broadly the link appears; the report only confirms that some cards have it and that "Our" and "Your" work.
- Combine a controllable opener with known
window.opener-dependent issues such as the ones the report cites, to see whether origins that normally do not shareopenerbecome reachable.
Glossary
- Browser extension: a small program installed into a browser that adds features to web pages.
- Card (Grammarly card): the pop-up panel the extension shows with the meaning of a double-clicked word.
- HTTP: the basic language browsers and servers use to exchange web pages, sent without encryption.
- HTTPS: the same language, wrapped in encryption so others on the network cannot read or alter it.
Referrerheader: a note the browser attaches to a request saying which page the user came from.window.opener: a handle a newly opened window keeps to the window that opened it, letting the two communicate.- MITM (man-in-the-middle): an attacker positioned on the network path who can read or change traffic.
- Hosts file: a local file mapping website names to addresses, checked by the browser before the internet.
- HSTS: a rule a site sends telling the browser to only ever use HTTPS with it from then on.
- Clean browser / profile: a browser that has never visited the site, so it has not learned its HSTS rule.
- Token: a short secret string, often in a web address, that proves identity or grants access.
- Origin: the scheme, host and port that identify which site a page belongs to; different origins are normally isolated from each other.
- CVSS v3: a standard scoring system for rating the severity of a security flaw.
- Secure design principles: the idea that a system should be built so that unsafe situations cannot arise, rather than patched afterwards.
- Severity: a rating of how serious a flaw is, here low.
- Exploit: a script or technique that demonstrates the flaw in action.
<grammarly-card>: the HTML element the extension inserts into the page to display its card.