Introduction
WhatsApp Web is a web-based extension of the WhatsApp application on your phone. The web application mirrors all messages sent and received, and fully synchronize your phone and your desktop computer so that users can see all messages on both devices.
WhatsApp Web is available for most WhatsApp supported platforms, including Android, iPhone (iOS), Windows Phone 8.x, BlackBerry, BB10 and Nokia smartphones. In September 2015, WhatsApp announced they had reached 900 million active users a month. At least 200M are estimated to use the WhatsApp Web interface, considering publicly available web traffic statistics.
Executive Summary
Check Point security researcher Kasif Dekel recently discovered significant vulnerabilities which exploit the WhatsApp Web logic and allow attackers to trick victims into executing arbitrary code on their machines in a new and sophisticated way. All an attacker needed to do to exploit the vulnerability was to send a user a seemingly innocent vCard containing malicious code. Once opened, the alleged contact is revealed to be an executable file, further compromising computers by distributing bots, ransomware, RATs, and other malwares.
To target an individual, all an attacker needs is the phone number associated with the account.
WhatsApp verified and acknowledged the security issue and have deployed the fix in web clients world-wide. To make sure you are protected, update your WhatsApp Web right now.
Check Point shared its discovery to WhatsApp on August 21, 2015. On August 27, WhatsApp rolled out the initial fix (in all versions greater than 0.1.4481) and blocked that particular feature.
Technical Details
WhatsApp Web allows users to view any type of media or attachment that can be sent or viewed by the mobile platform/application. This includes images, videos, audio files, locations and contact cards.
The vulnerability lies in improper filtering of contact cards, sent utilizing the popular ‘vCard’ format. This is a screenshot for a possible contact vCard sent by a malicious user:
As you can see, this message (contact card) appears legitimate, like any other contact card; most users would click it immediately without giving it a second thought.
The implication of this innocent action is downloading a file which can run arbitrary code on the victim’s machine:
An Initial Hole
During Kasif’s research, he found that by manually intercepting and crafting XMPP requests to the WhatsApp servers, it was possible to control the file extension of the contact card file.
He first changed the file extension to .BAT, which indicates a Windows batch (executable script) file:
This means, once the victim clicks the downloaded file (which he assumes is a contact card), the code inside the batch file runs on his computer.
Let’s see what’s inside the downloaded file (i.e. the batch file):
This is a standard vCard format. To run malicious code, Kasif found out an attacker could simply inject a command to the name attribute of the vCard file, separated by the ‘&’ character. When executed, Windows will attempt to run all lines in the files, including our controlled injection line.
Further research showed that no XMPP interception of crafting is needed for this attack, since any user can create such a contact with an injected payload on their phones, no hacking tools necessary:
Once such a contact is created, all an attacker has to do is share it via the normal WhatsApp client.
But can we take it to the next level? Could we possibly discover a way to share malicious PE (.exe) files through WhatsApp’s default sharing features (no external links)?
To answer that, we have to examine WhatsApp’s communication protocols; WhatsApp uses a customized version of the open standard Extensible Messaging and Presence Protocol (XMPP).
This is how vCard messages appear over-the-wire (with some reconstruction) when sent using WhatsApp’s protocol:
- NUMBER/GROUPID: the victim’s number or group ID
- ID: the message ID
- TIMESTAMP: the timestamp of the sender device
- FILENAME: the VCARD file name, <something>.exe
- FILEDATA: the raw data of the file
We were surprised to find that WhatsApp fails to perform any validation on the vCard format or the contents of the file, and indeed when we crafted an exe file into this request, the WhatsApp web client happily let us download the PE file in all its glory:
But wait, there’s more! Clever attackers can exploit this in more devious scenarios, using the displayed icon to enrich the scam:
This simple trick opened up a vast world of opportunity for cybercriminals and scammers, in effect allowing easy “WhatsApp Phishing”. Massive exploitation of this vulnerability could have affected millions of users, failing to realize the malicious nature of the attachment.
Disclosure Timeline
- August 21, 2015 – Vulnerability disclosed to the WhatsApp security team.
- August 23, 2015 – First response received.
- August 27, 2015 – WhatsApp rolls out fixed web clients (greater than v0.1.4481)
- September 8, 2015 – Public disclosure
Conclusions
“Thankfully, WhatsApp responded quickly and responsibly to deploy an initial mitigation against exploitation of this issue in all web clients, pending an update of the WhatsApp client” said Oded Vanunu, Security Research Group Manager at Check Point. We applaud WhatsApp for such proper responses, and wish more vendors would handle security issues in this professional manner. Software vendors and service providers should be secured and act in accordance with security best practices.
Check Point continues to be on the lookout for vulnerabilities in common software and Internet platforms, disclosing issues as they are discovered, protecting consumers and customers against tomorrow’s threats.”