New PHP-CGI exploit: CVE-2012-1823, Badly affecting php scripts

Recently some folks reported an interesting and nasty bug with php which will allow an intruder to view the source code and access the file systems.

As per the update from php ( ) , this bug has gone unnoticed for at least past 8 years .

# Who all are affected ?

If you are using Apache mod_cgi to run PHP you may be vulnerable to this bug.

# Are you safe ?

Just pass the argument “ ?-s “ to any of  your php pages and see.  Are you shocked ???
If you pass the following arguments in your site , say :

1 )
Will dump your source code of the file index.php ( in simple words it will display the content of the file index.php )

Will display your /etc/passwd file !!!!!!!

# Which all php versions are affected ?

The PHP Group – PHP 5.3.11,PHP 5.3.10, 5.4.0 and  5.4.1

# How to fix ?

To fix this, upgrade your php to PHP 5.3.12 or PHP 5.4.2.

# Any Patch ?

Yes , php has provided  a temporary work around . I have tested and confirmed ( in php 5.3.10 )that  this will close the loop hole .
Apply the following rewrite rule in your sites DocumentRoot .htaccess file .

         RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]
         RewriteRule ^(.*) $1? [L]


# More Reference ?