Phpinfo() PHP Magic Quotes Gpc is On

By
Prathap
Published on
02 Apr 2022
1 min read

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.

Example

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

    

Impact

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

    
Automated human-like penetration testing for your web apps & APIs
Teams using Beagle Security are set up in minutes, embrace release-based CI/CD security testing and save up to 65% with timely remediation of vulnerabilities. Sign up for a free account to see what it can do for you.

Written by
Prathap
Prathap
Co-founder, Director
Find website security issues in a flash
Improve your website's security posture with proactive vulnerability detection.
Free website security assessment
Experience the power of automated penetration testing & contextual reporting.