News for hackers. Stuff that matters.
Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by lkrubner on Tuesday January 16, 2018 @04:26PM (#16162796)
I almost wrote a similar comment, but I figured I would be downvoted. I realize it sounds cynical, but why should this effort be made for PHP? I loved PHP back in the year 2000, and at that time it had advantages that no other language had, but those days are long gone. There are many better languages now. I wrote about this in my essay "PHP is obsolete" and there was a fairly good conversation about that essay on Hacker News:

https://news.ycombinator.com/item?id=9598309

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by tyingq on Tuesday January 16, 2018 @05:52PM (#16163550)
It is still popular with newcomers, people that don't come from a structured CS background, etc. Because the barrier to entry is just so low. Meaning, it's a built in, working option on hosting providers, deceptively simple in the beginning, etc. Also, PHP still dominates the "host it yourself e-commerce" space, because of Magento, Opencart, and PrestaShop. Oh, and WordPress...it's some insane percentage of all sites. And lousy plugins are everywhere.

We could ignore that crowd, but guiding them down the right path is better for everyone.

Edit: I'm also not convinced that node.js, which is gaining ground with the same crowd, doesn't have similar issues. Footguns aren't unique to PHP.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by duskwuff on Tuesday January 16, 2018 @08:07PM (#16164572)
The availability on hosting providers is a HUGE deal. Sure, you can write an application in Python, or Node, or Java, or whatever else is theoretically better... but good luck finding somewhere to host it that's cheap and doesn't require you to do all the sysadmin work yourself (i.e, not a VPS).

PHP may not be the best of all possible languages, but it's by far the most widely available.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by tyingq on Tuesday January 16, 2018 @08:33PM (#16164715)
I agree. And, as mentioned, these hosting providers will likely make node.js just as simple soon, and node will replace php as the whipping boy for flippant remarks. What's old is new again. This is more about providing newbies with good advice than it is about PHP.
Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by duskwuff on Tuesday January 16, 2018 @10:00PM (#16165122)
Honestly, I don't see that happening soon, if ever. PHP was easy for hosting providers because it was easy to plug in to existing virtual hosting support in Apache and FTP servers. Node is more complicated; there's no obvious "right" way to handle many Node apps running on a single shared server.
Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by tyingq on Tuesday January 16, 2018 @10:29PM (#16165231)
There were several ways for PHP too, and still are, FWIW. The shared hosting providers eventually settled on the best compromise of price/performance/security.

What they provide now is better and more scalable than old school CGI. Most of the shared hosts are using LightSpeed[1] as it squeezes as much as possible out of PHP in a shared environment. That vendor, and their low end shared host customers, aren't dumb. They will respond to market changes and make node.js a 1st class support item when it is clear that's where the money is.

[1]https://www.litespeedtech.com

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by open-source-ux on Tuesday January 16, 2018 @07:09PM (#16164186)
For web development, PHP still has a key advantage that no other language can match: ease of deployment. Many developers woefully underestimate how important this is, particularly if non-technical users need to self-host your software.

Telling potential users to spin up a VPS or type some command line instructions to install code is too complicated for many users, even though it may seem trivially easy to a developer.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by kbenson on Tuesday January 16, 2018 @07:51PM (#16164496)
Actually, I think the current state of the art is significantly easier than PHP was, in that you just choose your langauge and the framework written in your language, start it and go to localhost and some port. It used to be that you had to have a web host, and then( sure you could just drop PHP in place, but you still needed that host. Setting anything up yourself required twiddling with Apache and mod_php (or using a distro that shipped with packages that enabled it by default).

The whole "start up a little webserver in the same language" trend makes everything much* easier to develop.

Where PHP still has an edge is deployment for non-development. If you just want to drop in some software and use it on the web (e.g. a bulletin board), PHP is still easier in many cases for novice users. But that's not development, it's just deployment.

I would even hazard that correct deployment of that software in a secure way is made harder by PHP's ease of deployment, as you have to rely on permissions in lieu of separate locations that have no remote read access, as many frameworks implement.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by lmm on Wednesday January 17, 2018 @05:41AM (#16166901)
> The whole "start up a little webserver in the same language" trend makes everything much* easier to develop.

I actually agree, but that's not the approach that's pushed. In python the "tiny http server" is explicitly advertised as insecure and unsuited to production use. In Java, embedding Jetty involves dozens of arcane lines and manually translating suggested XML files into code - not something a beginner can do. What other language than PHP can I dump a single file on a shared host and have it be running?

(Ironically Java is actually a legitimate answer here, if the shared host ran an application server like Tomcat and accepted .war uploads. But I don't think I've ever seen a shared host that offered that?)

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by kbenson on Wednesday January 17, 2018 @11:39AM (#16169313)
> I actually agree, but that's not the approach that's pushed. In python the "tiny http server" is explicitly advertised as insecure and unsuited to production use.

Sure, but we're talking about developing, and that's a pretty easy way to get started.

In Python, don't you have Gunicorn, Tornado and Twisted?

In Perl there's Mojolicious and Dancer.

Ruby has Rails, Sinatra and probably a least a few more.

Java... Well, IMO Java has a habit if either not delivering simple smaller projects, or communicating they exist very poorly (but I'm not really in the loop so my opinion may be very uninformed). Tomcat was too big and complex to fit this need a decade ago, so I doubt it does it well now (but maybe I'm wrong?).

> What other language than PHP can I dump a single file on a shared host and have it be running?

My point is that needing a shared host to get started is actually a step you often don't have to wait for now. If you're a developer, it's easier to just start up your dev locally and work out hosting in a bit.

If you're developing something beyond the simplest things, the host allowing drop in scripts is not actually a problem I think. For anything that's super quick and dirty, you still have CGI.

That's the point I was making. The drop in script support isn't really all that beneficial to PHP developers, but it is very beneficial to regular user that just was to deploy a PHP webapp of some sort, such as a bulletin board or blog software.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by lmm on Wednesday January 17, 2018 @11:55AM (#16169506)
> Sure, but we're talking about developing, and that's a pretty easy way to get started.

> My point is that needing a shared host to get started is actually a step you often don't have to wait for now. If you're a developer, it's easier to just start up your dev locally and work out hosting in a bit.

I have to disagree. It's silly to try to develop something you can't actually run. Getting your software in front of actual users is the critical path; everything else is secondary. (And exposing your dev laptop as a web host on the internet is pretty complex in practice for most people, quite aside from whether it's a good idea)

> For anything that's super quick and dirty, you still have CGI.

Do any of the frameworks you listed (Gunicorn or Mojolicious or Rails or...) support running as CGI? Is it documented in their tutorials?

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by kbenson on Wednesday January 17, 2018 @12:56PM (#16170104)
> I have to disagree. It's silly to try to develop something you can't actually run. ... (And exposing your dev laptop as a web host on the internet is pretty complex in practice for most people, quite aside from whether it's a good idea)

It's trivial to run. Get a minimal AWS instance, or a small digitalocean instance, or whatever. Hosting is not a problem these days. Godaddy is offering managed (they patch and provide support) VPS instances for $18/mo right now. Surely not as cheap as some dedicated host, but also more secure and if you're actually spending your time developing something, not a lot to pay.

Nobody is saying expose your laptop to the internet. But getting started isn't about getting someone to look at your stuff, it's about actually getting started and getting some code written.

> Do any of the frameworks you listed (Gunicorn or Mojolicious or Rails or...) support running as CGI? Is it documented in their tutorials?

When you control the webserver running a subprogram as CGI (which is what I was referring to) is trivial, and can be handled in a few lines of code.

If you're talking about whether the framework has instructions on how to run as a CGI, I'm going to go out on a limb and say yes, they all do because that's step one in telling people how to run your stuff when making a framework, where it makes sense. In some cases it's just a WSGI/PSGI etc server and you can interchange them. It may not make sense to run twisted as a CGI, but if you write WSGI you can just use django, which does support deployment as a CGI. Mojolicious and Dancer support it. I'm pretty sure Rails and Sinatra do in some way to.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by lmm on Thursday January 18, 2018 @07:16AM (#16176510)
> It's trivial to run. Get a minimal AWS instance, or a small digitalocean instance, or whatever. Hosting is not a problem these days. Godaddy is offering managed (they patch and provide support) VPS instances for $18/mo right now. Surely not as cheap as some dedicated host, but also more secure and if you're actually spending your time developing something, not a lot to pay.

These trivial things matter when you're getting off the ground. Dropping money on that idea you were playing with in your evenings is a big psychological step. A couple of hours faffing with server admin can be even more offputting.

> Nobody is saying expose your laptop to the internet. But getting started isn't about getting someone to look at your stuff, it's about actually getting started and getting some code written.

Disagree. The goal isn't to write some code, the goal is to get a viable business, and these days business concerns - the famous product-market fit - are a much bigger risk factor than technical ones. A mostly-static page with a simple text form that can start getting you actual customers puts you much closer to that than any amount of code running on your dev laptop. (It's different when technical innovation is at the core of the business - when the actual code is the biggest risk factor - but in that case you're probably not doing web stuff and probably not using any of these languages).

> If you're talking about whether the framework has instructions on how to run as a CGI, I'm going to go out on a limb and say yes, they all do because that's step one in telling people how to run your stuff when making a framework, where it makes sense. In some cases it's just a WSGI/PSGI etc server and you can interchange them. It may not make sense to run twisted as a CGI, but if you write WSGI you can just use django, which does support deployment as a CGI.

It's never "just" though; these differences are important. Every extra step beyond "upload this file to the host" probably cuts the number of projects that get off the ground in half. And a lot of these frameworks will tell you how to "run" them in a one-off way but completely gloss over how to set them up so that they'll still be running after you restart the server you're hosting on.

I just had a quick look through the django tutorials to check I wasn't talking nonsense and it's even worse than I thought. The "installing" page gestures vaguely in the direction of virtualenv (which is how people actually use django in practice) but it's not integrated in the tutorial at all. The 7-page "beginner tutorial" only ever uses the officially-not-secure-enough-for-production local development server. I was excited by the link to an "advanced tutorial about creating reusable apps", but turns out that's just telling you how to package up your webapp so that other people can run it locally with the development server. Nothing about WSGI, not one word about how to actually put your "webapps" on the web. I don't mean this as an attack on django specifically - I like django, and it's documentation and tutorials are better than a lot of options - but no wonder people keep using PHP.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by fizdoonk on Wednesday January 17, 2018 @12:15AM (#16165651)
>sure you could just drop PHP in place, but you still needed that host. Setting anything up yourself required twiddling with Apache and mod_php (or using a distro that shipped with packages that enabled it by default).

php has builtin webserver since 5.4. that's like 5-6 years ago

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by kbenson on Wednesday January 17, 2018 @03:46AM (#16166454)
If we're talking about the rise and dominance of PHP, we're talking about 10-15 years ago.
Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by CiPHPerCoder on Tuesday January 16, 2018 @04:33PM (#16162866)
> but why should this effort be made for PHP?

See https://w3techs.com/technologies/overview/programming_langua...

Anyone who wants a more secure Internet must necessarily be interested in improving the security of PHP.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by code_duck on Tuesday January 16, 2018 @07:50PM (#16164487)
The figures on that page don’t mean that 83% of developers use PHP... Just that some things written in PHP are very popular. I’m sure that most of that figure is packages like WordPress.
Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by CiPHPerCoder on Tuesday January 16, 2018 @08:28PM (#16164696)
Most of the Internet (5 out of 6 websites) is powered by PHP. This is true despite people saying "don't use PHP".

I didn't imply that 83% of developers use PHP. I'm sorry if anyone read it that way. I'm zeroed-in on the "what powers the Internet" statistic.

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by corobo on Tuesday January 16, 2018 @06:39PM (#16163974)
> why should this effort be made for PHP

Because people get into programming via PHP via writing extensions for popular PHP software (WordPress) because that's what they can get paid to do as an entry level dev. It would be prudent to have them get into it in a way that doesn't cause exploits.

Sure everyone and their dog may one day get into programming via Javascript via Ghost or something else along that line, but that's just not how it is right now. How it is right now is people writing HTML forms that post into raw SQL queries - you can make rookie mistakes like that in any language, no matter which one happens to be the top dog of the moment.

I also have to note that on a skim a lot of the comments you linked to can be distilled to "No it isn't"

Re:Our Ambitious Plan to Make Insecure PHP Software a Thing ... by meritt on Tuesday January 16, 2018 @08:23PM (#16164666)
> but why should this effort be made for PHP?

Why not? There's a large and active community, both the core dev team actively improving it, and millions of programmers building applications.

Just because you don't like something doesn't mean the rest of the world agrees with you.