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.
If server configuration is accessible. Then, it will be available in .htaccess.
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.
The below code is to be added in .htaccess:-
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.