Google addressed an XSS vulnerability in Gmail, the IT staff at Google defined the vulnerability as “awesome.”

Michał Bentkowski, Chief Security Researcher from security frim Securitum, found an XSS vulnerability in Gmail and responsibly disclosed it this week after Google has addressed it.

The flaw, described by Google IT staff as an awesome XSS issue, resides in the AMP4Email feature rolled out in July. Bentkowski reported the vulnerability via the Google Vulnerability Reward Program in August 2019.

AMP4Email makes it easier the management of dynamic content inside emails, it allows users to easily take action directly from within the message itself, like RSVP to an event, fill out a questionnaire, browse a catalog or respond to a comment.

Even if AMP4Email implements a strong validator that only allows a list of tags and attributes in dynamic mails, it doesn’t implement a validation system to prevent cross-site scripting (XSS) attacks. The expert noticed that that the id attribute is not disallowed in tags, so decided to investigate whether or not AMP4Email could be subject to DOM Clobbering.

“DOM Clobbering is a legacy feature of web browsers that just keeps causing trouble in many applications. Basically, when you create an element in HTML (for instance ) and then you want wish to reference it from JavaScript, you would usually use a function like document . getElementById ( ‘username’) or document . querySelector ( ‘#username’).” the expert wrote. “But these are not the only ways! The legacy way is to just access it via a property of global window object . So window.username is in this case exactly the same as document . getElementById ( ‘username’)! This behaviour (which is known as DOM Cloberring) can lead to interesting vulnerabilities if the application makes decisions based on existence of certain global variables (imagine: if (window . isAdmin ) { … } )..”

The expert verified that the AMP4Email employs some protection against DOM Clobbering by forbidding certain values for the id attribute (i.e. AMP). However, the restriction didn’t work with AMP_MODE that triggers a 404 error if the function tried to load JS files, causing the presence of an ‘undefined’ portion in the middle of the resultant URL (https://cdn.ampproject.org/rtv/undefined/v0/amp-auto-lightbox-0.1.js).

“AMP tries to get a property of AMP_MODE to put it in the URL,” the continues the researcher. “Because of DOM Clobbering, the expected property is missing, hence undefined.”

The researchers discovered that the code creates a new ‘script’ element, then it checks whether AMP_MODE.test and window.testLocation are both truthy.

Bentkowski discovered that it was possible to control the URL by writing specific code to overload the window . testLocation .

Anyway, the code didn’t execute in the real-world case because of Content-Security-Policy deployed in AMP.

“I didn’t find a way to bypass the CSP, but when trying to do so, I found an interesting way of bypassing dir -based CSP and I tweeted about it (later it turned out that the same trick was already used in a CTF in 2016). Google in their bug bounty program, don’t actually expect bypassing CSP and pay a full bounty anyway. It was still an interesting challenge; maybe someone else will find way to bypass 🙂 ” concludes the expert.

“In the post , I’ve shown how DOM Clobbering could be used to perform an XSS if certain conditions are met. It was surely an interesting ride! If you wish to play around with these kind of XSS- es , have a look at my XSS Challenge, which was based on this very XSS. “

Below the Gmail XSS vulnerability timeline:

15th Aug 2019 – sending report to Google

16th Aug 2019 – “nice catch!”,

10th Sep 2019 – response from Google: “the bug is awesome, thanks for reporting!”,

12th Oct 2019 – confirmation from Google that the bug is fixed (although in reality it happened way earlier),

18th Nov 2019 – publication.

Pierluigi Paganini

(SecurityAffairs – Google Gmail, XSS)

Share this...

Linkedin Reddit Pinterest

Share On