Code Organization

Some would argue that any file not directly accessible to the user from the Internet should not find a place in the document root of the web site. For example, if the document root for our message board web site is /home/httpd/messageboard/www, we should place all of our .inc files and other files in a place such as /home/httpd/messageboard/code. When we want to include those files, we can simply write in our code:

require_once('../code/user_object.inc');

The reasons for this degree of caution come down to what happens when a malicious user makes a request for a file that is not a .php or .html file. Many web servers default to dumping the contents of that file to the output stream. Thus, if we were to keep user_object.inc in the public document root and the user requested it, he might see a full dump of our code in his web browser. This would let him see the implementation, get at any intellectual property we might have in this file, and potentially find exploits that we might have missed.

To fix this, we should be sure that the web server is configured to only allow the request of .php and .html files , and that requests for other types of files should return an error from the server.

Similarly, files such as password files, text files, configuration files, or special directories are best kept away from the public document root. Even if we think we have our web server configured properly, we might have missed something. Or if our web application is moved to a new server that is not properly configured in the future, we might be exposed to exploitation.

4 komentar:

DioLT said...

Hello admin

Just wanted to say your blog has great and informative content i am reading all one by one. thanks for sharing with us

Regards
F.Ahmed
http://www.diolt.com

Harish said...

It is really helpful as a beginners.Thanks for sharing useful blogs.

gamblingdada said...
This comment has been removed by the author.
gamblingdada said...

nice posting i have some information about this
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra
Vigra

top