The safety mode PHP safe_mode option aims to solve some of the problems described in this chapter. However, it is not correct in terms of architecture to solve such problems at the PHP level, as described in the PHP Manual (php ....
Security mode
The safe_mode option of PHP aims to solve some problems described in this chapter. However, solving such problems at the PHP level is not correct in terms of architecture, as described in the PHP Manual (#).
When the security mode is effective, PHP checks the owner of the files read (or operated) by the script being executed to ensure that it is the same as the owner of the script. Although this does prevent many examples in this chapter, it does not affect programs written in other languages. For example, a CGI script written in Bash:
#!/bin/bash echo "Content-Type: text/plain" echo "" cat /home/victim/inc/db.inc
Will the Bash parser care about or even check the configuration strings in the PHP configuration file that enable the security mode? Of course not. Similarly, other languages supported by the server, such as Perl and Python, do not care about this. All examples in this chapter can be easily adapted into other programming languages.
Another typical problem is that the security mode does not deny access to files on the WEB server. This is because a script can be used to create another script, and the new script belongs to the WEB server, so it can access all files belonging to the WEB server:
'; file_put_contents($filename, $script); ?>
The above script creates the following file:
Because the file is created by a Web server, its owner is a Web server (Apache generally runs as a nobody user ):
$ ls file.php -rw-r--r-- 1 nobody nobody 72 May 21 12:34file.php
Therefore, this script can bypass the security measures provided by many security modes. Even if the security mode is enabled, attackers can display some information, such as session information stored in the/tmp Directory, because these files belong to the Web server (nobody ).
PHP's security mode does play a role. it can be considered as a deep defense mechanism. However, it only provides poor protection, and there are no other security measures in this chapter to replace it.
The above is the content of PHP security-security mode. For more information, see PHP Chinese network (www.php1.cn )!