Announcement

Collapse
No announcement yet.

Serious PHP vulnerability; please check your sites!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Serious PHP vulnerability; please check your sites!

    Over the past few days, an eight year old issue in php has been discovered; basically a specific configuration can result in anyone on the internet being able to execute code on your site. There is no fix at this time but there is a workaround. This only affects sites running PHP as a cgi script so most sites will not be vulnerable, but any site that has required a custom version of php be installed, such as to run Wordpress or even certain third party Miva Merchant modules that have php components, will be vulnerable to this and must be checked and protected asap.

    First, here is what to look for to see if you would be potentially vulnerable to this attack; make an FTP connection to your site and look in the /cgi-bin directory for any files that start with php, such as php5, php-cgi, php.ini, etc. If you do not have them, you are not vulnerable.

    If you do have them, because there is no fix from the php authors yet (it's potentially scheduled for release tomorrow), you need to implement the following code in your site's .htaccess file in the /httpdocs directory as a workaround:

    Code:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^[^=]*$
    RewriteCond %{QUERY_STRING} %2d|\- [NC]
    RewriteRule .? - [F,L]
    #
    Please do not wait for the official fix, this vulnerability is being actively exploited via automated processes running on hacked sites; thousands of sites are being compromised by the minute.

    If you are not familiar with .htaccess files, how to modify them, how to create them if you do not have one or don't feel comfortable modifying the one on your site since a mistake can cause the site to not work, please open a ticket with us if you are hosted with us and we'll make the addition for you; just reference this thread.
    Last edited by ILoveHostasaurus; 05-07-12, 07:53 AM.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    #2
    Re: Serious PHP vulnerability; please check your sites!

    Thanks for the heads up David. Sounds scary...ugh.
    Susan Petracco
    NetBlazon

    1.866.400.2444

    _____________________________________________

    Like us on Facebook

    Comment


      #3
      Re: Serious PHP vulnerability; please check your sites!

      Could you explain exactly where to put these lines and what they do?

      For example, many .htaccess already have the line "RewriteEngine On" Does that line get duplicated? Also many lines in the current .htaccess contain %{QUERY_STRING} Will the lines disable the query_string in existing lines?
      Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
      Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
      Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
      Facebook http://www.facebook.com/EmporiumPlus
      Twitter http://twitter.com/emporiumplus

      Comment


        #4
        Re: Serious PHP vulnerability; please check your sites!

        Originally posted by wcw View Post
        Could you explain exactly where to put these lines and what they do?

        For example, many .htaccess already have the line "RewriteEngine On" Does that line get duplicated? Also many lines in the current .htaccess contain %{QUERY_STRING} Will the lines disable the query_string in existing lines?
        "RewriteEngine On" only needs to appear in a .htaccess file one time, before any RewriteRule and RewriteCond statements.

        The other three lines should occur before any other rewrites, so at the top of the file just after the RewriteEngine.

        What the two lines do is first test to see if the request has a query string that does not contain an equal sign, which is an unusual occurrence since typically a query string will be field=value&field2=value2, etc. The second line then detects if the query string contains a hyphen or a url-encoded space. If both tests pass, i.e. no equal sign AND there's a space OR hyphen present, the request is blocked.
        Last edited by ILoveHostasaurus; 05-07-12, 08:27 AM.
        David Hubbard
        CIO
        Miva
        [email protected]
        http://www.miva.com

        Comment


          #5
          Re: Serious PHP vulnerability; please check your sites!

          I already have rewriteEngine On.

          Just double checking that there is no need to turn rewrite engine on again and the best place to place the additional code is just after the rewriteEngine on.

          Also, could you explain what the rule does:

          It appears to look for query strings and change any spaces to hyphens then forbids any query string that ends with equals sign. (my best guess)
          http://www.alphabetsigns.com/

          Comment


            #6
            Re: Serious PHP vulnerability; please check your sites!

            Sorry Bill beat me to the post.
            http://www.alphabetsigns.com/

            Comment


              #7
              Re: Serious PHP vulnerability; please check your sites!

              Originally posted by alphabet View Post
              I already have rewriteEngine On.

              Just double checking that there is no need to turn rewrite engine on again and the best place to place the additional code is just after the rewriteEngine on.
              Yep it should be put before other rewrites, and only need the engine on once since it's on for the duration of the file at that point.
              David Hubbard
              CIO
              Miva
              [email protected]
              http://www.miva.com

              Comment


                #8
                Re: Serious PHP vulnerability; please check your sites!

                Can you give any more information about the vulnerability? I haven't seen this posted anywhere else yet, so I'm a little curious myself.

                Also, does this have any relation to the downtime we all experienced last night?

                Comment


                  #9
                  Re: Serious PHP vulnerability; please check your sites!

                  What is the # for at the end of your code example?
                  Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
                  Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
                  Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
                  Facebook http://www.facebook.com/EmporiumPlus
                  Twitter http://twitter.com/emporiumplus

                  Comment


                    #10
                    Re: Serious PHP vulnerability; please check your sites!

                    Originally posted by Brandon MUS View Post
                    Can you give any more information about the vulnerability? I haven't seen this posted anywhere else yet, so I'm a little curious myself.

                    Also, does this have any relation to the downtime we all experienced last night?
                    Try this link Brandon:

                    http://www.php.net/archive/2012.php#id2012-05-06-1

                    The three most recent posts have more info and links to further documentation. It's a pretty ugly vulnerability since all you have to do is url encode the php code you'd like executed.

                    The issue last night was not related.
                    David Hubbard
                    CIO
                    Miva
                    [email protected]
                    http://www.miva.com

                    Comment


                      #11
                      Re: Serious PHP vulnerability; please check your sites!

                      Originally posted by wcw View Post
                      What is the # for at the end of your code example?
                      Just out of habit; to separate the new code from any other code already in the file for easier readability.
                      David Hubbard
                      CIO
                      Miva
                      [email protected]
                      http://www.miva.com

                      Comment


                        #12
                        Re: Serious PHP vulnerability; please check your sites!

                        I realize you guys have thousands of sites hosted and probably a very small fraction of owners read this forum. Even when notified there is a large percentage of folks who think it could never happen to them so they do nothing. What is being done to protect the servers where accounts (which have not made changes) exist? Is there any way to know if this exploit has been used to expose stores' backend data already?
                        Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
                        Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
                        Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
                        Facebook http://www.facebook.com/EmporiumPlus
                        Twitter http://twitter.com/emporiumplus

                        Comment


                          #13
                          Re: Serious PHP vulnerability; please check your sites!

                          Reading about this the scariest part is either the ?-s exploit or ?-T+1000000. I mean, just wow! (Super happy we are no longer using php-cgi on our websites)

                          Comment


                            #14
                            Re: Serious PHP vulnerability; please check your sites!

                            Originally posted by wcw View Post
                            I realize you guys have thousands of sites hosted and probably a very small fraction of owners read this forum. Even when notified there is a large percentage of folks who think it could never happen to them so they do nothing. What is being done to protect the servers where accounts (which have not made changes) exist? Is there any way to know if this exploit has been used to expose stores' backend data already?
                            We are writing scripts to automatically add the code to our hosted sites' web server config files if a cgi-based php is present on a given site; however that takes time and anyone who adds the code first will be protected sooner.

                            A store that was installed on or after May 2010, meaning it's at least PR7 from the beginning, is not at risk because the database connection information would have been encrypted. A store that was updated to PR7 and then the PA-DSS checklist shows passing, also would not be vulnerable; in many cases the encryption was automatically enabled so most will show as passing at least that one item and that is all that would be needed in this case. A store that is not up to that release, AND has a cgi-based php, AND had that php exploited in the past 48 hours AND the attacker knew what file in what directory to look at specific to Miva Merchant AND then took the time to access that store's database, could potentially have had data accessed.
                            David Hubbard
                            CIO
                            Miva
                            [email protected]
                            http://www.miva.com

                            Comment


                              #15
                              Re: Serious PHP vulnerability; please check your sites!

                              After implementing the code in the .htaccess file, is there any way to test to make sure that we have implemented it correctly and are no longer vulnerable?

                              thanks in advance.
                              Mark Romero
                              ~~~~~~~~

                              Comment

                              Working...
                              X