PHP Security-source code exposure

Source: Internet
Author: User
Source code exposure an important issue about inclusion is the exposure of source code. The main cause of this problem is the following common situation: l use the. inc extension l & amp ;...



Source code exposure

An important issue about inclusion is the exposure of source code. The main cause of this problem is the following common situations:

L use the. inc extension for inclusion files

L contains files stored in the home directory of the website

L Apache does not set the. inc file type

L the default file type of Apache is text/plain.

As a result, you can directly access the contained files through URLs. Worse, they will be processed as plain text instead of parsed by PHP, so that your source code will be displayed on your browser (see-1 ).

Figure 5-1. source code exposure on the server

It is easy to avoid this situation. You can only reorganize your application and put all the contained files out of the home directory of the website. The best way is to put only the files that need to be publicly published under the home directory of the website.

Although this sounds crazy, in many cases it can lead to exposure of source code. I have seen that Apache configuration files are mistakenly written (and not found before next startup). inexperienced system administrators upgraded Apache but forgot to add PHP support, there are a lot of other situations that can cause source code exposure.

By saving as much PHP code as possible outside the home directory of the website, you can prevent Source code exposure. At least, it is the best way to save all the contained files out of the home directory of the website.

Some methods can limit the possibility of source code exposure, but they cannot fundamentally solve this problem. These methods include configuring the. inc file in Apache for the same processing as the php file, including the file using the. php suffix, and configuring Apache cannot accept direct requests to the. inc file:

 
 
        Order allow,deny      Deny from all  
 

Although these methods have their own advantages, none of them is more secure than storing files in the home directory of a website. Do not rely on the above methods to protect your applications, at most treat them as in-depth prevention.

The above is the content exposed by PHP Security-source code. For more information, see PHP Chinese website (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.