Phpinfo() PHP Magic Quotes Gpc is On

OWASP 2013-A5 OWASP 2017-A6 OWASP 2021-A5 CAPEC-346 CWE-213 ISO27001-A.18.1.3 WASC-13

The PHP magic_quotes_gpc is a process that automatically escapes all the incoming data to the PHP script. The details about PHP magic_quotes_gpc can be viewed using phpinfo(). If an attacker successfully executes phpinfo(), he will be able to view all the details about the server. So it is recommended to disable phpinfo() in PHP.


The following code is the example of vulnerable php.ini. Here, magic_quotes_gpc is set as on.

        magic_quotes_gpc = on


If server configuration is accessible. Then, it will be available in .htaccess.

        php_flag magic_quotes_gpc on



The impacts include:-

  • An attacker can get access to sensitive information about the server like physical paths, environment variables, and the full PHP configuration settings. The attacker can use this information to exploit the server and can compromise the application completely.

Mitigation / Precaution

Beagle recommends the following fixes:-

  • Disable phpinfo() from PHP present in the server.
  • Update PHP to the latest version or try to at least use the PHP version 5.4. In version 5.4 and above, magic_quotes_gpc is removed for improving the security of the server and the application.
  • If you are using older versions of PHP (before 5.4), set magic_quotes_gpc as off in both .htaccess and php.ini. The below code is to be added in php.ini.
        magic_quotes_gpc = off


The below code is to be added in .htaccess:-

        php_flag magic_quotes_gpc off


Latest Articles