WhatsApp 中的点击劫持漏洞可引发网络钓鱼攻击
A clickjacking vulnerability in WhatsApp that enables phishing attacks

原始链接: https://00xbyte.github.io/posts/Don%27t-Believe-Your-Eyes-A-WhatsApp-Clickjacking-Vulnerability/

在最近的一项发现中,网络安全专家 Zuki (Itay Zukerman) 透露了他如何开发“2K2E”,这是一种利用 Unicode 字符 U+202E(即从右到左覆盖)的技术,对流行的消息应用程序 WhatsApp 发起网络钓鱼攻击。 通过发送包含扭曲链接的精心设计的消息,攻击者可以诱骗收件人访问虚假网页,从而导致潜在的安全漏洞、身份盗窃和财务欺诈。 尽管 Facebook 母公司 Meta 承认了这个问题,但他们没有表现出立即解决该问题的迹象,导致数百万 WhatsApp 用户受到影响。 作为缓解措施,专家建议在访问 URL 链接之前先将其粘贴到新选项卡中来验证它们。 在多个数字通信平台上都发现了类似的漏洞,包括 Facebook、Android Messages 和 Google Keep 等。

至于关于 WhatsApp 的 iOS 与 macOS 客户端的第二个问题:虽然两者共享许多相同的界面和功能,但与 Mac 版本相比,iOS 版本有一些独特的功能和行为变化: 1. iOS 允许通过“新建组”图标创建新组,而 Mac 目前不提供此功能。 相反,必须在“设置”>“帐户”>“新组”中创建新组。 2. 在 iOS 上,按住群聊缩略图会启动聊天标题编辑模式,而在 macOS 上,按住对话会打开自己的菜单(尽管技术上可以在聊天设置中编辑群聊)。 3. 在 iOS 上回复消息时,您可以选择内联回复(直接在所选消息下方),但在 macOS 上您始终在单独的窗口中回复。 此外,消息传递功能略有不同; iOS 提供了点击消息气泡来显示其他操作的功能,而 macOS 则需要辅助鼠标操作或键盘快捷键来触发类似的功能。 根据每个平台的持续开发,可能存在其他潜在差异。 希望这有助于澄清情况。 如果您需要进一步的帮助或解释,请告诉我们!
相关文章

原文

Imagine you have received a WhatsApp message with a link to ln.instagram.com.
Where do you think the link leads? Instagram? Think again.

I have found a clickjacking vulnerability in WhatsApp that enables phishing attacks.
An attacker can send anyone a crafted message with a link that appears to lead to a legitimate website, but in fact leads to any website of the attacker’s choice.

Discovery Process

I started my research looking for a way to make a message recipient perform an HTTP request. My initial thought was to check WA’s link preview feature. I hoped the the link would be rendered twice, once by the sender and once by the receiver. In order to check my theory, I created a webhook and sent it to a friend. Sadly only one request was made, only by me.
That got me thinking. If the receiver does not render the link for themselves, that must mean I send both the link and the preview. If so, I wonder if I can send a link to one site with a preview of another?

I decided to take a look into what data is sent in a WA message that contains a link with a preview. My goal was to intercept the message, change the link and the preview to mismatch, and send it.
I decided to intercept a message via WA web, as hopefully that would be a faster setup than debugging an emulator. I then ran into a problem - WA uses and E2EE so I couldn’t simply modify the message with proxy like Burp Suite.

Instead of understanding the encryption mechanism, I decided insert a breakpoint a moment before the message was encrypted and sent through the websocket. WA web’s javascript was uglified and minified, however after a while of searching I found the right place.

Exactly as I suspected, the link and the preview were sent separately!
I created a message object forinstagram.com and changed the text property to google.com. Unfortunately, the message that was sent did not have a preview anymore. Only a link to Google.
Blackbox testing taught me that:

PropertyPurpose
textThe text of the message
canonicalURLThe domain that is shown at the bottom of the preview
matchedTextSeems to be compared against canonicalURL, also tested that its value apears in text

I discovered that if the matchedText was deleted from the object, I could create a mismatch!

Success! I have created a message with a preview to one site, and when clicked, leads to another. This was a great start, but I didn’t want the real link to be shown in the message. I was looking for ways to hide the message text.

I remembered that some unicode characters can change the representation of text, so I tried fuzzing characters to see their effect:

1
2
3
4
5
6
7
8
9
function fuzz(start, end) {
	for (let i = start; i  end ; i++) {
	    j = i.toString(16)
	    if (j.length  4) { j = "0".repeat(4 -j.length) + j}
 	    msg += eval("\"\\u"+j+"\"")
			+ "https://google.com/" + i.toString(16)
			+ "\n" 
	}
}

I observed the results and one result caught my eye. One of the lines (202e) was in reverse:

Apparently, the unicode character U+202E (Right-To-Left Override) alters the way that text is presented to the user by displaying it in reverse order.
That was a great start but this link looks horrible. Nobody would click it.

Crafting A Mirror URL

I wanted to create a URL that, when reversed, looked like https://instagram.com. This means that the link should be moc.margatsni//:sttph (\u202e+moc.margatsni//:sttph = https://instagram.com )

This fist problem is the TLD. I cannot register a .margatsni domain.
My solution was to find a TLD that could look like a subdomain. For example the TLD .nl (Netherlands) would result in ln.instagram.com (ln as in link)

Problem number two was that the URL needed to start with https:// in order to look legitimate.
My solution to this was to append the string //:sptth (which is a valid path) to the URL, so that https://moc.margatsni.nl//:sttph would appear as https://ln.instagram.com//:sptth

With a mirror URL and the U+202E character, an attacker can make any URL look like any other!
I call this vulnerability 2K2E

Final Result

Finally I have a legitimate looking URL that seems like it leads to Instagram, when in fact it leads to my blog Security Is Broken.

Attack Scenario

Utilizing both these issues can allow attackers to perform phishing attacks where they construct legitimate looking links that lead to malicious websites.

The full attack flow:

  1. An attacker purchases the mirror domain of the site they would like to impersonate. For example moc.margatsni.nl to impersonate ln.instagram.com
  2. The attacker creates a message with a link to original domain in order to use its preview.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    {
     "text": "https://instagram.com/",
     "matchedText": "https://instagram.com/",
     "canonicalUrl": "https://instagram.com/",
     "description": "Create an account...",
     "title": "Instagram",
     "jpegThumbnail": {},
     "previewType": 0,
     "mediaKey": {},
     "mediaKeyTimestamp": 1693302818542,
     "thumbnailDirectPath": "/v/t62.36...",
     "thumbnailSha256": {},
     "thumbnailEncSha256": {},
     "thumbnailHeight": 1024,
     "thumbnailWidth": 1024,
     "inviteLinkGroupTypeV2": 0
    }
    
  3. The attacker then removes the matchedText property and changes the text property to the following value: U+202E + “URL to the mirror domain” + //:sptth
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    
    {
     "text": "\u202ehttps://moc.margatsni.nl//:sptth",
     "canonicalUrl": "https://instagram.com/",
     "description": "Create an account...",
     "title": "Instagram",
     "jpegThumbnail": {},
     "previewType": 0,
     "mediaKey": {},
     "mediaKeyTimestamp": 1693302818542,
     "thumbnailDirectPath": "/v/t62.36...",
     "thumbnailSha256": {},
     "thumbnailEncSha256": {},
     "thumbnailHeight": 1024,
     "thumbnailWidth": 1024,
     "inviteLinkGroupTypeV2": 0
    }
    
  4. Finally the attacker sends the crafted message to their victim

Because we support many different platforms and environments, there are a significant number of ways that some platform could choose to normalize a URL differently than our server-side logic does. To address that, we have systems in place which allow us to adjust our URL normalization logic dynamically in the event of real-world spam and abuse.

Sadly, Meta has shown no intention to resolve this security issue and from their response it seems that they will try to stop these attacks only if their systems detect them as spam. This means that WhatsApp users can only cross their fingers that they won’t fall victims to 2K2E attacks.
Apposed to WhatsApp, other platforms such as X, TikTok, and Pinterest, all have sanitization of the U+202E character.

Mitigation

Because Meta has no intention of fixing this issue, links on WhatsApp cannot be trusted. In order to not fall victim to a 2K2E phishing attack, before clicking on a link, copy it. The clipboard preview should show the link address while sanitizing the U+202E character.

Update

I have found other services that do not have proper sanitization and are vulnerable to 2K2E as well.

  • WhatsApp
  • Facebook
  • Android Messages
  • Google Keep (Spreading phishing links via shared note)
  • Google Photos (Commenting on shared photos)
联系我们 contact @ memedata.com