How we Broke PHP, Hacked Pornhub and Earned $20,000
작성자 정보
- Arlene 작성
- 작성일
본문
We now have found two use-after-free vulnerabilities in PHP’s rubbish assortment algorithm. Those vulnerabilities were remotely exploitable over PHP’s unserialize perform. We had been additionally awarded with $2,000 by the Internet Bug Bounty committee (c.f. Many thanks go out to cutz for co-authoring this text. Pornhub’s bug bounty program and its relatively high rewards on Hackerone caught our consideration. That’s why now we have taken the angle of a sophisticated attacker with the total intent to get as deep as potential into the system, focusing on one essential purpose: gaining distant code execution capabilities. Thus, we left no stone unturned and attacked what Pornhub is built upon: PHP. After analyzing the platform we quickly detected the utilization of unserialize on the web site. In all circumstances a parameter named "cookie" obtained unserialized from Post information and afterwards reflected by way of Set-Cookie headers. Standard exploitation strategies require so referred to as Property-Oriented-Programming (POP) that involve abusing already current lessons with specifically outlined "magic methods" to be able to set off unwanted and malicious code paths.
Unfortunately, it was difficult for us to collect any details about Pornhub’s used frameworks and xnxx PHP objects generally. Multiple classes from widespread frameworks have been examined - all with out success. The core unserializer alone is comparatively advanced because it entails more than 1200 lines of code in PHP 5.6. Further, many internal PHP classes have their very own unserialize methods. By supporting structures like objects, arrays, integers, strings and even references it is not any shock that PHP’s observe record reveals a tendency for bugs and reminiscence corruption vulnerabilities. Sadly, there were no recognized vulnerabilities of such sort for newer PHP variations like PHP 5.6 or PHP 7, particularly as a result of unserialize already got a lot of attention prior to now (e.g. phpcodz). Hence, auditing it can be compared to squeezing an already tightly squeezed lemon. Finally, after so much consideration and so many safety fixes its vulnerability potential ought to have been drained out and it must be secure, shouldn’t it? To seek out an answer Dario carried out a fuzzer crafted specifically for fuzzing serialized strings which were passed to unserialize.
Running the fuzzer with PHP 7 immediately result in unexpected behavior. This behavior was not reproducible when examined in opposition to Pornhub’s server although. Thus, we assumed a PHP 5 version. However, running the fuzzer against a newer model of PHP 5 just generated more than 1 TB of logs without any success. Eventually, after putting more and more effort into fuzzing we’ve stumbled upon unexpected behavior once more. Several questions needed to be answered: is the issue security related? If so can we only exploit it locally or additionally remotely? To further complicate this case the fuzzer did generate non-printable information blobs with sizes of greater than 200 KB. A tremendous amount of time was necessary to analyze potential points. In any case, we may extract a concise proof of idea of a working memory corruption bug - a so referred to as use-after-free vulnerability! Upon further investigation we discovered that the basis cause might be present in PHP’s garbage collection algorithm, a part of PHP that is completely unrelated to unserialize.
However, the interplay of each parts occurred only after unserialize had finished its job. Consequently, it was not well suited for distant exploitation. After additional analysis, gaining a deeper understanding for the problem’s root causes and a variety of hard work an identical use-after-free vulnerability was discovered that gave the impression to be promising for remote exploitation. The high sophistication of the found PHP bugs and their discovery made it mandatory to write separate articles. You may learn more details in Dario’s fuzzing unserialize write-up. As well as, we have now written an article about Breaking PHP’s Garbage Collection and Unserialize. Even this promising use-after-free vulnerability was considerably troublesome to use. In particular, it involved a number of exploitation phases. 1. The stack and heap (which also embody any potential person-enter) in addition to some other writable segments are flagged non-executable (c.f. 2. Even in case you are in a position to manage the instruction pointer you want to know what you need to execute i.e. that you must have a sound tackle of an executable reminiscence segment.
관련자료
-
이전
-
다음