r/programming • • Oct 21 '26

PHP2Shell: Critical vulnerabilities in the backbone of the web

https://php2shell.com
516 Upvotes

71 comments sorted by

46

u/gajus0 Oct 21 '26

Does anyone have a high-level walkthrough of how this attack works?

101

u/throwaway490215 Oct 21 '26

Send a request too big to fit. PHP starts building a table and increments the item count before filling each slot. The allocation fails, PHP bails out of the request — but the count now includes a slot that was never written.

Cleanup trusts the count and walks into that empty slot. The bytes there aren't a real object — they're attacker-planted garbage (freed memory reused from an earlier request or earlier in the same request). PHP reads them as a pointer + type and does its normal "free/destroy whatever this points at."

So the attacker gets "do a write at an address I choose." They aim that at a function pointer, overwrite it, and the next normal call jumps to attacker code.

25

u/tripleplay23 Oct 21 '26

This seems like a plausible description, but as described it sounds like it would immediately crash (at next cleanup) any PHP server after any “too big” request. I assume there is more nuance here?

52

u/artofthenunchaku Oct 22 '26

IIUC the worker processing the "too big" request does crash, but not the whole PHP server runtime. The worker persists it's data structures to shared memory before crashing, which gets picked up by another worker.

7

u/throwaway490215 Oct 22 '26 edited Oct 22 '26

A crash just means you get a 500 error most of the time. Turning that (worker thread) crash into a working exploit is the hard part.

Most AI's can trivially point you to where the corruption happens, but leveraging that into more seems to be rather hard. (I've not heard of publicly available code that does it for now).

3

u/Infinite_Music2059 Oct 22 '26

Calif has a good write up.

7

u/Deathisfatal Oct 22 '26

DJ?

5

u/Infinite_Music2059 Oct 22 '26

Yeah, he moonlights as a script kiddie and wrote some banger lines about it.

175

u/currentscurrents Oct 21 '26

Details from the group that found the exploit: https://www.wiz.io/blog/php2shell-php-rce

They credit their discovery to AI tools, especially Gemini 4.

169

u/MorrisonLevi Oct 21 '26

As far as I understand it, the core of the vulnerability was known in 2024, long before these AI tools were able to do this kind of stuff. It was just difficult to fix and nobody had figured out how to actually exploit it, so other things took priority. See the PHP Foundation's blog article on today's security release.

Now AI tools have radically accelerated how to connect the dots from "theoretically bad" to "mother forking shirtballs bad."

67

u/PascalsBadger Oct 21 '26

As a result of the leak and pre-announcement around 20:00 UTC, Calif, one of the security firms that had reported the issues mistakenly published a video. It showed their proof of concept working against a number of targets and revealed a few additional, though limited, details about the vulnerabilities. Copies of the deleted video started circulating on social media soon after. The video contributed to accelerated development of various PoCs (exploitation proof of concepts), which then increased circulation on October 21st.

Oof

5

u/teodorlojewski Oct 21 '26

Thanks for the insight!

17

u/tyler1128 Oct 21 '26

They also seem to have written the article largely using AI.

17

u/currentscurrents Oct 21 '26

Seems to be more and more common these days. 

I think the correctness of AI prose has made large strides, but the readability leaves much to be desired.

18

u/chucker23n Oct 22 '26

Yup. It tends to lack brevity, and occasionally sprinkles in details that may be plausible but aren't actually the case.

And even if that weren't so… as this sub's mods would say, "if you don't want to write it, we don't want to read it".

-3

u/danielcw189 Oct 22 '26

but the readability leaves much to be desired

which parts of the text did you find problematic?

19

u/Pindaman Oct 22 '26

I find that AI writes really correct and complete sentences which are longer than a human would naturally write. It's a bit exhausting to read because it feels like word filler

WordPress, Drupal and Joomla were representative targets used to demonstrate unauthenticated remote code execution.

I would have just said

WordPress, Drupal and Joomla were used to demonstrate remote code execution.

Just a random example but a lot of sentences are like that

-1

u/oscarolim Oct 22 '26

One is more formal than the other. Is like saying “In back to the future, Marty went to the past, to the future, to the past, to the past past, and back to the present. The end.”

Technically correct, but lacks substance.

15

u/this_knee Oct 21 '26

“Thanks, ai”

1

u/PhilMcGraw Oct 22 '26

Sarcasm, but it's probably accurate. Just because it wasn't shouted from the rooftops until now doesn't mean it wasn't exploited before this.

6

u/teodorlojewski Oct 21 '26

'PHP is the programming language behind much of the web, powering WordPress, Drupal and MediaWiki, the software that runs Wikipedia. A flaw in its core engine can affect websites across this ecosystem, even when their own application code is secure.'

What came first, the patch for the wiki or the wiki for the patch?

32

u/unicodemonkey Oct 22 '26

Let's make paragraphs pop into existence with a significant delay and with random animation effects as you scroll the page, it'll help readability for sure.

112

u/hazpotts Oct 21 '26

Anyone blaming people for using PHP mustn't remember HeartBleed or Shellshock. This vulnerability has no baring on any fundamental flaw in PHP itself. It's pervasiveness is just down to it's wide use, like OpenSSL and Bash in these previous exploits.

68

u/scottrycroft Oct 21 '26

And Log4J

-14

u/throwaway490215 Oct 21 '26

This is perhaps the most delusional take i've seen on the subject today.

The language of choice matters a lot. This has been proven beyond a doubt from CVE studies by both Google, Microsoft, and others - far in excess for you to be this willfully ignorant and spreading such nonsense.

This one was bad; and the pattern that created the flaw, is of a kind that can be caught/prevented in half a dozen ways that have become mainstream in the past decade.

PHP not doing so is cruft. Its old and successful in its heyday, that makes it pervasive and such a big deal now. The pervasiveness, and being vulnerable to any POST request, is a signal of its bad design. Not an excuse to accept bad design going forward.

HeartBleed spawned a few SSL forks because it was clear OpenSSL had become spaghetti, and it took OpenSSL a few years to get their shit together.

However the difference is that OpenSSL is a single implmenetation of some crypto standard; i.e. replacable.

PHP defines PHP.

Just stop creating new projects for it.

29

u/hazpotts Oct 21 '26

I didn’t say nothing’s wrong with PHP.

THis is a use-after-free in the runtime issue, sure. My point was the scale is down to how many servers run it. The CVE studies you’re quoting are about C/C++ memory safety, and that’s exactly what this is, same as Heartbleed. Python and Node run on C/C++ runtimes too. PHP 5 was a mess, 7 and 8 have been generally a lot better.

Not sure that’s “delusional”, feels like you replied to a comment I didn’t write.

-5

u/throwaway490215 Oct 22 '26 edited Oct 22 '26

has no baring on any fundamental flaw in PHP itself.

You're so close on the subject that you're separating out PHP into parts you consider fundamental and parts you considered flawed.

When people are being blamed for using PHP what they're blamed for is "the choice of using PHP and all the implication and context surrounding it from language design, runtime design, people paid to maintain it, size/quality of the ecosystem, etc."

PHP is written in a language and in a way where there is no memory safety guarantees, with a design that makes those lack of guarantees worse.

Node - was a language before it was webserver, and you can see that in the design how it handles HTTP request. PHP choose to create one request object using unsafe C code, whereas node mostly deals with socket and buffers. That choice is a fundamental part of PHP.

There are ways to negate it like compiling with Fil-C - the fact that less than 1% would use that is a fundamental part of PHP.

If this is the moment things are rewritten in rust or some other far stronger prove of safety can be given and in 3 years this kind of critical vuln are considered a major flaw in the safety guarantees present, then PHP will have fundamentally changed.

The vuln event is not the issue - shit happens. The issue is that today you're still arguing in terms of if PHP is flawed instead of this event triggering an argument 'how' its safety guarantees are flawed.

That makes PHP fundamentally flawed compared to alternatives.

7

u/chucker23n Oct 22 '26

I mean, if anything, the point you're making here is that this is not because of PHP as a language, but because PHP back then chose to be implemented largely in C. With modern tooling, be it static analyzers for C or languages that treat this approach as unsafe and require you to be explicit (such as Rust), this may have been avoided.

But what's "delusional" about that? Of course PHP chose, in 1995, to be written in C.

PHP defines PHP.

Just stop creating new projects for it.

But nothing about this has something to do with PHP as a language. Or even PHP as a standard library, with some of its… unusual choices.

All this would be is a case for "PHP ought to be reimplemented on top of a safer language". (Incidentally, it has been.)

0

u/milridor Oct 22 '26

This has been proven beyond a doubt from CVE studies by both Google, Microsoft, and others - far in excess for you to be this willfully ignorant and spreading such nonsense.

Agreed.

I know of at least one FAANG company that has a general ban on PHP for security reasons. And by ban, it includes internal tooling and external 3rd party services. They even migrated their internal wiki (not a simple thing to do considering the size) to a non-PHP version.

And I'm not even blaming the PHP foundation, their team is tiny (13 core devs as of 2026) and the runtime was not initially developed as an actual language (I mean for PHP 1 back in the 1990s) so some cruft is to be expected.

As a comparison, OpenJDK has 20 official builds supported by companies like Alibaba, Amazon, Microsoft, Oracle, etc. Most of them with LTS and commercial support. And dedicated teams internally.

Or look at Rust, this is just their compiler team, and they have separate language and library teams.

I just checked the PHP and Rust foundations reports for 2025. The former received ~645000$ in donations and membership fees, the latter ~5.1M$. PHP is just broke.

0

u/[deleted] Oct 21 '26

[deleted] — view deleted comment

4

u/ROBOTRON31415 Oct 22 '26

(Except when Heartbleed came out, over a year passed before Rust’s 1.0 release.)

5

u/thedogz11 Oct 22 '26

Meanwhile we get npm supply chain exploits so often it's not even news anymore.

PHP, you been a good pony.

16

u/Primary_Ads Oct 21 '26

thank the heavens im not using php

21

u/peaky_blin Oct 21 '26

Even if you’re not, a service you’re relying upon might be using it, tbh it’s a shitty situation for the whole world

2

u/burgonies Oct 21 '26

My wife’s job apparently uses some service that runs on PHP. It was down all day.

47

u/labatteg Oct 21 '26

- Thank the heavens I'm not using PHP!

- Exactly! What if you were hit by this exploit?

- What exploit?

4

u/matthieuC Oct 22 '26

Tell us what you use and I bet that within one hour you'll have 5 people telling you this is the worst thing that ever happened since butt cancer.

1

u/Far_Composer_5714 Oct 22 '26

Nginx serving static files

4

u/dkarlovi Oct 23 '26

Nginx also had a few CVEs released in the last few days.

-1

u/Primary_Ads Oct 22 '26

i dont mind

1

u/mpdsfoad Oct 21 '26

Oh that's rough

-13

u/someyokel Oct 21 '26

The backbone? More like the appendix.

-74

u/VanillaSkyDreamer Oct 21 '26

If PHP is backbone of your internet then let it burn.

38

u/CompetitiveCut3919 Oct 21 '26

that's 70% of the entire internet bud

-15

u/bedroompurgatory Oct 21 '26

Yeah, but 70% of the internet is also ghostwritten SEO wordpress blogs.

3

u/Harvey_the_Hodler Oct 22 '26

It's starting to feel like 70% is written by ai.

-110

u/[deleted] Oct 21 '26 edited Oct 21 '26

[removed] — view removed comment

66

u/bagabe Oct 21 '26

What is this rage bait crap man? There are decades of vulnerabilities in practically every language/runtime if they are around long enough and relevant enough to look for vulnerabilities in them.

-23

u/garnet420 Oct 21 '26 edited Oct 21 '26

PHP is definitely garbage, but it's wrong to blame the victims of that ecosystem. There's all sorts of constraints on the kind of tools people can use, and whether they can switch off of them.

People down voting can't handle the fact that the vulnerability was known in php in 2024 but they were too smug to fix it.

1

u/Abhrogash Oct 22 '26

no they were not "smug" about it. They actually aknowledge what went wrong: there was no known way to exploit it and the solutions they came up with had trade offs, so they sat on it while they prioritized other things that had a more direct impact.

There's a full explanation here: https://thephp.foundation/blog/2026/10/21/todays-php-security-release-and-how-were-strengthening-php-security/

0

u/garnet420 Oct 22 '26

"we can't think of how to exploit this" doesn't mean there's not an exploit. It's inherently a smug position to take, because it assumes that the limits of your imagination are the actual limits.

2

u/Abhrogash Oct 22 '26

Which is why they worked on fixing it. From the wording of the article it seems like they had fixes ready but they all had various trade offs. They went into decision paralysis about it while prioritizing other stuff that had confirmed exploits. Could have they had handled it better? Yes Do they acknowledge that? Yes Are they working on improving their systems to prevent this happening again? Also yes They didn't just go "oh yeah, no exploit so who cares"

-38

u/ToaruBaka Oct 21 '26

Insanity is doing the same thing over and over again and expecting different results

6

u/2cars1rik Oct 22 '26

That’s actually not what insanity is

22

u/chucker23n Oct 21 '26

If you think it's appropriate for all major eCommerce and web hosting tools to be built on top of the same runtime you should actually just find a new career. This is a condemnation of the lazy fucks in this industry that think all of this is just someone else's problem.

Is your point here that everyone should roll their own runtime?

9

u/ulimn Oct 21 '26

If you don’t make your chips yourself from the minerals you mine with your bare hands or produce your own electricity, you deserve getting hacked!!

-20

u/ToaruBaka Oct 21 '26

Well if they did, 70% of the internet wouldn't be down right now, would it?

6

u/chucker23n Oct 22 '26

No, instead we’d have a hundred different combinations of bugs and far fewer eyes on each of them.

6

u/7f2g Oct 21 '26

Dude is angry lol

You make the world a worse place

6

u/im_a_goat_factory Oct 21 '26

What sort of trash take is this lol

Enlighten us with your runtime that never gets a critical security patch

10

u/FingerAmazing5176 Oct 21 '26

Yeah. You’d be surprised how many companies, especially small ones that can’t afford $30k+ fees for custom design and hosting use WP and Drupal.

In fact many agencies that do charge $100k+ still end up with drupal templates

7

u/scottrycroft Oct 21 '26

PHP is written in C, so C is the real problem lol.

3

u/UnexpectedAnanas Oct 21 '26

Personally I blame Assembly.

2

u/programming-ModTeam Oct 22 '26

Your post or comment was overly uncivil.