'Month of PHP Security' Finds 60 Bugs
darthcamaro writes "More than 60 bugs were reported in PHP over the last 30 days by the Month of PHP Security project. Most of the flaws, however, are ones that developers themselves can protect against with proper coding practices, according to Andi Gutmans, CEO of commercial PHP vendor Zend. He argues that PHP security is a matter of setting expectations. In his view, PHP — like all development languages — is only as secure as the code developers write with it. 'People should not expect PHP to be able to enforce security boundaries on a developer [who] has permissions to run custom PHP code,' Gutmans said. 'It's an inherently flawed scenario — and it's the wrong layer to protect in. People must rely on properly configured OS-level permissions for securing against untrusted developers.' Gutmans also praised the MOPS effort for elevating the profile of PHP security throughout the community, and for responsibly alerting the PHP project first with the bugs they found."
Sorry this is long, I could probably write a whole dissertation on my thoughts on PHP though.
I've been developing in PHP since version 2 way back in '97 and I've always felt that one of PHP's biggest downfalls is that it has a configuration file. I understand that it has more to do with its origins as an Apache module, but I can't think of many modules or programming languages that are so customizable as PHP is. Over the years this has led to different schools of programmers choosing one setting or another and chastising people who use a different setting.
Another big problem is that the core developers don't seem to get just how large the PHP community is. I found out some months ago that they were deprecating the ereg/POSIX regex set of functions in 5.3 and will be removing them in 6. I bought up on the mailing list that I think this is too quick of a time table for it being removed and that they should have it marked deprecated for at least 1 major version before removing it. Their excuse was that they really wanted to get UTF-8 support in PHP (a commendable goal) and the ereg functions weren't compatible and are also too slow. So now they are pushing the preg functions which are based on PCRE. Ironically all this time I've been avoiding the preg functions because I figured they were the more likely candidates to go away.
And I'm not alone. Many many people out there have been using ereg in lots of code over the past decade and its going to be a huge shock for them when it comes time to switch suddenly. When 50%+ of the dynamic web uses PHP, this is going to cause lots of problems over the next 5-10 years.
Yes yes, I know that there is work on a PEAR module to substitute the functionality of ereg, but my point is that the core developers seem to be in their own world and aren't thinking about the overall affects of their decisions and how far reaching they are.
Once a company starts using phrases like "setting expectations" their end is near.
As long as you expect PHP and the majority of code written in it to be insecure, you're expectations will be met. We call this setting your expectations appropriately. If you expect security from PHP, well, you need to learn to set your expectations appropriately.
"I use a Mac because I'm just better than you are."
At least they are working on finding bugs. The fact that they _found_ bugs shows that they are doing a thorough job.
This is A GOOD THING (TM)
Seven Days with Ubuntu Unity
I can live with the settings file, PHP has many more fundamental flaws than disparate configurations. The only real configuration schism I'm aware of was register_globals vs. not register_globals.
That and magic_quotes_gpc on or off. The ill-advised feature was on by default in PHP 4, and though official PHP 5 turned it off, a lot of shared hosting providers turn it back on to remain compatible with legacy PHP 4 code that their hosting clients might still be using.
...can be a good idea as a standard practice.
Bugs in the bloated function list can last for years. Interfacing with external applications can often be incomplete - see the memcache versus memcached extensions. The best solution in one version may not be in the next, and may not even be available shortly after (see all the changes they are making to version 6).
And yet, php is good where it dominates - pulling data from MySQL and shoving it through FastCGI. If someone ends up forking php 5.3/5.4 to flesh it out as a language, I would seriously consider looking at it.
Adult Role Playing Forum
"People must rely on properly configured OS-level permissions for securing against untrusted developers"
People must rely on a size 13 boot to the head for securing against untrusted developers.
I mean really, if you don't trust your developer, fire the incompetent lying sack of shit. I don't consider myself a super coder (anymore), but it's not exactly rocket science to secure the average PHP script. Sanitize the inputs, escape any SQL parameters (or use prepared statements), and if your app needs to do stuff like "exec('sudo rm -rf /')", you just might want to rethink what it is you're trying to do for your lusers.
The reason PHP takes so much flak is because it's a very popular, rather easy, and embarrassingly sloppy hodge-podge of diverse functionality. By that virtue, it attracts a larger-than-usual share of troublesome coders and users. Nobody's ever really heard of vulnerabilities in, say, A+, because there's only about 3 people who use that language.
-Billco, Fnarg.com
People must rely on properly configured OS-level permissions for securing against untrusted developers.
Why not also blame the web server, the middleware (e.g., Tomcat/Jboss/etc), the database, and the client-side browser as well? While security problems at these layers certainly exist, they don't excuse any problems in PHP--and they certainly don't exonerate any developer for writing insecure code in the first place.
php 6.0 isn't even finished yet. It took years for php5 to get adopted - which isn't even available on some crappy hosts - and the inertia holding php5 is going to be that much stronger, if only because it's not in the atrocious state it was in with version 4. People aren't going to pick up version 6 on a whim, exactly for reasons like this.
Adult Role Playing Forum
Adult Role Playing Forum
If you "can protect against [the bugs] with proper coding practices", are they really "bugs"? I would say not.
Everyone posts that simply good coding practices will solve your problems. I didn't read through all of the security flaws they are now reporting, but good coding doesn't overcome flaws in the language. If these flaws allow for security problems, it is of great concern! When parts of a language don't always function they way you expect, how are you supposed to code. I really don't want to have to code exceptions, triggers, catches and the like for every part of the language I use. That's silly. Don't tell me proper coding solves all security flaws when you don't even know where the bugs are.
jsut athnoer menagiensls ltitle psrhae for you to dcoede. Why do we wtsae our tmie dnoig tihs?
LOL, yes, the above PHP example will complain about the semicolon missing behind the "PHP". *sigh*
Anyway... I thank PHP... for giving me the motivation to finally learn Haskell. :)
Any sufficiently advanced intelligence is indistinguishable from stupidity.
I find it very confusing that Redhat server version 5 only provides 5.1.x php as a standard installation.
This is not even an still a supported branch of php by the php community so I assume none of these fixes that will be coming out in the next php 5.2.x or 5.3.x version may make it into RedHat 5 server. Considering that none of these holes are considered critical is more reason for RedHat to not bother with backporting.
Anyone find it a problem that Redhat installs in corporate environments do not provide a php version that is under active development?
I ran into this one today.
array_search(needle, haystack) - returns first occurrence of needle. If you need all the occurrences use array_keys the the optional array_search parameter. That is...
array_keys(haystack, optional needle)
Ugh.....
But wait, I guess that makes sense because the needle is optional for array_keys but you always pass the haystack.
It's a nasty mess but it work fairly well. Just keep the docs handy.