News for hackers. Stuff that matters.
Re:80% of the Web Powered by PHP (2017) by piotrkubisa on Thursday March 21, 2019 @09:09AM (#19451838)
I think link should be changed to https://w3techs.com/technologies/details/pl-php/all/all, because it points to more actual results. On that page, we can see a diagram that shows many websites has not been updated to work with latest PHP 7+, which I'd say is quite shameful and/or method used by authors of this report to check PHP version is not adequate (I guess it is now a common standard to hide version of the used interpreter in a HTTP header, while it wasn't obvious todo task when only 5.x was available). Additionally, I found it is quite wrong to putting equal mark between PHP and Hack (HHVM) in section of "Popular sites using PHP".

Edit: Fixed some language errors and typos.

Re:80% of the Web Powered by PHP (2017) by teh_klev on Friday March 22, 2019 @07:37AM (#19461556)
> that shows many websites has not been updated to work with latest PHP 7+, which I'd say is quite shameful

Speaking as an ex-hoster here who had to look after a fleet of shared servers running PHP (000's of sites) for 15 years, sadly life is not that simple in the trenches. The major problem with PHP is breaking changes. Even within the 5.x releases there were enough breaking changes such that upgrading from say 5.3 to 5.6 could break a site. The jump from 5.6 to 7.x has enough breaking changes to make you cry. I think there should have been a commitment to maintain 5.6 for the next ten years, if only for security fixes.

Now I'm not suggesting that developers shouldn't go back and fix stuff that breaks because the PHP folks removed/altered that functionality (with the good intentions of encouraging more secure programming, for example), but there's a labour cost and someone needs to pay for that time.

There's also functionality in PHP that shouldn't have been removed (register_globals) but should have been defaulted to disabled. Sure register_globals is insecure but what we saw were folks adding the same functionality back, just google for "php emulate register_globals".

And don't get me started about the annoyance that was removing mysql_* support. Those exact same insecure string concatenated queries are still being executed via mysqli_* and the PDO libraries. In my experience, binning mysql_* didn't make a damn bit of difference when it came to sql injection attacks.

Don't get me wrong, I admire the efforts of the PHP core team, but they made a rod for our already sore support backs whenever a new release of PHP shipped because of some fairly unnecessary BC's.

Re:80% of the Web Powered by PHP (2017) by phikai on Friday March 22, 2019 @10:19AM (#19462709)
THIS... elebenty billion %. The breaking changes of PHP upgrades make the hosting life a nightmare. It's so easy in the vacuum of a single developer with a single application to think everyone should keep up to date, but the reality is most of the PHP sites on the internet are owned by non-technical people.
Re:80% of the Web Powered by PHP (2017) by sowhatquestion on Saturday March 23, 2019 @01:21AM (#19469178)
> It's so easy in the vacuum of a single developer with a single application to think everyone should keep up to date, but the reality is most of the PHP sites on the internet are owned by non-technical people

"Non-technical" people who don't plan for maintenance costs to their software (including maintenance to keep up with dependencies like PHP) don't get a ton of sympathy from me ¯\_(ツ)_/¯

Re:80% of the Web Powered by PHP (2017) by DannyB2 on Friday March 22, 2019 @10:54AM (#19463073)
> The jump from 5.6 to 7.x has enough breaking changes to make you cry.

It's not just PHP. But Python 2x / 3x as well.

Just to point something out: this is one reason why Java is so well liked for large enterprise code bases. They have been religious about backward compatibility in new versions.

A 2nd principle I would advocate is that if there must be a breaking change, it should be caught at compile time, not at run time. The project should fail to build, and the errors point you to exactly where the source code problems are.

Other language systems would do well to embrace backward compatibility and build time errors over run time errors. IMO.

Re:80% of the Web Powered by PHP (2017) by teh_klev on Friday March 22, 2019 @11:12AM (#19463292)
> But Python 2x / 3x as well.

But at least the python folks provided some tooling to bridge the gap between v2 and v3 such as backporting features from python 3. Also minor version updates generally don't break whole codebases.

Apropos Java backwards compatibility, Microsoft has been pretty good at ensuring strong backwards compatibility with .NET code. I've seen .NET 1.0 source compile and run just fine on .NET 4. Hell I've even witnessed .NET 1.0 binaries run just fine without recompilation in newer .NET environments.

Sure there's breaking differences between .NET Standard and .NET Core but they're two different products and that was made pretty apparent from the get-go.

Re:80% of the Web Powered by PHP (2017) by consp on Friday March 22, 2019 @11:03AM (#19463180)
> ... But Python 2x / 3x as well.

That was one of the lowest effort upgrades I ever did for my company (backend services, no front end websites).

One of the other reasons Java is popular in big companies is the low effort it requires to find people who can work with it.

Re:80% of the Web Powered by PHP (2017) by fucking_tragedy on Friday March 22, 2019 @11:11AM (#19463282)
> That was one of the lowest effort upgrades I ever did for my company (backend services, no front end websites).

If your application does a lot of ASCII/unicode/raw string and byte manipulation, the transition from Python 2 to 3 can be very cumbersome.

Re:80% of the Web Powered by PHP (2017) by kevin_thibedeau on Friday March 22, 2019 @12:27PM (#19464133)
It's not like we didn't have 10+ years of forewarning and many available ways to prepare 2.x codebases for a smooth transition. My 2.7 code passes through 2to3 with only the occasional manual fixup required because I heeded the warnings.
Re:80% of the Web Powered by PHP (2017) by mywittyname on Friday March 22, 2019 @03:57PM (#19466296)
Java was designed upfront to be a language for large-team, long-lived, enterprise development. Whereas Python and PHP were originally toy languages that ended up filling a popular niche.

I mean, I agree with you. But Java benefits from well thought-out design constraints, ground-up IDE support, and an amazingly flexible bytecode interpreter. Normal people in the early 90s didn't have the resources to produce a language like Java.

Re:80% of the Web Powered by PHP (2017) by wvenable on Friday March 22, 2019 @01:51PM (#19465000)
> There's also functionality in PHP that shouldn't have been removed (register_globals) but should have been defaulted to disabled.

It was for years! They deprecated the feature. It was default disabled in php.ini. And now, as you said, if you really still need it you can code it yourself (I had to).

> And don't get me started about the annoyance that was removing mysql_* support.

I'm pretty sure that library isn't supported by MySQL server anymore (it's their library) so that's why it was removed. You can even use it to connect to newer versions of MySQL as the protocol changed.

Re:80% of the Web Powered by PHP (2017) by duiker101 on Friday March 22, 2019 @10:09AM (#19462628)
I had this problem just yesterday. A dev decided to update their XAMPP to a version that uses PHP7.3. Took us a while to understand why he was getting notices that no one else was getting. The compact function started printing notices of undefined variables since that version, it's a small thing, but I can see breaking a lot of stuff that is not expecting it.
Re:80% of the Web Powered by PHP (2017) by buboard on Friday March 22, 2019 @09:08AM (#19462148)
yeah the mysql_* function removal happened for no reason whatsoever. A library that did not need maintainance is something to keep , not throw away.
Re:80% of the Web Powered by PHP (2017) by leetbulb on Friday March 22, 2019 @11:19AM (#19463378)
This mysql extension was deprecated six years ago. It lacked support for many important features such as transactions, stored procedures, parameterization that were either often insecurely shoehorned or simply not capable.

http://php.net/manual/en/mysqlinfo.api.choosing.php

Re:80% of the Web Powered by PHP (2017) by sbarre on Friday March 22, 2019 @12:54PM (#19464382)
I think the point is that those functions could have just been aliased to other methods from other libraries, in order to maintain compatibility for older applications while removing the deprecated underlying library.
Re:80% of the Web Powered by PHP (2017) by teh_klev on Friday March 22, 2019 @11:28AM (#19463475)
Read my comment above where I explain why it was a pointless move:

>Those exact same insecure string concatenated queries are still being executed via mysqli_ and the PDO libraries. In my experience, binning mysql_ didn't make a damn bit of difference when it came to sql injection attacks.

Re:80% of the Web Powered by PHP (2017) by leetbulb on Friday March 22, 2019 @01:43PM (#19464924)
I don't care how safe you think your input validation is, concatenating strings and variables together should NEVER be done for SQL. Writing your own input validation for SQL is similar to "homebrew crypto." Even if it's mostly safe, it'll eventually bite you in the ass. You won't think of every possible attack vector. Same goes for shell, XSS, etc... In CTFs, you'd be surprised at some of the shit that you end up doing to exploit these types of vulnerabilities.

Unlike ext/mysql, ext/mysqli and PDO both support server side prepared statements. If you don't utilize this properly, your argument is moot.

Official discussion points here: https://wiki.php.net/rfc/mysql_deprecation#why

The way I see it is new features, better practices, and greater security versus convenience. If the latter won, the former would need to be implemented on an ancient codebase, possibly opening up many new issues. If the former won and there's enough demand for ext/mysql, development may be continued by the community or at least shimmed on top of a proper extension or library. These decisions were being made while PHP was trying to gain traction in the "modern" web development community, making massive overall improvements leading to PHP 7+ due to pressure of Hack & HHVM, and doing a pretty damn good job with it.

Sure it sucked to convert existing code, but looking back, I'm glad I did, even if ext/mysql were still available. Luckily some of the larger, more abstracted codebases I've had to convert meant simply writing and swapping out an adapter. Most of the codebases I see nowadays still utilizing ext/mysql were clearly destined to bitrot regardless and now have far more important problems to worry about because they weren't designed to be maintained this long or they've been poorly maintained from inception. Good riddance.

Re:80% of the Web Powered by PHP (2017) by Izkata on Friday March 22, 2019 @04:47PM (#19466773)
You seem to have totally missed the point: mysql_* were removed in order to prevent string-concat SQL from being used, but people just end up doing the same thing with the new methods, so there was no benefit to removing them.
Re:80% of the Web Powered by PHP (2017) by leetbulb on Friday March 22, 2019 @05:14PM (#19467033)
ext/mysql was not removed "to prevent string-concat SQL from being used." ext/mysqli and PDO allow raw SQL to be executed as well. It's just a necessary feature in some cases, but it should be reserved for static SQL.

Forming SQL by concatenating strings and variables is just bad practice and hopefully we can agree on that. ext/mysql provided no other option and this was just one of many issues with the extension.

Using ext/mysqli and PDO in a such a way (and I don't care if you're talking about retrofitting old code) is not even bad practice, it's just improper usage of the API when prepared statements should be used instead.

EDIT: Individually `print` `echo` `shell_exec` may be just as dangerous... It's up to the developer if they want to use them correctly.

Re:80% of the Web Powered by PHP (2017) by buboard on Friday March 22, 2019 @09:22PM (#19468458)
> Individually `print` `echo` `shell_exec` may be just as dangerous... It's up to the developer if they want to use them correctly.

and you don't have to install ext/mysql, they could just remove it from default configuration

Re:80% of the Web Powered by PHP (2017) by nkozyra on Friday March 22, 2019 @09:28AM (#19462297)
Even though it had no paramaterized/prepared queries and made injection issues abundant?
Re:80% of the Web Powered by PHP (2017) by buboard on Friday March 22, 2019 @09:43AM (#19462417)
not a fault of the library itself. also, mysqli_* has the same issue, was not removed
Re:80% of the Web Powered by PHP (2017) by nkozyra on Friday March 22, 2019 @10:07AM (#19462616)
It doesn't matter whose fault it is; if it provides no mechanism for prepared queries, it should be replaced.

mysqli_ has prepared queries, so it offers an immediate improvement.

Re:80% of the Web Powered by PHP (2017) by teh_klev on Friday March 22, 2019 @10:58AM (#19463123)
You missed my point. All developers did was replace their mysql_* calls with mysqli_* calls but skipped out on the parameterising step. Sure they're using a parameterised capable API, but they're not actually parameterising their queries.

In the real world dropping the mysql_* API achieved next to bugger all, we still ended up with a bunch sites with exactly the same SQL injection vulns.

Re:80% of the Web Powered by PHP (2017) by nkozyra on Friday March 22, 2019 @11:09AM (#19463261)
> All developers did was replace their mysql_*

They did? All of them? Nobody moved to paramaterized queries?

Re:80% of the Web Powered by PHP (2017) by teh_klev on Friday March 22, 2019 @11:15AM (#19463329)
When you work for a mass market shared hoster you get to see all sorts of ugliness, dirty hacks, incompetence and just plain lazyness.
Re:80% of the Web Powered by PHP (2017) by ars on Friday March 22, 2019 @01:52PM (#19465008)
New code sure? But existing code? Especially large projects? No.
Re:80% of the Web Powered by PHP (2017) by nkozyra on Friday March 22, 2019 @04:52PM (#19466818)
I am 100% a LOT of projects fall under this umbrella, but:

1) this is not an argument for leaving an inferior library in the language

2) plenty of people do update their software, for old code and large projects. Why not push people toward the better library?

Re:80% of the Web Powered by PHP (2017) by creeble on Friday March 22, 2019 @10:52AM (#19463059)
Why couldn't the mysql_ library just have added prepared queries? I've never understood this (not a PHP programmer, just someone who has had to patch a dozen sites that were suddenly broken once).
Re:80% of the Web Powered by PHP (2017) by lugg on Friday March 22, 2019 @11:11AM (#19463280)
MySQL libraries are extensions.

The mysqli library was likely a full rewrite in another extension. Extensions, at least that kind, at that time, didn't use/have namespaces.

Keep in mind this is a legacy code base with a function called mysql_real_escape string, like if you're at that point you're so far past gone you've lost all hope.

Re:80% of the Web Powered by PHP (2017) by buboard on Friday March 22, 2019 @02:42PM (#19465598)
> like if you're at that point you're so far past gone you've lost all hope.

for a 25 year library, thats not at all too bad. And even PHP developers admit that the lib was "not broken"

Re:80% of the Web Powered by PHP (2017) by reaperducer on Friday March 22, 2019 @11:19AM (#19463377)
mysqli_ has prepared queries, so it offers an immediate improvement.

Only if they're used. If mysqli_ required prepared statements, then it would be different. But the sins that were committed with mysql_* could still be committed with mysqli_*.

Re:80% of the Web Powered by PHP (2017) by nkozyra on Friday March 22, 2019 @02:39PM (#19465566)
Absolutely, the idea was to provide prepared queries while allowing people to migrate their code.

The point wasn't "this fixed the injection problem" it was that it provided a solution not available for mysql_

Re:80% of the Web Powered by PHP (2017) by buboard on Friday March 22, 2019 @02:45PM (#19465632)
> It doesn't matter whose fault it is

it does for old code. and many people prefer a website with bugs than a website that doesn't work at all. And any website that was vulnerable to mysql_* attacks should have already been hacked out of existence by now.

Re:80% of the Web Powered by PHP (2017) by ddebernardy on Friday March 22, 2019 @12:24PM (#19464094)
Unless something has changed since the early 2000s, `mysqli_` doesn't have a gazillion PHP/MySQL tutorials that are riddled with insecure code. That alone was a good reason to deprecate `mysql_`.
Re:80% of the Web Powered by PHP (2017) by jwat0v on Thursday March 21, 2019 @09:15AM (#19451905)
I don't know if it's shameful but it's expected.

Of those PHP websites, most of them are probably wordpress. How many of those haven't been updated in ages?

That's way more dangerous than running PHP 5, taking into account all distros will backport security fixes for years to come.

Re:80% of the Web Powered by PHP (2017) by uses on Friday March 22, 2019 @10:32AM (#19462859)
Probably worth noting that WP is planning on requiring PHP 7 by the end of 2019 https://make.wordpress.org/core/2018/12/08/updating-the-mini...
Re:80% of the Web Powered by PHP (2017) by piotrkubisa on Thursday March 21, 2019 @09:33AM (#19452085)
Yes, that's true you can find many web sites using Wordpress, or other popular CMSes like Joomla, forum boards i.e. phpBB or even e-commerce stores based on OpenCart / ZenCart / Prestashop haven't seen an update for a quite long time. Personally, I'd be glad to offer my free time to help i.e. update Wordpress (recent versions has auto-update feature) or even migrate to static-site, especially whether I am returning user of such website.
Re:80% of the Web Powered by PHP (2017) by antsar on Friday March 22, 2019 @08:38AM (#19461942)
The hard part isn’t updating. It’s checking what got broken by the update, and fixing that. Then finding out one of the plugins is no longer supported, researching alternatives, and rebuilding half the site to use a new thing.
Re:80% of the Web Powered by PHP (2017) by piotrkubisa on Friday March 22, 2019 @02:38PM (#19465553)
Tip: static analysis tools for PHP helped me during a rewrite from 5.6 to 7.0. It was really good experience, I'd say.
Re:80% of the Web Powered by PHP (2017) by antsar on Sunday March 24, 2019 @09:31PM (#19479726)
Same here. Sadly, I don't know of any static analysis tools that can detect inter-compatibility of different versions of WordPress plugins/themes/core. That's one aspect of WordPress maintenance that can get real hairy.
Re:80% of the Web Powered by PHP (2017) by simion314 on Thursday March 21, 2019 @09:23AM (#19451988)
From my experience WP autoupdates

Do you expect all node small and medium completed projects run on latest node?

Re:80% of the Web Powered by PHP (2017) by corobo on Friday March 22, 2019 @07:02AM (#19461307)
WordPress core autoupdates. Plugins will happily remain exploitable for years if you're not on top of their security updates.
Re:80% of the Web Powered by PHP (2017) by acomjean on Friday March 22, 2019 @09:02AM (#19462105)
Since the article is from 2017 php 7 was kind of newish then. I think its seen pretty rapid adoption (mainly because additional speed means fewer servers.).

PHP has adopted a strategy of rolling version upgrades with defined end points. They probably should have some "LTS (Long Term Support) type releases.

http://php.net/supported-versions.php

5.6 just reached eol. I think they've put out a securtiy patch since then so its (not quite) completely abandoned.

If people aren't forced to upgrade their sites, they won't. So there is huge incentive to just keep running the older versions.

Re:80% of the Web Powered by PHP (2017) by tzs on Friday March 22, 2019 @01:28PM (#19464770)
Many sites run an LTS release of a Linux distribution until support ends, and then update to either the next or the latest LTS release of that distribution, which they then stay on as long as it is support, and so on.

Debian 8 (Jessie) still has a little over a year left, for example, and is on PHP 5. Ubuntu 14 is just nearing the end of support, and is on PHP 5. Same with OpenSUSE and CentOS.

I'm not sure what the Red Hat situation is, because the pages at Redhat that Google found that would probably tell me are in the knowledge base, and will only show me the question, telling me I have to be a Red Hat subscriber to see the answer.

This is one of the annoyances with some major frameworks. According to both the Symfony and Laravel requirements pages, they need PHP 7.1.3. As far as I can tell that's not included in any LTS release of any major Linux distribution, which top out at 7.0.33 currently, I believe.

PS: interesting oddity somewhere in HN. When on the "reply" screen for your comment, HN says your comment is 1 day old. However, back in the thread, or on a direct link to your comment, it says that it is 6 hours old. It does the same thing for all 6 hour old comments in this thread, but not 5 hour old comments.

Re:80% of the Web Powered by PHP (2017) by btreecat on Friday March 22, 2019 @02:37PM (#19465543)
And this is why as a developer, I adopted docker.

Oh you cant run lib/framework/tool due to host deps? No problem, I will just replace you with a script.

Re:80% of the Web Powered by PHP (2017) by pjmlp on Thursday March 21, 2019 @10:20AM (#19452626)
Many ISPs now do opt-in for their customers.

For example by default the Website runs in PHP 5.6 and it is up to the site owner to change the local site version to a newer version via cPanel or similar.

So non technical users that just know a bit of PHP or use some CMS, end up being stuck with the default version.