Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do Facebook's JSONP callbacks start with "/**/"

When I used Facebook's Open Graph API, I noticed that the JSONP responses generated by Facebook seemed to have an extraneous "/**/" at the beginning of each response like this:

URL: 
https://graph.facebook.com/SOME_ID?method=get&pretty=0&sdk=joey&callback=FB.__globalCallbacks.f1c77f051c

Response:
/**/ FB.__globalCallbacks.f887adeec(...);

Why is this?

like image 880
Andrew Lee Avatar asked Mar 09 '13 02:03

Andrew Lee


2 Answers

We added this to protect against an attack where a third party site bypasses the content-type of the response by doing: <object type="application/x-shockwave-flash" data="http://graph.facebook.com?callback=[specifically crafted flash bytes]"></object>

Google does something similar, except they use //... + \n (e.g. http://www.google.com/calendar/feeds/[email protected]/public/full?alt=json&callback=foo)

like image 200
Alok Avatar answered Nov 12 '22 11:11

Alok


Certainly to prevent XSSI... so you can't execute it...

http://maxime.sh/2013/02/javascript-quest-ce-que-le-xssi-et-comment-leviter/&usg=ALkJrhhjfdwBrK7kxNipOowAYacIcJm89g">Here is a french blog post about that (with google translate)

like image 20
Jean-Michel Trayaud Avatar answered Nov 12 '22 11:11

Jean-Michel Trayaud