How we Broke PHP, Hacked Pornhub and Earned $20,000

How we Broke PHP, Hacked Pornhub and Earned $20,000

Madeline 2024.05.30 15:56 views : 9

360_F_314700448_Ckh3uDxLuKEwPNGHIKF1ZgRwuVStqSft.jpgWe've got found two use-after-free vulnerabilities in PHP’s garbage assortment algorithm. Those vulnerabilities have been remotely exploitable over PHP’s unserialize function. We had been also awarded with $2,000 by the Internet Bug Bounty committee (c.f. Many thanks go out to cutz for co-authoring this article. Pornhub’s bug bounty program and its comparatively high rewards on Hackerone caught our attention. That’s why now we have taken the perspective of a sophisticated attacker with the total intent to get as deep as attainable into the system, focusing on one major purpose: gaining remote code execution capabilities. Thus, we left no stone unturned and attacked what Pornhub is built upon: PHP. After analyzing the platform we shortly detected the utilization of unserialize on the web site. In all cases a parameter named "cookie" received unserialized from Post data and afterwards reflected by way of Set-Cookie headers. Standard exploitation methods require so referred to as Property-Oriented-Programming (POP) that contain abusing already present classes with specifically defined "magic methods" with a view to set off undesirable and malicious code paths.



b9404ca05d4b26a9c18a3f4577b1b9da.10.jpgUnfortunately, it was troublesome for us to collect any details about Pornhub’s used frameworks and PHP objects normally. Multiple classes from widespread frameworks have been tested - all without success. The core unserializer alone is relatively advanced because it involves greater than 1200 lines of code in PHP 5.6. Further, many internal PHP lessons have their own unserialize strategies. By supporting buildings like objects, arrays, integers, strings or even references it is not any shock that PHP’s monitor record shows a tendency for bugs and xnxx memory corruption vulnerabilities. Sadly, there have been no identified vulnerabilities of such type for newer PHP versions like PHP 5.6 or PHP 7, especially because unserialize already bought a number of attention in the past (e.g. phpcodz). Hence, auditing it can be compared to squeezing an already tightly squeezed lemon. Finally, after so much consideration and so many security fixes its vulnerability potential ought to have been drained out and it should be safe, shouldn’t it? To search out an answer Dario carried out a fuzzer crafted specifically for fuzzing serialized strings which had been passed to unserialize.



Running the fuzzer with PHP 7 instantly lead to unexpected conduct. This conduct was not reproducible when examined against Pornhub’s server though. Thus, we assumed a PHP 5 version. However, operating the fuzzer against a newer model of PHP 5 simply generated more than 1 TB of logs with none success. Eventually, after putting more and more effort into fuzzing we’ve stumbled upon unexpected conduct again. Several questions had to be answered: is the problem safety associated? If that's the case can we solely exploit it regionally or also remotely? To additional complicate this example the fuzzer did generate non-printable knowledge blobs with sizes of greater than 200 KB. An amazing period of time was obligatory to analyze potential issues. In spite of everything, we could extract a concise proof of concept of a working memory corruption bug - a so referred to as use-after-free vulnerability! Upon further investigation we discovered that the root cause could possibly be present in PHP’s rubbish collection algorithm, a component of PHP that is totally unrelated to unserialize.



However, the interplay of both elements occurred solely after unserialize had completed its job. Consequently, it was not properly fitted to remote exploitation. After further analysis, gaining a deeper understanding for the problem’s root causes and a lot of exhausting work the same use-after-free vulnerability was discovered that seemed to be promising for remote exploitation. The high sophistication of the discovered PHP bugs and their discovery made it crucial to write down separate articles. You'll be able to learn more particulars in Dario’s fuzzing unserialize write-up. In addition, now we have written an article about Breaking PHP’s Garbage Collection and Unserialize. Even this promising use-after-free vulnerability was significantly tough to exploit. In particular, it concerned a number of exploitation phases. 1. The stack and heap (which additionally include any potential user-input) as well as some other writable segments are flagged non-executable (c.f. 2. Even if you're ready to control the instruction pointer you should know what you want to execute i.e. it is advisable to have a valid address of an executable reminiscence segment.

Comments