Hacking

Google addressed an XSS flaw in Gmail

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.
[adrotate banner=”9″] [adrotate banner=”12″]

Pierluigi Paganini

(SecurityAffairs – Google Gmail, XSS)

[adrotate banner=”5″]

[adrotate banner=”13″]

Pierluigi Paganini

Pierluigi Paganini is member of the ENISA (European Union Agency for Network and Information Security) Threat Landscape Stakeholder Group and Cyber G7 Group, he is also a Security Evangelist, Security Analyst and Freelance Writer. Editor-in-Chief at "Cyber Defense Magazine", Pierluigi is a cyber security expert with over 20 years experience in the field, he is Certified Ethical Hacker at EC Council in London. The passion for writing and a strong belief that security is founded on sharing and awareness led Pierluigi to find the security blog "Security Affairs" recently named a Top National Security Resource for US. Pierluigi is a member of the "The Hacker News" team and he is a writer for some major publications in the field such as Cyber War Zone, ICTTF, Infosec Island, Infosec Institute, The Hacker News Magazine and for many other Security magazines. Author of the Books "The Deep Dark Web" and “Digital Virtual Currency and Bitcoin”.

Recent Posts

Google addressed 2 Chrome zero-days demonstrated at Pwn2Own 2024

Google addressed two zero-day vulnerabilities in the Chrome web browser that have been demonstrated during…

9 hours ago

INC Ransom stole 3TB of data from the National Health Service (NHS) of Scotland

The INC Ransom extortion group hacked the National Health Service (NHS) of Scotland and is threatening…

13 hours ago

CISA adds Microsoft SharePoint bug disclosed at Pwn2Own to its Known Exploited Vulnerabilities catalog

U.S. Cybersecurity and Infrastructure Security Agency (CISA) adds a Microsoft SharePoint vulnerability disclosed at the…

18 hours ago

The DDR Advantage: Real-Time Data Defense

This is the advantage of Data Detection and Response (DDR) for organizations aiming to build…

21 hours ago

Finnish police linked APT31 to the 2021 parliament attack

The Finnish Police attributed the attack against the parliament that occurred in March 2021 to…

1 day ago

TheMoon bot infected 40,000 devices in January and February

A new variant of TheMoon malware infected thousands of outdated small office and home office…

2 days ago

This website uses cookies.