PHP Security PHPSecurity

Source: Internet
Author: User
[Original book information] SAMSTeachYourselfPHPin10Minutes Author: ChrisNewmanPublisher: SamsPublishingPubDate: March29, 2005 ISBN: 0-672-32762-7Pages: 264 [flip [Original book information]
SAMS Teach Yourself PHP in 10 Minutes
Author: Chris Newman
Publisher: Sams Publishing
Pub Date: March 29,200 5
ISBN: 0-672-32762-7
Pages: 264

[Translation information]
Translation staff: heiyeluren
Translation Time: 2006-3-15
Translated chapter: Lesson 24. PHP Security
Chinese name: PHP Security

PHP is undoubtedly a very strong server-side scripting language, but the powerful effect is always accompanied by a major danger. in this chapter, you will learn how to apply the security mode of PHP to prevent some dangerous elements of PHP ambush.

[Security mode]

The security mode of PHP provides a basic and secure sharing environment on a PHP open Web server with multiple user accounts. When PHP running on a Web server opens the safe mode, some functions will be completely disabled and some available functions will be limited.

[Application security mode to force restrictions]
In safe mode, some function functions that attempt to visit the file system will be limited. Run the Web server user id. if you want to hold a file, you must have the access permission to read or write the file. to achieve this restriction, PHP has no title.

When security mode is enabled, PHP checks whether the visiting user is the owner of the target file when it tries to read or write a local file. If it is not the owner, the hold will be disabled. (Write permission: If you have a lower level of file access permission, you may promise to read or write the file that the system holds the system, the PHP Security mode prevents you from holding another user file. Of course, a Web server may be able to visit any file with the global write permission .)

When security mode is enabled, the functions of the following function lists are limited:

Chdir, move_uploaded_file, chgrp, parse_ini_file, chown, rmdir, copy, rename, fopen, require, highlight_file, show_source, include, symlink, link, touch, mkdir, unlink
 
Similarly, some PHP extended functions will also be affected. (Loading module: in safe mode, the dl function will be disabled. if you want to load expansion, you can only modify the expansion option in php. ini and load it at PHP startup)

When enabling the PHP Security mode, you must specify the directory program in the safe_mode_exec_dir option when executing the System program control. Otherwise, the execution will fail. Even if the request is fulfilled, it will be passed to the escapeshellcmd function for filtering.

The following list of functions that execute the command will be affected:
Exec, shell_exec, passthru, system, popen

In addition, the back Flag Identifier (') will also be closed.

When running in safe mode, the putenv function will be invalid, though it will not cause errors. Similarly, some other functions that try to change the PHP environment variables set_time_limit and set_include_path will also be neglected.

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.