A single Python file exploits PHP's memory limit to steal Bitcoin CTF flag

Steal My Bitcoin CTF PoC

A single Python file exploits PHP's memory limit to steal Bitcoin CTF flag

A public proof-of-concept for the Steal My Bitcoin CTF, written in one standard-library Python file. It walks PHP 8.4.26 through a memory-limit fatal during session upload-progress parsing, leaks a heap address and a code address through oversized session cookies, then forges a HashTable so cleanup calls zif_system and runs a command. The whole chain takes at most 20 HTTP requests, with no looping or retries, and runs against a local Docker lab.

With both addresses, a final request drops a forged PHP structure where cleanup will find it, and cleanup calls zif_system, PHP's handler for system.
  1. NorwegianDude

    To be fair, the person who created the challenge stated that is was a fairly standard setup, replicating something outside a lab, but in reality is was something completely different, and not anywhere near how PHP is usually used.

    It used the development server in PHP, and did not even run requests with fpm or mod_php. Instead, it used the built in dev server of PHP, and just proxied requests from nginx to the php dev server.

    Literally the first thing on top of the PHP docs about the dev server used here is this:

    "Warning

    This web server is designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network."

    That is not something people do, and it also explains why the site was down all the time, cause the dev server is super slow, as it's not meant for this in any way shape or form. A real setup would add a few zeros to the requests per second a server could handle.

    So all in all, this was very pointless, as it was nothing like real php sites. A shame, cause a realistic setup woild be more interesting and relevant to answer the question of how hard is it really to gain RCE on a normal site.

  2. bushwart

    Related: https://x.com/JamesPavur/status/2114501212313653696

    Apparently the wallet key wasn't on the server, like some in the original thread suspected, but perhaps not due to maliciousness after all.

  3. pwython

    I used Kimi K3.1 Pro to figure it out as soon as cloudlandsdev put php-version.php live. The exploit worked just like this in a local Docker lab. But the terms page of the contest prohibited "resource exhaustion," so it stopped there. Showing Kimi the PoC, it says:

    "The winning chain deliberately used per-request memory exhaustion, which appears to violate the literal no-resource-exhaustion rule, although the organizer accepted the win."

  4. zeratax

    between the challenge being updated to actually run php and this only like 2-3 hours passed

  5. gnabgib

    This is already linked by it's author in the Steal My Bitcoin thread (585 points, 458 comments) https://news.ycombinator.com/item?id=50224916

More from this day

2026-10-26