August 11, 2007

Facebook Source Code Leaked

Nik Cubrilovic

257 comments »

We just received a tip that the source code for the Facebook main index page has been leaked and published on a blog called Facebook Secrets. There are at least two possible ways that the source code got out - the first is that a Facebook developer has sent it out, or the more likely option that a security hole or other method has been used on either one of the Facebook servers or in their source code repository to reveal the code. The blog that published the code only has a single post on it, so it was created exclusively to publish this code - meaning that whoever is behind this both isn’t taking credit for the hole and doesn’t want to be associated with it. While there is no certain way to verify if the code is actually from Facebook, by taking a quick look through the code and by double-checking some paths that have been referenced, we can say with some certainty that this seems to be both real and also a recent version of the main Facebook page.

There are a number of clear ramifications here. The first is that the code can be used by outsiders to better understand how the Facebook application works, for the purposes of finding further security holes or bugs that could be exploited. Since Facebook is a closed source application, without access to the code security holes are usually found through a process of black-box testing, whereby an external party will probe the application in an attempt to work out how the application behaves and to try and find potential race conditions. In closed source applications it is common that developers rely on the closed nature of the application to obfuscate poor design elements and the structure of the application. An attacker getting access to the source code more often than not leads to further security holes being discovered. It is for these reasons that it is often claimed that open source software is more secure than closed source software, since there are many more eyes auditing the code and obfuscation can’t be used as a security measure.

The second implication with this leak is that the source code reveals a lot about the structure of the application, and the practices that Facebook developers follow. From just this single page of source code a lot can be said and extrapolated about the rest of the Facebook application and platform. For instance, the structure doesn’t follow any object oriented development practices, and it seems that the application is one large PHP file with a large number of custom functions living in the same namespace (they also seem to be using the Smarty templating engine).

This leak is not good news for Facebook, as it raises the question of how secure a Facebook users private data really is. If the main source code for a site can be leaked, then it can be said that almost anything is possible. Facebook has become such a success and has such a high profile that it has become a magnet for attacks against its systems. Most large scale applications suffer a breach at some point or another, since the odds are always stacked in favor of attackers, but companies can respond in a number of ways and the hope here is that Facebook will handle this situation gracefully. I don’t doubt that Facebook will pursuit this case with a lot of energy to both find the cause of why the code has leaked as well as to find who was responsible. They will also need to take some very quick short term measures to mitigate the risk to users since you can bet that right this minute there are hundreds of potential attackers pouring through the leaked code and probing their systems. At a quick glance, I know that I can see some obvious things in the code that both reveal certain hidden aspects of the platform and give a potential attacker a good head start.

Update: Facebook have sent us an official response (and Brandee Barker from Facebook has left a comment below): “A small fraction of the code that displays Facebook web pages was exposed to a small number of users due to a single misconfigured web server that was fixed immediately. It was not a security breach and did not compromise user data in any way. Because the code that was released only powers the Facebook user interface, it offers no useful insight into the inner workings of Facebook. The reprinting of this code violates several laws and we ask that people not distribute it further.” It seems that the cause was apache and mod_php sending back un-interpreted source code as opposed to output, due to either a server misconfiguration or high load (this is a known issue). It is also apparent that other pages have been revealed, and that this problem has occured before, but only now has somebody actually posted the code online.

Update 2: I have posted 4 tips on my own blog on how to prevent your server from leaking your application source code

  • Sphere It

Trackbacks/Pings (Trackback URL)

  1. Yasser Has Things To Say » Facebook Source Code Leaked ?
  2. Facebook You Have a Problem
  3. » Potential Consequences of Facebook Source Code Leak || Pulse 2.0: Web 2.0 Reviews & Profiles || » Blog Archive
  4. Deep Jive Interests » Facebook Hacked! (By An Inside Job?)
  5. Facebook Source Code Exposed By Faulty Web Server
  6. A break-in of the Facebook Walled Garden | WinExtra
  7. FaceBook源代码泄漏 | China IT News
  8. FaceBook源代码泄漏 -- 幻影泡沫
  9. Facebook Source Code Leaked » TechAddress
  10. Facebook Hacked? My Identity Too? « Network(ed)News
  11. Revelado el código de Facebook
  12. Facebook Source Code Leaked « TechTitans™
  13. HerbaZ - حرباز » أرشيف المدونة » Facebook تسرب السورس كود لموقع
  14. Attention all: Facebook code leaked-- Stepping in Faith
  15. Metagg
  16. FernyB
  17. frank.linhares - general.wandering.ramblings » Blog Archive » Facebook source code leaked
  18. Facebook 소스 코드 유출
  19. 我挖网(5dig.net)
  20. Techomical
  21. Learning from Facebook: Preventing PHP Leakage | New Web Order - Nik Cubrilovic
  22. Facebook source leaked - get it all here - alex.moskalyuk
  23. Lost! » Facebook Code Published
  24. NYLON » Archive » Τρύπα στο Facebook
  25. Svelato il codice della homepage di Facebook
  26. Sndagsbrunch / mblogg.se
  27. Facebook Source Code Leaked! - The Unofficial Facebook Blog
  28. Parte del código fuente de Facebook… ¡hecho publico! :
  29. Nuudelisoppa » Facebook Source Code Leaked
  30. Inside Facebook » Facebook Source Code Inadvertently Leaked
  31. Когда сервер плохо настроен « О PHP и о жизни…
  32. Why I prefer LinkedIn over Facebook | kerimsatirli.com
  33. CISNKY » Facebook source code leaked
  34. Facebook: Strike Two « These are the days
  35. Facebook hax0red « D-Lister
  36. Facebook Source Code Leaked « Daily Rambling Thoughts
  37. Facebook Goes Open Source | Tekjuice.com
  38. Peter’s Blog » Blog Archive » Facebook Server Configuration Mistake
  39. muhammad.saleem » facebook source code leaked - what does it mean for our privacy?
  40. Mark Evans - How Much Do You Peel Back the Onion?
  41. Smart Mobs » Blog Archive » Facebook Source Code Inadvertently Leaked
  42. proxieslist.net
  43. Insider Chatter by Donna Bogatin » Zuckerberg Insecurity Exposed: A Facebook Bug Attacks Again
  44. Tech / tunes links 8.12.07 – From brunch to eternity « The ListeNerd
  45. JOBMATCHBOX » Blog Archive » Social Network Security Update
  46. Facebook code leaked.
  47. PHP Did Not Cause Facebook Code Leakage at Random Strings
  48. Facebook Source Code leaked
  49. Great posts - 12/8
  50. Just a random blog !
  51. Facebook Source Code Leaked | Ashwin’s Blog
  52. Facebook Source Code Leaked | Ashwin’s Blog
  53. Διέρρευσε μέρος κώδικα του Facebook! at Wiggler
  54. Mrasnika’s Lair » Source Code-а на Facebook
  55. Big Trapeze » Blog Archive » Facebook Code Leak
  56. Facebook Home Page Code at The Mackademic
  57. asBlog » Facebook Source Code Leaked
  58. Facebook Source Code Leaked.
  59. The Programming and Management Blog » Facebook PHP Code Leaked
  60. Zen 2.0 : Facebook exposed
  61. Scalable web architectures » Blog Archive » Facebook internals
  62. El código de Facebook fue liberado… por accidente
  63. All ur spring break pictures are belong to us! « Pax Arcana
  64. Breakdowns: Why does Facebook want to hide its source code? » TechAddress
  65. Support this story on Stirrdup
  66. Facebook Source Code Leaked : Knurów
  67. Tony Cai’s Blog - Technology, Business, Politics and Life at Stony Brook University » Facebook PHP Code Leaked: It’s Copyright!
  68.   All your misconfigured servers are belong to us - Fudeblog by Cesar Cardoso
  69. Techomical
  70. How to Prevent your own Facebook-Style PHP Leak | Bookmark Bliss
  71. Anandhan Subbiah - ‘Inspire and Innovate’ » Facebook source code compromised
  72. TechCrunch en français » Le code source de Facebook piraté et publié
  73. Facebook source code leaked · TechBlogger
  74. T-Error
  75. Facebook security failure - The Relentless Stream of Consciousness
  76. Security Tips » Facebook Opened Its Source Code
  77. FacebookTalk.com - Facebook Hacks, Tricks, Tips, and Wall ASCII
  78. Don't count on Facebook to be spam/scam free either | Michael Gracie
  79. Facebook Source Code Leaked Onto Internet :: The FilipinoDutyFree.Com Blog
  80. bloggy blog
  81. GM.com » Blog Archive
  82. pligg.com
  83. MiCCAS.net Official Blog » Blog Archive » FaceBook source code LEAKED
  84. Reiten, Schwimmen, Lesen » Blog Archive » Auslieferung von PHP Sourcecode verhindern
  85. VCs are seeking Vietnamese Web 2.0 Startups
  86. moonbuggy
  87. Facebook Source Code Leaked | The Last Page on the Net
  88. Null is Love » Blog Archive » Lessons from the Facebook Leak
  89. Facebook Source Code Leaked · Style Grind
  90. All your facebook are belong to us - Ninja Monkeys!
  91. Google Takes Down Blogger Site With Leaked Facebook Code
  92. Google Takes Down Blogger Site With Leaked Facebook Code : Knurów
  93. Google Removeses Blog Publishing Leaked Facebook Code : Knurów
  94. Google Removes Blog Publishing Leaked Facebook Code : Knurów
  95. Google Removes Blog Showing Leaked Facebook Code : Knurów
  96. NexGen Technology Blog » Google Removes Blog Showing Leaked Facebook Code
  97. Google Removes Blog Showing Leaked Facebook Code | Tekjuice.com
  98. Linzerd.s Word » facebook代码泄漏
  99. GbolahanWilliams.com » Careless Code Leakage, Outrageous Application Outage | The power of G
  100. TechCrunch en français » Google ferme le blog qui avait publié le code de Facebook
  101. As the kicks off « Digital Chameleon
  102. Wyciekł kod źródłowy Facebooka | Futurity.pl
  103. Je libo zdrojáky Facebooku?
  104. MAMK:Net | Blog Archive | Concern: Facebook Source Code Leaked
  105. adClustr » Breaking: AuctionAds’ PHP Leak - Free Ad Backgrounds & AdSense Advice
  106. All Night Coder - Today’s Top Blog Posts on Programming - Powered by SocialRank
  107. Apple Fever - Today’s Top Blog Posts on Apple - Powered by SocialRank
  108. Startup Signal - Today’s Top Blog Posts on Entrepreneurship - Powered by SocialRank
  109. New Media Signal - Today’s Top Blog Posts on New Media - Powered by SocialRank
  110. Codespot.ru » Blog Archive » о движке vkontakte.ru
  111. Исходники Facebook просочились в Сеть at Лучший УЕБ разработчик Украины
  112. Daily Links for 2007-11-15 « Attractive Verdana
  113. Obfuscure Blog » Blog Archive » Source Code Leaks: Facebook repeated?
  114. tech.nocr.at | Facebook source code leaked
  115. Most Popular TechCrunch Posts of 2007 teasered @ TechTalkBlog
  116. Facebook Information Links and Stats | FAQHit.com
  117. Clever Diversions - 08.13.07 « jdWeblog
  118. Team BKWLD » Secure Your Web Apps
  119. Josh on the Web » Blog Archive » Securing Your PHP Code - Server Sercurity
  120. 8216862eabdf

Comments

RSS feed for comments on this post.

  1. Michael Vu