PHP security-security mode

Source: Internet
Author: User
Tags safety mode
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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.