13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

382 Chapter 16 <strong>Web</strong> Application Security<br />

n<br />

Avoid using common names. Large numbers of automated programs out there<br />

look for scripts <strong>and</strong> programs in obvious subdirectories of our document root,<br />

such as Scripts/, cgi-bin/, bin/, <strong>and</strong> so on.<br />

Again, reading the documentation for IIS to learn more about recommended security<br />

procedures is highly recommended.<br />

Commercially Hosted <strong>Web</strong> Applications<br />

There is one group of users for whom the problem of security on virtual servers is a bit<br />

more problematic—those users running their web applications on a commercial<br />

<strong>PHP</strong>/<strong>MySQL</strong> hosting service. On these servers, you likely will not have access to<br />

php.ini, <strong>and</strong> you will not be able to set all the options you would like. In extreme cases,<br />

some services will not even allow you to create directories outside of your document<br />

root directory, depriving us of a safe place to put our include files. Fortunately, most of<br />

these companies want to remain in business, <strong>and</strong> having an insecure design is not a good<br />

way to keep customers.<br />

To be certain, you can <strong>and</strong> should do a number of things as you look into a service<br />

<strong>and</strong> deploy your web applications with them:<br />

n Before you even select the service, look through their support listings. Better services<br />

will have complete online documentation (we even found a few with excellent<br />

dynamic tutorials) that show you exactly how your private space is configured.You<br />

can get a feel for what restrictions <strong>and</strong> support you will have by browsing<br />

through these.<br />

n Look for hosting services that give you entire directory trees, not just a document<br />

root. Although some will state that the root directory of your private space is<br />

the document root, others will give you a complete directory hierarchy, where<br />

public_html/ is where you place your content <strong>and</strong> executable <strong>PHP</strong> scripts. On<br />

these, you could safely create an includes/ directory.This will help us ensure that<br />

people cannot see the contents of our .inc files.<br />

n Try to find out what values they have used in php.ini. Although many will probably<br />

not print these on a web page or email you the file, you can ask their support<br />

personnel questions such as whether safe mode is turned on, <strong>and</strong> which functions<br />

<strong>and</strong> classes are disabled.You can also use the ini_get function to see setting values.<br />

Sites not using safe mode or without any functions at all disabled will worry<br />

us more than those with some reasonable sounding configuration.<br />

n Look at what versions of the various pieces of software they are running. Are they<br />

the most recent ones? If you cannot see the output of something such as phpinfo,<br />

use a service such as Netcraft (http://www.netcraft.com), which will tell you<br />

which software a particular site is running. Make sure that they are indeed running<br />

<strong>PHP</strong>5!

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!