Slashdot Mirror


Serious Crypto Bug Found In PHP 5.3.7

Trailrunner7 writes "The maintainers of the PHP scripting language are warning users about a serious crypto problem in the latest release and advising them not to upgrade to PHP 5.3.7 until the bug is resolved. PHP 5.3.7 was just released last week and that version contained fixes for a slew of security vulnerabilities. But now a serious flaw has been found in that new release that is related to the way that one of the cryptographic functions handles inputs. In some cases, when the crypt() function is called using MD5 salts, the function will return only the salt value."

34 of 165 comments (clear)

  1. Regression tests are for wimps! by Niac · · Score: 5, Insightful

    Who cares about testing security code for regressions?

    I'm seriously astounded that the php development community doesn't have acceptance testing around this sort of thing. In this day and age, why on earth is it the case that bugs like this get through?

    --
    http://gabrielcain.com/
    1. Re:Regression tests are for wimps! by PCM2 · · Score: 3, Funny

      I'm seriously astounded that the php development community doesn't have acceptance testing around this sort of thing. In this day and age, why on earth is it the case that bugs like this get through?

      Speaking as an occasional PHP developer, you must be new here.

      --
      Breakfast served all day!
    2. Re:Regression tests are for wimps! by rainmayun · · Score: 4, Insightful

      True, PHP has a history of "winging it", but by now they should be doing a pretty damn extensive suite of regression tests against each release candidate, if not each build. At this point in its life and supposed maturity, the PHP Group should really be doing better.

    3. Re:Regression tests are for wimps! by thue · · Score: 4, Informative

      From the Bug report:

      > Confirming, some very recent update broke it - right now unit tests fail on SVN. I wonder if nobody run it before release?

      So they do have a unit test for that. They just didn't run it before release :).

    4. Re:Regression tests are for wimps! by Arancaytar · · Score: 4, Insightful

      Unit tests are slow and they almost always pass. When you're in a rush to release, sometimes you feel lucky.
      Of course, you're not. That's the whole point of unit tests...

    5. Re:Regression tests are for wimps! by msauve · · Score: 2, Informative

      "I'm seriously astounded that the php development community doesn't have acceptance testing around this sort of thing."

      Two things.

      1) The problem was found and announced by "the php development community," and presumably found by them, too (admittedly, not prior to release).
      2) Why aren't you involved in acceptance testing, if you see a problem with how it's being done?

      --
      "National Security is the chief cause of national insecurity." - Celine's First Law
    6. Re:Regression tests are for wimps! by GPLHost-Thomas · · Score: 2

      Few things you are failing in here. First, "Debian" is down to one guy when it comes to packaging PHP. More or less, Ondej Surý does it all, since last year, Raphael Geissert started being busy. I myself work more on packaging PEAR packages, and I have enough work. So if you want things to become better for the packaging of PHP in Debian, then you need to contribute! Create a new user on Alioth, register the project and the pkg-php-maint list, and start helping. Because for sure, we don't have, in Debian, the time to do the programming for more unit testing than it is available in upstream. However, I believe it'd be nice to have the upstream unit testing added the to Debian build process. That would avoid such "surprise"! :)

      And the second thing, I posted it on another thread: Debian is *NOT* affected by this, since the crypt() function of php is using the system implementation, not the one of PHP, at least when available (this isn't the case of blowfish which isn't available, so blowfish is affected, but not md5 for example).

    7. Re:Regression tests are for wimps! by Chuck+Chunder · · Score: 2

      It seems that the bug was in the code base for at ~10 days before someone (external) discovered it. That does not seem to be (just) a case of unit tests being skipped in a rush, it seems like a surprising lack of automated testing.

      --
      Boffoonery - downloadable Comedy Benefit for Bletchley Park
    8. Re:Regression tests are for wimps! by Chuck+Chunder · · Score: 4, Informative

      1) The problem was found and announced by "the php development community," and presumably found by them, too (admittedly, not prior to release).

      That seems entirely incorrect. According to the bug report it seems to have been found by someone external, it was found in a release candidate not the released version and seemingly filed before the release was made.

      2) Why aren't you involved in acceptance testing, if you see a problem with how it's being done?

      Speaking for me, we pay Zend for server licences and imagine that in someway contributes to a professionally run project. Though I have to say we are becoming increasingly unsure as to whether we get any value for money for that, of the security fixes that 5.3.7 fixed I haven't noticed any of them being pushed to Zend Server in a priority fashion and I don't think we've ever had a single support question resolved satisfactorily. Sometimes being a Zend customer seems merely to open you up to sales pushes.

      --
      Boffoonery - downloadable Comedy Benefit for Bletchley Park
    9. Re:Regression tests are for wimps! by Rob+Aley · · Score: 3, Informative

      While it could have been caught, the bug was actually a result of testing, namely the use of the Coverity static analyzer which flagged up "strcat(passwd, "$");". In this particular case it was safe use strcat, but was erroneously changed to "strlcat(passwd, "$", 1);" to avoid the warning. Its a lesson perhaps that automated tests aren't the silver bullet for avoiding bugs, understanding the code itself is just as important. It also raises the question of whether much of the criticism in the discussions below should be directed at C instead of PHP. I'll stay out of that one...!

    10. Re:Regression tests are for wimps! by gweihir · · Score: 3, Insightful

      Automated tests are nice, but fixing the code requires somebody that _really_ understand what they are doing. Fixing problems found in automated tests so that the tests stay quiet without understanding what is going on is about the most stupid thing you can do in security-relevant code. It is grounds for immediate and permanent removal of code maintainer status.

      Also note that the Debian OpenSSL disaster was a result from doing the same thing with valgrind, so there has been at least one very public warning about this sort of thing.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    11. Re:Regression tests are for wimps! by JDG1980 · · Score: 2

      Any language with a low barrier to entry will attract a higher-than-usual number of poor developers. This doesn't mean that the language itself is necessarily bad.

    12. Re:Regression tests are for wimps! by GooberToo · · Score: 2

      It does once the feedback loop becomes complete. At least with VB, those developers were not contributing back to the language. The same can not be said for PHP.

    13. Re:Regression tests are for wimps! by JDG1980 · · Score: 2

      Another problem is that there is literally a function for everything. And a corrected version of it, named differently because code out there relies on the old buggy version. Things like urlencode and rawurlencode, mysql_escape_string and mysql_real_escape_string (I'm not making this up!) and htmlspecialchars and htmlentities.

      This is hardly limited to PHP. You'll see much the same thing in the Win32 API, or indeed in the C standard library (gets, anyone)? Deprecated functions left in for compatibility reasons are a fact of life.

  2. When will MD5 be let to die as hash for passwords? by c0lo · · Score: 2, Informative
    --
    Questions raise, answers kill. Raise questions to stay alive.
  3. Poor QA by TheNinjaroach · · Score: 3, Informative

    The PHP project has shown some pretty poor QA when it comes to defects in their code.

    Hell, their ODBC interface has been returning wrongly typed data for years now and nobody on the project seems to care. It's not like ODBC is something brand new and still widely misunderstood.

    It's almost like the people who build PHP aren't even interested in maintaining it.

    --
    I went to eat some animal crackers and the box said, "Do not eat if seal is broken." I opened the box and sure enough..
    1. Re:Poor QA by Xest · · Score: 2

      "It's almost like the people who build PHP aren't even interested in maintaining it."

      It's not really that, it's just the PHP ethos, PHP has never really been about good software development and that flows not just through the language itself but development of the language. It's not that PHP is inherently bad- rather than focus on good practice, it focuses on just getting things done, and this kind of works, but it also means that you'll more frequently see things like this when you throw best practice out the window.

      Like every other language, PHP has it's pros and cons- it's good for getting things done quickly, it's easy for beginners and is forgiving, but for professionals who want to write solid software it has many weaknesses. Without a doubt it's done well- look at Facebook, but similarly look what Facebook had to do with it- mangle it down to C++, and then look at the amount of bugs Facebook has suffered- anyone who uses it regularly will be well aware of features that randomly just break on some days, like chat, the ability to comment and so forth.

      A lot of developers think best practice is just fantasy, but these are developers who have never worked on large scale systems and it is precisely these scenarios where you want something that supports best practice development well. The issue Facebook has had in terms of bugs and performance, leading to difficulties with scalability are issues that arise precisely from failing to ensure you're software is well developed. It hasn't hindered Facebook, but it doesn't particularly look good for such a company either, and for more serious applications where such bugs have real repercussions it's unacceptable.

      If you want to get somethnig done ASAP and there's little accountability required if things go wrong then PHP is absolutely brilliant. But if you're developing something where there's a lot of accountability required, you can spend a bit longer developing it to produce a more solid, more futureproof (scalable, maintainable) system, then PHP is not the right tool for the job.

      So in that context although bugs are bad, I really find it hard to slag the PHP team off- they're producing a tool that people want, but it's a tool where you should expect these kind of issues. If you want a solid, trustworthy tool, then PHP isn't the right tool for the problem you're trying to solve. The only issue really surrounding PHP is that as a tool that prioritises speed over quality, is that because it's so easy to learn, too many developers when they've become good with it having learnt it as their first language, they continue to use it even where it's not fit- they don't dare venture on to anything else and so they genuinely believe it's the right tool for every job. That's wrong, no language is.

  4. Re:Perhaps THIS is the reason why THIS occurs? by ledow · · Score: 4, Funny

    Did you know that houses were the favoured target of burglars? Quick! Sell your house and buy a bungalow! Even though only 1% of houses are bungalows, they're attacked only 1% of the time if you consider all burglaries!

    It's like saying "cars most likely target in car thefts".

    Dickhead.

  5. PHP can't get better. It drives away anyone good. by Anonymous Coward · · Score: 2, Insightful

    PHP has gotten itself into a vicious cycle where it inherently can't get better.

    Anyone who knows what their doing will refuse to use PHP. That means that only the worst "programmers" out there will even consider it, let alone use it.

    WIthout having good developers using it, it'll never have good developers contributing to it. No good developer would want to publicly admit that they've contributed to PHP.

    At this point, some fool will throw out some crap like, "OmG but W1kip3D1A n faceb00K yooze PhP!@!#%@!!". None of that changes the fact that it's a horribly "designed" language, and it's just as poorly implemented. This single bug shows just how awful it is.

  6. Not only that by Chuck+Chunder · · Score: 3, Informative

    It seems the bug was filed before the release was made.

    --
    Boffoonery - downloadable Comedy Benefit for Bletchley Park
  7. Re:PHP Bug #55439 FIXED (Aug 20) by nedlohs · · Score: 4, Informative

    Nope.

    $valid will be the return value of crypt which will be true in the non-broken code as well.

    $crypted == crypt($pw, $salt)

    will always be true in the broken code, if $crypted was created with any old password and the same salt.

    Of course if you have existing such password, they'll always match false, so no one is going to be able to change their password and trigger the problem anyway :)

  8. Re:When will MD5 be let to die as hash for passwor by Arancaytar · · Score: 3, Informative

    MD5 should be deprecated, but the collision attack only invalidates signatures; it doesn't help you extract a password from its hash.

    Currently there is no feasible non-dictionary attack for that (the preimage attack found in 2009 still has complexity >2^120), and the dictionary attacks are defeated by salt. So in this narrow context, yes.

    (Of course, this would end if a somewhat more efficient preimage attack is found. 2^120 is orders of magnitude beyond usefulness, but not many orders...)

  9. Re:PHP can't get better. It drives away anyone goo by rainmayun · · Score: 2

    A bug in a library function shows how a language is poorly designed? Methinks you need a little more logical organization to your thoughts. and I can't help but laugh at "no good developer would want to publicly admit that they've contributed to PHP". Perhaps no good developer would want to admit to posting your comment, hence Anonymous Coward status.

  10. Most distributions *not* affected by this! by GPLHost-Thomas · · Score: 4, Informative

    The internal crypt() function of PHP is only there whenever the system function doesn't exist. So for example, in Debian, only the blowfish encryption is affected, all other encryption are using the system. Here's Ondrej post about it:

    http://lists.alioth.debian.org/pipermail/pkg-php-maint/2011-August/009328.html

    I am guessing that this will be the case in most Unix distribution, but it will be an issue on platforms like Windows. So, maybe this is just too much buzz...

    1. Re:Most distributions *not* affected by this! by EvanED · · Score: 2

      The internal crypt() function of PHP is only there whenever the system function doesn't exist.

      This is not correct.

      Ondrej's post you link to is specifically referring to the patched version of PHP that you get from the Debian repository. One of the patches Ondrej applies makes PHP use the system crypt(). Without that patch -- with the stock PHP code -- PHP uses its own crypt(). Now, other distributions might apply Ondrej's patch, but I certainly wouldn't count on it, and you definitely will have a broken crypt() if you get the stock PHP.

      For my source, I again cite an email from Ondrej, this time to the PHP list http://marc.info/?l=php-internals&m=131404279532421&w=2

      In that email, he suggests to the PHP folks that they should apply his patch.

  11. Re:When will MD5 be let to die as hash for passwor by rthille · · Score: 3, Informative

    What's fixed by using salt in your passwords is that the leaked password file can't be compared against a precomputed password dictionary.

    --
    Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
  12. Re:PHP can't get better. It drives away anyone goo by onepoint · · Score: 2

    I just had to have a very similar situation for a web site that I wanted, I went out for bids, and got about 5 solid coders, each one real good, each had a quote price with in 4500 of each other, all different languages it all came down to delivery date.

    I took the PHP guy, why, real simple, he said to me, prototype web site in Photoshop in 3 days, working web site idea in a week, beta test on the 14th day, can go live within another week and afterwards with 3 months of support, bug cleaning, and code clean up free. bottom line he said, if it works you'll hire me on the 4th month for years, and then we can recode it in whatever you want.

    the truth of the matter seems that i wanted a delivery date that could be hit, Who knows I might have done something wrong but first to market always get's the attention.

    --
    if you see me, smile and say hello.
  13. Re:PHP can't get better. It drives away anyone goo by EvanED · · Score: 5, Insightful

    I think that the post you replied to was a bit extreme, but it's not the bug in the library function that caused him to say that: it's the fact that the PHP project lacks the testing infrastructure that any reasonable project of that size would have.

    Anyone can commit a bug; that's easy and excusable. What makes it look like PHP is developed by a bunch of 12 year olds is the fact that they have a test suite with a test that exhibited the bug, and yet no one ran it before they made a release, because they've got too many failing tests so it just got swamped in with that noise.

    I'm working on some dinky pieces of research software, and while we probably don't have as extensive a test suite as PHP does, we have a way better testing regimen. A project like PHP should have a CI server that runs their tests at least nightly, and a release shouldn't be made while there are failing tests. That's what expected failures are for. (They even know about expected failures, but still have over 200 failing tests for some reason.) Even we've got that.

    It's the QA that's messed up, not the coding.

  14. Re:When will MD5 be let to die as hash for passwor by cduffy · · Score: 2

    Of course an attacker who steals your password database knows the salt values in use for each account.

    But unless they have a rainbow table calculated with every possible salt value taken into account, they can't do a simple lookup on a precomputed map of hash values to top-5,000,000-common-passwords and hope to get a match... so their expense to actually break any of those passwords is much, much higher.

  15. Re:When will MD5 be let to die as hash for passwor by mgiuca · · Score: 2

    Read up on the difference between Collision attack and Preimage attack.

    MD5 is vulnerable to collision, but not yet preimage attacks. The preimage attack the GP is mentioning is something like this: Alice is required to digitally sign off on all money withdrawals from an account, and MD5 is used as a hash algorithm. Bob creates two documents, one saying "I authorize the withdrawal of $100." and another saying "I authorize the withdrawal of $1,000,000." He uses a collision attack to ensure that these two documents both hash to the same MD5 value. He then gives Alice the $100 note to sign. She does so creating a digital signature, which happens to also be valid for the $1,000,000 note (unbeknownst to her). Bob then submits the $1,000,000 request for withdrawal, along with a valid signature from Alice.

    In general, it is Very Bad if two documents can be created with the same hash. But yes, not going to help cracking passwords though.

  16. Worst of all worlds by 93+Escort+Wagon · · Score: 3, Interesting

    I know there's no reason a skilled programmer can't use php, but in my experience the users that request php access are generally the users who you'd least want to have any sort of script-level access to your servers. When I've explained to requestors why we don't generally provide php, I've been told on several occasions "I don't want or need the ability to run scripts! I just want to create php web pages." Oh, and mysql access requests usually come hand-in-hand with php requests.

    I remember one guy, quite a few years ago, who asked us to 1) enable php on our department's web server; and 2) give him access to create and run php scripts. To demonstrate to us that he wasn't just another newbie... he wrote a php script and placed it on his own personal box as a demo of his coding skill. This script let anyone, anywhere, examine the content of any file in the /etc/ directory via an easy to use web interface.

    We politely declined his request.

    --
    #DeleteChrome
  17. Re:PHP can't get better. It drives away anyone goo by makomk · · Score: 2

    In reality, almost nobody* is going to call md5 via crypt() when a standalone md5() function exists

    Yes they are, because the two don't do the same thing. md5 just calculates the md5 of data, whereas the md5 support of crypt uses salting and a large number of rounds to make password cracking harder.

  18. Re:PHP can't get better. It drives away anyone goo by Rob+Aley · · Score: 2

    I don't think they should have pulled it, if you don't use the the crypt() function the other fixes and features of the upgrade may well make it a worthwhile upgrade. However I agree that the download page should be marked with this information, not just the front page.

  19. Re:PHP can't get better. It drives away anyone goo by Haeleth · · Score: 2

    A bug in a library function shows how a language is poorly designed?

    No, but releasing an update without even running the existing unit tests shows how amateurish the whole PHP project is. The terrible design of the language is also a reflection of its amateurish nature.

    It's true that some websites manage to do wonderful things with PHP, but then it's also true that some artists manage to make wonderful sculptures out of manure. That doesn't mean it's a good choice for most people.