User Tools

Site Tools


securing_php

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
securing_php [2015/10/15 13:56] – created luke7858securing_php [2024/05/23 07:26] (current) – external edit 127.0.0.1
Line 2: Line 2:
 After you have installed php you should go about securing php. After you have installed php you should go about securing php.
 \\ \\
-One major issue with php.ini file is a line of code:+One major issue with php.ini file the following entry. Please note, if the line below is commented out AND =0 is NOT specified then the server will default to the value =1
 <sxh bash> <sxh bash>
 cgi.fix_pathinfo=1 cgi.fix_pathinfo=1
 </sxh> </sxh>
-You can grep for the file in your php.ini file with:+You can find this entry in your php.ini with the following command:
 <sxh bash> <sxh bash>
 grep 'cgi.fix_pathinfo' /etc/php.ini grep 'cgi.fix_pathinfo' /etc/php.ini
Line 12: Line 12:
 Explanation:  Explanation: 
 \\ \\
-When +When the value of cgi.fix_pathinfo=1 then the PHP interpreter will process files with similar file names rather than exact names.  
 +\\ 
 +For example, if the script mysript.php cannot be found the PHP interpreter will try to find a similar file name such as myscript.jpg and try to execute this. 
 +\\ 
 +This is obviously a security risk. 
 +\\ 
 +\\ 
 +Make sure you commend out cgi.fix_pathinfo=1 
 +\\  
 +Example: 
 +<sxh bash> 
 +;cgi.fix_pathinfo=1 
 +</sxh> 
 +And then add the following: 
 +<sxh bash> 
 +;cgi.fix_pathinfo=0 
 +</sxh> 
 +=== Testing === 
 +The following command can be used to view the value of php-fpm cgi.fix_pathinfo 
 +<sxh bash> 
 +php-fpm -i 2>&1 | grep 'pathinfo' 
 +</sxh>
securing_php.1444917398.txt.gz · Last modified: 2024/05/23 07:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki