Thursday 14 November 2013

Facebook Open URL Redirection Vulnerability

About a week ago, I discovered an open url redirection vulnerability in Facebook that allowed me to have a facebook.com link redirect to any website without restrictions.

The flaw exists in the way facebook handled the url parameter. Visiting the link below would always redirect to the facebook homepage:
http://facebook.com/campaign/landing.php?url=http://yahoo.com

But I noticed that changing the url to a random string, for example:
http://facebook.com/campaign/landing.php?url=asdf

The link above generated a unique "h" variable and passed the url parameter to Facebook's Linkshim:
http://www.facebook.com/l.php?u=asdf&h=mAQHgtP_E

So how do you bypass the restrictions and load arbitrary links? You simply remove the http:// part of the target destination and it will redirect successfully:
http://facebook.com/campaign/landing.php?url=yahoo.com

Facebook's Linkshim (l.php) interprets example.com the same as http://example.com thus allowing for a working redirection. As you may have read in the past, url redirection flaws in facebook and third party applications puts a user's access token at risk if that link is entered as the final destination in an Oauth dialog. But the most common use of a redirection flaw in general is the ability to convince a user to click on a trusted link which is specially crafted to take them to an arbitrary website.

However, facebook informed me that because the redirection occurs through the l.php method, they have the ability to filter and ban particular websites from redirecting using their automatic spam and malware analysis. But not all malware/spam can be caught by facebook, and by the time a link is banned, an attacker would have already moved on to another link.


Video Proof of Concept:

(Best Viewed in HD)

Facebook responded the day after my report, and they were quick to patch the flaw in about a week and a half. The payout for this bug is $1,000.

~Dan Melamed

2 comments:

  1. There is a type mistake in the title, please change Vulnerabiity with Vulnerability

    ReplyDelete
    Replies
    1. I didn't even notice. Thanks for letting me know, I must have written it too fast.

      Delete

About Me

I'm a security researcher. You can follow me on twitter @danmelamed

Contact

Media Inquiries:
press.danm@gmail.com

Questions or Comments
general.danm@gmail.com