Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

'Month of PHP Security' Finds 60 Bugs

kdawson posted more than 4 years ago | from the new-mops-sweep-clean dept.

PHP 120

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."

cancel ×

120 comments

Sorry! There are no comments related to the filter you selected.

One of the biggest problems is configurability (5, Interesting)

suso (153703) | more than 4 years ago | (#32459788)

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.

Re:One of the biggest problems is configurability (1)

Anonymous Coward | more than 4 years ago | (#32459814)

> 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

Well, sure. Why do you think there are two sets of regex functions in the first place?

PHP is a mess exactly for this reason. Features are implemented several different ways, made to conform to unhelpful C-like syntax, and crammed in wherever they will fit. The whole language is broken, and while security problems are never solely the fault of the programming language, PHP surely doesn't help security nearly as much as I'd expect from a modern Web language.

Re:One of the biggest problems is configurability (4, Insightful)

MightyMartian (840721) | more than 4 years ago | (#32459816)

The configuration file is a problem, to be sure, but the real problem is their insane library which seems to fit no particular convention. It's goddamned madness and makes coding an incredibly painful experience as you constantly run back and forth to the online manual to get the exact name of the function. Out of that comes the constant deprecating and synonyms. I find PHP a painful, awkward language to code in, but because I do so much work supporting legacy stuff, I'm stuck with it.

Re:One of the biggest problems is configurability (5, Funny)

ajrs (186276) | more than 4 years ago | (#32459888)

You young kids and your legacy php applications. Get off my network.

Re:One of the biggest problems is configurability (2, Interesting)

ceeam (39911) | more than 4 years ago | (#32459928)

Any sufficiently useful in real life set of libraries suffers from the same problems.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32460024)

Name one as large and as mature as PHP with such hideous problems.

Re:One of the biggest problems is configurability (1)

ceeam (39911) | more than 4 years ago | (#32460080)

Python. WinAPI. Enough?

Re:One of the biggest problems is configurability (3, Informative)

shutdown -p now (807394) | more than 4 years ago | (#32460180)

Stock Python libraries don't suffer from this to the extent PHP ones do.

WinAPI is twice as old.

Re:One of the biggest problems is configurability (1, Insightful)

Anonymous Coward | more than 4 years ago | (#32461648)

So wait, you need an example that is *exactly* like PHP, otherwise you will shoot it down with a worthless one liner?

Well, here's one: PHP

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32464454)

Saying something isn't as bad as the Windows API is the equivalent saying, "At least we're not as bad as China." Maybe technically true, but you're not exactly setting up a good standard for yourself.

Re:One of the biggest problems is configurability (1)

i_ate_god (899684) | more than 4 years ago | (#32460846)

Name one as large and as mature as PHP with such hideous problems.

Java Standard Library? It's a convoluted horrendous mess that requires five times as much code compared to Python or Ruby or even PHP to accomplish.

PHP's messy "standard library" is nothing compared to Java's convoluted "standard library"

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32462002)

It's a convoluted horrendous mess that requires five times as much code

But are search functions always (needle,haystack), or are half of them haystack first?

Re:One of the biggest problems is configurability (1)

i_ate_god (899684) | more than 4 years ago | (#32462610)

It's a convoluted horrendous mess that requires five times as much code

But are search functions always (needle,haystack), or are half of them haystack first?

This is a huge annoyance for sure. Having coded in all the above mentioned languages, I can definitely say that when I look at explode, stristr, str_replace, etc in PHP, their lack of consistency bugs the hell out of me, but it's easy to work around.

http://www.php.net/ [php.net] and now I know. Do that a few times and I'll remember.

Re:One of the biggest problems is configurability (1)

nxtw (866177) | more than 4 years ago | (#32466144)

PHP's messy "standard library" is nothing compared to Java's convoluted "standard library"

Java has namespaces [wikipedia.org] and the standard library uses them. Obvious troll is obvious.

Re:One of the biggest problems is configurability (4, Insightful)

0racle (667029) | more than 4 years ago | (#32460042)

I wouldn't say that Perl or Python suffer from what PHP suffers from.

Re:One of the biggest problems is configurability (4, Funny)

Zarf (5735) | more than 4 years ago | (#32460400)

I wouldn't say that Perl or Python suffer from what PHP suffers from.

No. They don't suffer from it they thoroughly enjoy it.

Re:One of the biggest problems is configurability (1, Insightful)

the_B0fh (208483) | more than 4 years ago | (#32461362)

Some people shouldn't be given modpoints. What kind of moron marks such an obvious joke flamebait?!

Re:One of the biggest problems is configurability (2, Informative)

pjfontillas (1743424) | more than 4 years ago | (#32461936)

Hopefully someone who does get the joke and has mod points can help fix that. That's how the system is supposed to work... now if it would actually happen...

Re:One of the biggest problems is configurability (1)

ceeam (39911) | more than 4 years ago | (#32464014)

Note to you: you have just used Perl in a positive context in a thread about programming languages consistency.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32460092)

the same problems, maybe, but on a much smaller scale. PHP is the Tucker Max of languages.

Re:One of the biggest problems is configurability (1)

ceeam (39911) | more than 4 years ago | (#32460122)

> on a much smaller scale

Since we don't probably have any formal metric for that, I don't see how we can settle this argument.

By subjective feelings, I disagree.

Re:One of the biggest problems is configurability (5, Insightful)

mcrbids (148650) | more than 4 years ago | (#32460136)

I use PHP and I love it as a language. It's powerful, stable, and lets me get lots of work done quickly.

That said, you hit on the two biggest annoyances I have with PHP:

1) Argument order: is it myfunction($haystack, $needle) or myfunction($needle, $haystack)? There's no rhyme or reason that I can consider, mostly just random stuff.

2) Function names: Is it going to be isinteger() or is_integer()? And even within a set of otherwise closely rlated functions, while php has is_integer(), is_set() is actually isset(). Who thought this was a good idea?

Again, I don't want to knock PHP too badly, it's a lean mean workhorse of a language, and its many strengths vastly outweigh its weaknesses. But couldn't they pick a convention and move to it?

Re:One of the biggest problems is configurability (3, Insightful)

Luke has no name (1423139) | more than 4 years ago | (#32460966)

This, and the lack of a namespace concept (until recently) make me wonder, "Who would begin a greenfield web application in PHP when you have Python/Ruby/(kinda) Perl?" These are all strong languages. Ruby is fascinating, though it's only now coming into its own.

Seriously, tell me, because I don't get it. You say its strengths outweigh its weaknesses. We've pointed out some damned big weaknesses, so what are its unique strengths?

Re:One of the biggest problems is configurability (4, Insightful)

Mr. Shiny And New (525071) | more than 4 years ago | (#32462462)

PHP's strength: ubiquity. PHP is installed everywhere, so if you are intending for your application to be deployed on diverse machines with low-cost hosting it is a good bet. I like to code in Java but for my home website it's all PHP because that comes free with my hosting provider, whereas better environments are more complicated to set up or more expensive.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32462662)

What you say is absolutely true. When I need value hosting, I go out of my way to find hosts who offer plans that don't include PHP by default. That way I know they're a responsible host, and don't voluntarily compromise their servers by installing software that's knowingly insecure and full of bugs and security holes.

Re:One of the biggest problems is configurability (5, Interesting)

Quirkz (1206400) | more than 4 years ago | (#32462552)

"Who would begin a greenfield web application in PHP when you have Python/Ruby/(kinda) Perl?" These are all strong languages. Ruby is fascinating, though it's only now coming into its own.

Well, I'm one of those people. In college I was trained in Fortran and then C++, and PHP has always seemed pretty friendly and intuitive in comparison with those. At least on the surface other than minor differences in syntax I could transition from one to the other to the next without too much difficulty.

Every time I've looked at Perl, it's been downright indecipherable. I've edited a few existing scripts, tried reading not one but two books on it, and mostly I walked away feeling just as confused as when I started.

As for Ruby and Python, when I started needing to code web applications, I'd never heard of them. They may be coming into their own now, but why should I start over with a new language when I can already do what I want with PHP? I don't know much about either, but at least peripherally I've been confused by some impression that with Ruby there are varying implementations (on Rails versions, versus who knows what else), and Python being the frequent butt of jokes here on slashdot hasn't ever made me want to research it to find out more.

It may be a poor excuse, but that's why I'd start my next project in PHP. You may call it prejudice and ignorance against other languages; I call it being happy with what's been working just fine for me over the past decade.

Re:One of the biggest problems is configurability (1)

Luke has no name (1423139) | more than 4 years ago | (#32463916)

I learned enough Perl to write file grabbing and parsing scripts within a week of work. This is simple stuff, and it was just as much about learning Regex as it was Perl. Point is, Perl is just another language, thought it is not syntactically beautiful, so to speak.

Ruby and Python both have a strong mainline; there are not several /competing/ implementations as you seem to be concerned about with Ruby. Also, Python is awesome, and lots of people use it. That's why it's made fun of here :)

Quirkz, I get your point. You know what you know it and works. PHP isn't broken, I just don't think it's the best tool anymore. Maybe in the 1995-2005 era, but I think it's prime is past.

To Mr. Shiny And New above, I agree, PHP is everywhere. And that argument is one of the few I appreciate, and it saddens me. It saddens me because that's a circular problem: Something is only cheap and easy because it's used a lot, and it's only used a lot because it's cheap and easy. Python/Ruby are better than PHP IMO.

Re:One of the biggest problems is configurability (2, Informative)

Gulthek (12570) | more than 4 years ago | (#32465302)

That's only because you haven't taken a serious look at Django or Rails. Every diehard PHP coder that I've shown something like the Django admin interface, web form creation/management or something like ActiveRecord and fundamentally integrated testing in Rails has been absolutely stunned at how much low-level work has either been obviated or eliminated entirely. Both frameworks really free you to work on the high level fun stuff of a web application.

If you want a quick look at Django and don't mind not "getting" it all, the book "Practical Django Projects" is most excellent.

For Rails you'll probably get the most out of "Rails for PHP Developers".

Have fun!

Re:One of the biggest problems is configurability (1)

KamuZ (127113) | more than 4 years ago | (#32467082)

I am a PHP Developer and you are right, when I was checking Rails it was really awesome.

Then I discovered http://www.symfony-project.org/ [symfony-project.org] and it was amazing, give it a try, you will also see how much low level work is eliminated entirely. Their documentation and tutorial is awesome too.

I used to work with Zend Framework but now it looks complex and slow compared to Symfony. Of course as most programming discussions, it is a matter of preference. Pretty sure someone is going to come here and say Zend Framework is the best and symfony is crap :)

Re:One of the biggest problems is configurability (1)

cifar24 (1147127) | more than 4 years ago | (#32467050)

I can related to that. Most people code in PHP because they learn it in 1 day and then they are hooked to it. The power of PHP is its simplicity. We do web stuff with PHP because we tried JAVA and it was TOO costly. To us, any improvement will help as long as it is well documented and documentation has high google page-ranking.

Re:One of the biggest problems is configurability (1)

nidarus (240160) | more than 4 years ago | (#32463580)

Very easy to get from nothing to a fully-functional site. Take a static HTML file, add a couple of tags, move this file into your web root directory, and you're done.

That, and great PHP projects like Drupal (although I don't know if your average Drupal project qualifies as a "web application").

Re:One of the biggest problems is configurability (1)

Firehed (942385) | more than 4 years ago | (#32464270)

PHP was designed from the ground up to be a templating language for building dynamic websites, and is one of very few languages that can make that claim. Plenty of frameworks have been built to make other languages web-friendly, and they're nearly required to do anything in a cost/time-effective manner. Of course, PHP frameworks (can) speed up development as well, but you can make do without one just fine as well.

Admittedly I may be biased as I develop in PHP all day and literally work five feet away from Rasmus Lerdorf, but I've had that opinion long before that was the case. But except for a single occasion*, I've never found that the language was simply incapable of doing what I needed to do, and what I do requires me to interact with at least half a dozen external services each in a different way (and only one is even using a standard format/protocol). Nearly 100% of the time, any difficulties arise in actually understanding the problem in a meaningful way rather than trying to figure out how to write the code to do the tricky operation, but I guess that's a hazard of having used PHP for the last eight years or so.

That said, the inconsistencies in the syntax drive me insane.

Don't get me wrong - I'm certainly not claiming that it's right for every project, every job, or every developer. It's not. But the amount of time I spend thinking "damn, there has to be a better way to do this" is almost never related to the language itself, and I have to do a lot of weird things in my code (yay, banks).

* and what I had to do violates all good ideas and best practices anyways; unfortunately, the external server is completely out of my control so I can't do something better. The substitute shell script is nearly as much of a hack.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32461938)

I use PHP and I love it as a language. It's powerful, stable, and lets me get lots of work done quickly.

When PHP is the only programming language you've ever used, of course you'll consider it "powerful", "stable", and productive.

Thankfully, the rest of us have used languages like Python, Ruby, Perl, Haskell, Erlang, Common Lisp and Smalltalk, and we know how horrible PHP truly is.

There might be some method to the madness. (0)

Anonymous Coward | more than 4 years ago | (#32466852)

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.

Re:There might be some method to the madness. (1)

Dylan16807 (1539195) | more than 4 years ago | (#32467156)

I think haystack first makes more sense as haystack is the subject you're working on, but if the needle is going to be first just make the first parameter optional, don't screw up the pattern.

Re:One of the biggest problems is configurability (2, Insightful)

Jack9 (11421) | more than 4 years ago | (#32461052)

The configuration file is a problem, to be sure

Why? Lots of languages use or require configurations for their interpreters/compilers. If the ini was such a big deal, there would be an implementation without one. Unfortunately, there's too many reasons to HAVE one.

Re:One of the biggest problems is configurability (1)

B3ryllium (571199) | more than 4 years ago | (#32465906)

I do agree that many of the function names are, quite frankly, *wacky* ... but the online manual more than makes up for it. I just toss it in my firefox search bar, and I can generally find any function definition (and, in some cases, arcane function names) nearly as fast as I can type it.

I've found it very difficult to find similarly useful resources in other languages (javascript in particular, if you can count it as a language ;-)).

I'm not sure exactly what about it makes it so easy to use for regular reference - but I do know that it is about a billion times better than most docbook-generated documentation I've ever seen. Usually docbook/javadoc makes me want to stab my eyes out with a rusty grapefruit spoon.

Re:One of the biggest problems is configurability (1)

jgagnon (1663075) | more than 4 years ago | (#32459876)

I've never programmed in PHP but I do love Python. Python 3 broke a lot of compatibility with earlier versions for the sake of becoming more consistent and a more solid foundation on which to build future versions.

Is PHP headed in that direction as well?

Re:One of the biggest problems is configurability (1)

mikael_j (106439) | more than 4 years ago | (#32460264)

But Python had a bit of consistency in 2.x that PHP has always lacked. And once you get used to how stuff works in python you can just sort of guess at how various parts of the standard library work unlike PHP where it's seemingly random.

That said, I do hold a bit of a grudge toward PHP since I have some code that I wrote in PHP ages ago and took great care to make sure it was nearly bug-free and now I can't be bothered rewriting it in a more sane language (this is OO PHP4 code with some PHP5 thrown in for kicks, at least all the old PHP3 stuff is gone and I no longer have any mod_perl crap to worry about).

Re:One of the biggest problems is configurability (1)

maxume (22995) | more than 4 years ago | (#32460324)

A lot of people get all crotchety because python breaks ABI compatibility with minor versions, so they may not realize that incompatible changes to the language are avoided.

Re:One of the biggest problems is configurability (1)

jgagnon (1663075) | more than 4 years ago | (#32460386)

I wasn't complaining about the changes to Python, only commenting on them. :p

Re:One of the biggest problems is configurability (1)

maxume (22995) | more than 4 years ago | (#32460764)

I didn't read your comment as a complaint, I was just pointing out that while the language itself is quite stable, third party libraries, especially C libraries, may still be unavailable, which if you don't agree with the ABI breakage may be quite frustrating (I'm still using python 2.5, partly because of library availability, but I don't find it irritating).

Re:One of the biggest problems is configurability (1)

ceeam (39911) | more than 4 years ago | (#32459894)

> Ironically all this time I've been avoiding the preg functions because I figured they were the more likely candidates to go away.

Sorry this is short, but are you *that* dumb?

Anyway, I remember seeing (in official docs) the note that ereg functions will occasionally be dropped like 5 years ago when I first started with PHP. And the fact that PCRE functions are *much, much* more powerful is very obvious.

Re:One of the biggest problems is configurability (3, Informative)

suso (153703) | more than 4 years ago | (#32460032)

> Ironically all this time I've been avoiding the preg functions because I figured they were the more likely candidates to go away.

Sorry this is short, but are you *that* dumb?

I must be.

Anyway, I remember seeing (in official docs) the note that ereg functions will occasionally be dropped like 5 years ago when I first started with PHP. And the fact that PCRE functions are *much, much* more powerful is very obvious.

Well good for you. Like I said, I've been using PHP since '97 and I don't usually have to go back to ereg page of the manual much. I know PCRE is more powerful (I do lots of Perl programming too so maybe I am dumb), but there are lots of functions like that in PHP where someone thought it would be cool to add it in, so it got included, but not all of them last and I wouldn't want to write code based on something that would get deprecated. Since ereg has been around since the beginning, I figured that it would be less likely to get deprecated.

As I brought up on the mailing list months ago when I was trying to make my case, of the books in the top 10 search results for PHP on Amazon, 5 or 6 of them, including the book by Rasmus himself (wrote PHP originally), use the ereg functions in their examples. So you can imagine that there are lots of people out there learning basic search functions out there that will be going away in the next major version. This is not good.

Re:One of the biggest problems is configurability (1)

Low Ranked Craig (1327799) | more than 4 years ago | (#32460280)

Personally I keep most of my validation and formatting functions in a single class, and about a year ago I spent 4 or 5 hours and replaced all the ereg with preg. It wasn't that big of a deal and the fact that ereg is going away as been, apparently, known for a long time. I've known about it for over a year personally. Besides preg is perl / mod_rewrite compatible so the expressions are more universal. I don't see the problem here - it's not like all web hosts are going to force upgrading to PHP 6 anytime soon. Hell, most hosts still make PHP 4 available...

Why are you assuming people will up and drop php5? (1)

Vekseid (1528215) | more than 4 years ago | (#32460398)

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.

Re:One of the biggest problems is configurability (1)

Bill, Shooter of Bul (629286) | more than 4 years ago | (#32460696)

Yeah, you really do have to keep up with a language these days to keep an eye out for the future. I wonder how you managed the transition through the other PHP versions. I mean, you aren't using register_globals or magic_quotes are you? Languages evolve. Programmers must evolve with them. If you don't then you'll get left behind.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32463830)

Yeah, you really do have to keep up with a language these days to keep an eye out for the future. I wonder how you managed the transition through the other PHP versions. I mean, you aren't using register_globals or magic_quotes are you? Languages evolve. Programmers must evolve with them. If you don't then you'll get left behind.

register_globals and magic_quotes are such obviously, spectacularly stupid ideas that anyone who's even slightly competent won't have been using them in the first place. That's not true of the ereg functions.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32464966)

anyone who's even slightly competent won't have been using them in the first place. That's not true of the ereg functions.

There is two set of regex function, one of which is faster AND more powerful (preg). Anyone who's even slightly competent would have used it, as there was no reason to go with ereg in the first place. It's not "two good choice and one got better", it has pretty much always been that way.

Re:One of the biggest problems is configurability (1)

merreborn (853723) | more than 4 years ago | (#32466226)

As I brought up on the mailing list months ago when I was trying to make my case, of the books in the top 10 search results for PHP on Amazon, 5 or 6 of them, including the book by Rasmus himself (wrote PHP originally), use the ereg functions in their examples. So you can imagine that there are lots of people out there learning basic search functions out there that will be going away in the next major version. This is not good.

When has using a book that's more than 1 major revision behind ever been a good idea? A MySQL 3 book proved pretty worthless when MySQL 4 came out. And MySQL 5 adds all kinds of stuff that MySQL 4 books don't cover.

I just threw out my java books from college because they covered java 1.2.

That's just how it is with programming books. Major language releases make them obsolete.

Re:One of the biggest problems is configurability (3, Insightful)

Gulthek (12570) | more than 4 years ago | (#32459970)

"Now" they are pushing preg functions? Everything I've read on PHP for the last five years has been drilling "use preg instead of ereg because ereg is slow and going away". This isn't a sudden switch either, you've already had months to transition and you still have many more months before you need to cut over.

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.

Global namespace stuffed full of built-in functions. Inconsistent argument order for built-in functions (needle, haystack || haystack, needle). Inconsistent naming scheme for built-in functions. PHP is a dumb language when it comes to including other code, it doesn't even have a concept of "other" code: an include/require statement just dumps the entire contents of the file being pulled in.

I could go on.

Yes, I code PHP for a living.

Magic quotes or magic drugs? (2, Insightful)

tepples (727027) | more than 4 years ago | (#32460138)

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.

Re:Magic quotes or magic drugs? (1)

Gulthek (12570) | more than 4 years ago | (#32465234)

Ugh, I blocked that one from memory. You know you're in for a fun time when the function has "magic" in its name.

Re:One of the biggest problems is configurability (1)

jd (1658) | more than 4 years ago | (#32459974)

When configuration files get horribly long and complex, it is usually true that they are configuring multiple distinct sub-components. In which case, those sub-components might be best pulled out of the main configuration file and placed in distinct configuration files. Further, sub-components should be responsible for loading their configuration on use. No sense loading, parsing and storing state information that won't be used in a specific PHP application - that just adds to the start-up time without adding any benefits.

My personal opinion of deprecated functions is that if the new function is THAT much better, the maintainers can provide a wrapper that provides the old API but uses the new functions. This can be done as an extra module written in PHP itself, so that those not using the old API don't suffer from overheads and the actual maintained codebase doesn't have extra arcs that need to be tested. The module can then be released as an unmaintained object. Users who wish to keep using the old API permanently can then maintain the wrapper themselves. Those who wish to migrate will have the time to do so, as the old API will only fail when there is an incompatibility between the new API as used and the new API as implemented.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32460000)

My main beefs with PHP are
1- they aren't consistent with the naming convention of functions/procedures
2- they aren't consistent with the order in which parameters are passed in to functions/procedures

I often have to resort to flat out guessing by trial and error, or refer back to php.net

Re:One of the biggest problems is configurability (1)

ceeam (39911) | more than 4 years ago | (#32460070)

> they aren't consistent

Nobody ever is! You know why? Because many functions are direct copies from the C stdlib, for example. Or from W3 DOM or other inter-language API standards. And different standards - gulp - are *inconsistent*!

Yes, it's as simple as that.

(And "native" PHP functions are more or less ok)

Re:One of the biggest problems is configurability (1)

tepples (727027) | more than 4 years ago | (#32460162)

Nobody ever is! You know why? Because many functions are direct copies from the C stdlib, for example.

At least Python tends to rename some functions when bringing them in from C: fopen() becomes open(), etc. PHP prior to 6 didn't even have a consistent way to declare namespaces.

Re:One of the biggest problems is configurability (1)

mikael_j (106439) | more than 4 years ago | (#32460286)

Of course, the namespace operator in PHP is "\" which seems to be hated by just about everyone.

Re:One of the biggest problems is configurability (1, Funny)

Anonymous Coward | more than 4 years ago | (#32460410)

So you're saying that you could get a PHD of PHP?

Re:One of the biggest problems is configurability (3, Insightful)

ducomputergeek (595742) | more than 4 years ago | (#32460420)

Our front end has been PHP for a while because it was popular and we could find developers easily. And when we were in the development, speed and the ability to find programmers was a primary concern. However now we've added all the functionality needed and it's a mature/stable product, but in the last 18 months we've noticed quite a few of these "You shouldn't use thisFunction() because it is deprecated". Every couple months when we upgraded PHP to the latest version it seemed like we'd start seeing new warnings that some function we'd been using for years was being deprecated. The last straw for me was the deprecation of split(). We were spending more time for maintenance than what we wanted to commit to the project at this stage so we ended up porting the frontend to Perl. The backend had been Perl based since 1999/2000 and the last time we had to do any updates to those scripts was adding functionality in 2006.

I know Perl is not sexy these days, but we use it a lot for things that we need done but don't want to spend a lot of time on maintenance. And I catch flack from some of the programmers who always want to use whatever "new hotness" is this year. But I'll take stable and mature any day of the week.

Re:One of the biggest problems is configurability (1)

D'Sphitz (699604) | more than 4 years ago | (#32460842)

error_reporting(E_ALL ^ E_DEPRECATED); // lameness filter too many caps wtf djalfkjasdkl fksjdklf jsakdlj fkldj lfkjsadlk fjlkasdjf lkasjflkjdasklf jlakdj fklsdajkl

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32461158)

jsakdlj

Hey that's my password. What are you doing with it?

Re:One of the biggest problems is configurability (1)

tsm_sf (545316) | more than 4 years ago | (#32461702)

I know Perl is not sexy these days, but we use it a lot for things that we need done but don't want to spend a lot of time on maintenance. And I catch flack from some of the programmers who always want to use whatever "new hotness" is this year. But I'll take stable and mature any day of the week.

Perl hard. Make puzzler hurt. Mongo work in java now.

Re:One of the biggest problems is configurability (0)

Anonymous Coward | more than 4 years ago | (#32461960)

I've ditched php in favor of html + ajax + perl.

Re:One of the biggest problems is configurability (1)

Stercus Fit (570489) | more than 4 years ago | (#32461326)

It's worse than just the configuration file. In the middle of the 5.2.x development, they changed which value types automatically passed by reference -- in a security patch! 5.2.1 you can modify your arrays in place, 5.2.3 your code is broken. If you want to change the semantics of function calling, you should give the new version a new name; it's a new language. At the very least, you'd better give me a new major version or I'll stop using your platform. I've stopped using the platform.

(I know it was 5.x, it might have been 5.3-ish when all this happened. This rant is from memory. Consider this a pre-emptive [citation needed]. There's no way we were the only ones bitten by change.)

Re:One of the biggest problems is configurability (1)

Hurricane78 (562437) | more than 4 years ago | (#32462478)

The biggest problem is it being PHP.
Sorry, but as the wise Sioux used to say:
When you discover that you are riding a dead horse, you should dismount. ;)

Doomed (1)

ISoldat53 (977164) | more than 4 years ago | (#32459834)

Once a company starts using phrases like "setting expectations" their end is near.

Re:Doomed (-1, Troll)

Anonymous Coward | more than 4 years ago | (#32459998)

Clearly you are a moron.

Re:Doomed (0)

Anonymous Coward | more than 4 years ago | (#32460362)

Yeah... but does Netcraft confirm it?

Setting expectations (3, Insightful)

0racle (667029) | more than 4 years ago | (#32459986)

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.

Re:Setting expectations (1)

Saeed al-Sahaf (665390) | more than 4 years ago | (#32460278)

So, in your biased opinion, it is impossible to write insecure code in, say, perl? C? These languages are perfectly safe for all?

Setting your bias aside, clearly the vast majority of insecure code in any language is not the language, but the way it was used.

The issue with PHP and insecure code comes from its low bar to entry.

Re:Setting expectations (1)

Magic5Ball (188725) | more than 4 years ago | (#32461446)

When recently helping a colleague with a CMS migration of a few million rows, I had to stop tracking the number of times and ways in which using string functions on not particularly interesting user-submitted data would cause PHP to segfault. It made no difference whether we ran the migration scripts from the command line or an Apache instance, nor whether the host was OS X, Windows, or the various Linux distros we had on hand. And then we got into the image parsing functions, which choke on files saved with particular non-spectacular options in Photoshop (and others) when the underlying GD libraries handle with no issue. Thankfully, we were only using PHP to get the data into the new system, and not as the foundation of the new system itself.

Re:Setting expectations (-1, Troll)

Saeed al-Sahaf (665390) | more than 4 years ago | (#32461714)

The issues you relate, particularly the image problems come from bad code (indeed when you described your image issue, I immediatly said to myself "I've seen that noob code error many times". These things are unrelated to the usability of PHP, but rather code monkeys who don't know their language. I could explain the image issue, but obviously you have no interest in learning professional PHP.

Re:Setting expectations (1)

Magic5Ball (188725) | more than 4 years ago | (#32462054)

With respect to the image handling, the failures on the part of PHP fell outside of the exception handling system presented to the user, and outside its internal facilities. Its attempts to parse some images walled the machines to the extent that local and remote ttys became unresponsive.

A well implemented system should include enough safeguards to prevent the system from failing so spectacularly on easily anticipated use cases, regardless of the inputs that code monkeys, such as allegedly myself, can mash up and throw at it.

In this case, PHP has compromised itself by adding some unsafe logic before or after passing valid data to a known working library. That fault would present itself as much to bad code monkeys and esteemed PHP professionals such as yourself.

Speaking of which, could you please direct me to the PHP professionals code of conduct or the like? I'd imagine that it's the same boilerplate that most others use, but I've not been able to locate one through my simple code monkey Google ful.

Re:Setting expectations (1)

the_B0fh (208483) | more than 4 years ago | (#32461468)

What kind of moron are you? When did OP say anything about the impossibility of writing insecure code in other languages? What he said was that if the expectation is that most PHP code is insecure, then you will have met the expectation.

Which part of that is wrong?

Stop defending insecure code. You make the assertion yourself with your statement of low bar to entry.

Re:Setting expectations (1)

Vekseid (1528215) | more than 4 years ago | (#32460318)

When was Facebook's database exposed?

Most security vulnerabilities in major php offerings these days are not php's direct fault, except perhaps as a function of the language's accessibility. If someone creates a script to allow uploading files, and sticks it on a server with both mod_php and mod_perl, and the script doesn't check non-php extensions, how is it php's fault when the server promptly gets owned?

The server owner has a responsibility not to allow one user to threaten others (by running php over FastCGI rather than mod_php), and the script author has a responsibility as a programmer to make a secure application. PHP is not where it was in the 4.x days.

Re:Setting expectations (0, Troll)

Saeed al-Sahaf (665390) | more than 4 years ago | (#32460498)

The Parent is not "insightful", it is ignorant and biased. Insecure PHP is a function of the low bar to entry that allows noobs to produce code that does stupid things. The same (and worse) are possible with many languages...

Re:Setting expectations (1)

hardburn (141468) | more than 4 years ago | (#32462770)

The language may not guarantee secure code, but it can make writing secure code easy.

For instance, using placeholders in SQL makes code virtually immune to SQL injection attacks. If your database does not support placeholders, then the library can simulate it by quoting bad characters when data is passed in.

In Perl, any tutorial on database usage that anybody will point you to will most definitely show you how to use placeholders. The main one [perl.com] is over 10 years old, and it's very first Perl code example uses placeholders, as do all its other examples that run a query against a variable. It was the correct way to do things back then, and still is. DBI makes it very easy to do it right because there are no additional methods to call to make use of placeholders, and the Perl community is good about showing new programmers how to use them.

If you use PHP with PosgreSQL, then you have the pg_query_params() for the job. Why can't pg_query() do it? For that matter, why can't the equivalent function translate placeholders for braindamaged databases that don't use them? Making the programmers handle this with an escape function is inconvenient. Smarter programmers will have their time wasted on writing frivolous string escaping code, and more noobtacular programmers won't even know what it is or why they should be doing it.

It's entirely possible to write it correctly in PHP, but languages don't differer in what they make possible; they differ in what they make easy. Writing secure code should be much easier than it is.

Oh No! 60 issues (0, Troll)

Rallias Ubernerd (1760460) | more than 4 years ago | (#32459996)

Oh right. There is over a million on MS Windows.

Doing something about it. (4, Insightful)

AndGodSed (968378) | more than 4 years ago | (#32460002)

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)

Re:Doing something about it. (2, Interesting)

ianpatt (52996) | more than 4 years ago | (#32460334)

The PHP developers didn't find these bugs, Stefan Esser did. (see http://php-security.org/ [php-security.org] )

The fact that one of the bugs still remains from his original /2007/ Month of PHP Bugs shows that the PHP developers are clearly not doing a thorough job.

I would laugh... (3, Insightful)

Vekseid (1528215) | more than 4 years ago | (#32460482)

The fact that one of the bugs still remains from his original /2007/ Month of PHP Bugs shows that the PHP developers are clearly not doing a thorough job.

...but this sort of thing just makes me want to cry. Multiyear bugs exist in multitude. And these are just the ones they admit exists.

Re:Doing something about it. (1)

Hurricane78 (562437) | more than 4 years ago | (#32462650)

Yeah. Like walking trough Nazi Berlin 1944, seeing 60 cases of deadly friendly fire by the Nazis, and declaring their action a good thing. ;)

Considering my 7-year experience with PHP, I’d say that the easy to find bugs are only artifacts of the horrible horrible architecture underneath.

A interpreter/compiler that allows you to put plain text right between your lines of code like this

<? echo "EVIL";
blablabla
echo "PHP" ?>

and not throw an error because it considers any string without quotes to be a string anyway (or a constant, or...), which can be in an expression, which itself can be a statement with its result thrown away,
deserves to be compared to something as completely insane as the above example. ;)

Also, I only have to say “implicit casting guesswork”, to raise the hairs of pretty much every real programmer out there.

P.S.: (1)

Hurricane78 (562437) | more than 4 years ago | (#32463222)

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. :)

The only language where reinventing the wheel... (1)

Vekseid (1528215) | more than 4 years ago | (#32460220)

...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.

Untrusted developers (1)

billcopc (196330) | more than 4 years ago | (#32460262)

"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.

Re:Untrusted developers (4, Insightful)

Hatta (162192) | more than 4 years ago | (#32460366)

What if that untrusted coder is not an employee, but a customer? If you're hosting websites, and your client wants to write custom PHP, you need to rely on your OS features to ensure that his insecure code can't damage other users.

Re:Untrusted developers (1)

the_B0fh (208483) | more than 4 years ago | (#32461504)

I am not sure which language I would prefer more, brainfuck, or APL.

Re:Untrusted developers (1)

AliasMarlowe (1042386) | more than 4 years ago | (#32461780)

I am not sure which language I would prefer more, brainfuck, or APL.

APL, no contest. When it's done right, it's a non-stop brainfuck.

Re:Untrusted developers (1)

adamofgreyskull (640712) | more than 4 years ago | (#32461660)

ACK that. Slightly OT, but humorous. At a php conference in London a couple of years ago, in a talk by Stefan Esser on PHP Binary Analysis a guy, possibly the guy referred to in this post [pookey.co.uk] , claimed that he had a commit trigger that detected calls to exec() and e-mailed him, so he could summarily exec('sudo rm -rf /') the committer. Everyone laughed, but I have the strangest feeling he wasn't joking...

Re:Untrusted developers (0)

Anonymous Coward | more than 4 years ago | (#32464302)

Actually the true story is that someone in the audience told him that he disallows eval() in his company and Stefan replied that he could use the techniques to introduce an autocommit hook that detects eval() and sends an email to the commiter telling him that he is fired.

Why stop at blaming the OS for insecurity? (2, Insightful)

prgrmr (568806) | more than 4 years ago | (#32460342)

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.

Proper Coding Practices (1, Insightful)

epp_b (944299) | more than 4 years ago | (#32460496)

If you "can protect against [the bugs] with proper coding practices", are they really "bugs"? I would say not.

Re:Proper Coding Practices (2, Insightful)

Dan Ost (415913) | more than 4 years ago | (#32461266)

But because the work-around for a bug is common knowledge doesn't make the bug any less of a bug. It does, however, give the devs an excuse for not fixing it, or making it lower priority than bugs that have no work-around.

Re:Proper Coding Practices (2, Interesting)

webbiedave (1631473) | more than 4 years ago | (#32462150)

proper coding practice != workaround

Re:Proper Coding Practices (1)

Just Some Guy (3352) | more than 4 years ago | (#32462162)

If you "can protect against [the bugs] with proper coding practices", are they really "bugs"? I would say not.

Description: all built-in functions are insecure and will poison your cat and sell your organs.
Workaround: re-implement all native functionality yourself.

QED.

Re:Proper Coding Practices (1)

mandelbr0t (1015855) | more than 4 years ago | (#32464550)

Yes, they are. Because the main issue is that many sites host PHP from untrusted users, and don't have time to go through every script with a fine-toothed comb. Assuming that the people who write PHP scripts are capable of using proper coding practices is kind of like assuming that your teenager always tells the truth. In rare cases, it might be true, but you're an idiot if you believe it.

Security flaws and good coding practices? (1)

gsgriffin (1195771) | more than 4 years ago | (#32460686)

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.

Re:Security flaws and good coding practices? (-1)

Anonymous Coward | more than 4 years ago | (#32462446)

I didn't read through all of the security flaws they are now reporting...

So in actuality, you're talking out of your ass? Of course you are, this is Slashdot.

Redhat 5 a problem which php 5.1 only? (1)

felix9x (562120) | more than 4 years ago | (#32465860)

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?

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?