13.09.2016 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Additionally, we want to be extremely careful when we let users enter the name<br />

of a file they would like to see. If we had a directory in our document root (c:\<br />

Program Files\Apache Software Foundation\Apache2.2.htdocs\) with a bunch of<br />

files we were granting users access to, <strong>and</strong> they input the name of the file they wanted to<br />

view, we could get into trouble if they asked to see<br />

..\..\..\php\php.ini<br />

This would let them learn about our <strong>PHP</strong> installation <strong>and</strong> see whether any obvious<br />

weaknesses exist to exploit. Again, the fix to this problem is easy: if we do accept user<br />

input, make sure we filter it aggressively so as to avoid any problems of these sorts. For<br />

the preceding example, removing any instances of ..\ would certainly help prevent this<br />

problem, as would any attempt at an absolute path such as c:\mysql\my.ini.<br />

Code Stability <strong>and</strong> Bugs<br />

We mentioned this briefly before, but your web application is neither likely to perform<br />

well nor be terribly secure if the code has not been properly tested, reviewed, or is so<br />

complicated as to be full of bugs.This should not be taken as an accusation at all, but<br />

rather as an admission that all of us as programmers are fallible, as is the code we write.<br />

When a user connects to a website, enters a word in the search dialog (for example,<br />

“defenestration”), <strong>and</strong> clicks Search, the user is not going to have great confidence in the<br />

robustness or security of it if the next thing the user sees is<br />

¡Aiee! This should never happen. BUG BUG BUG !!!!<br />

If we plan from the beginning for the stability of our application, we can effectively<br />

reduce the likelihood of problems due to human error.Ways in which we can do this are<br />

as follows:<br />

n Complete a thorough design phase of our product, possibly with prototypes.The<br />

more people we have reviewing what we plan to do, the more likely we are to<br />

spot problems even before we begin.This is also a great time to do usability testing<br />

on our interface.<br />

n Allocate testing resources to our project. So many projects skimp on this, or hire<br />

perhaps one tester for a project with 50 developers. Developers do not typically make<br />

good testers! They are very good at making sure their code works with the correct<br />

input, but less proficient at finding other problems. Major software companies have<br />

a ratio of developers to testers of nearly 1:1, <strong>and</strong> although it may not be likely that<br />

our bosses would pay for that many testers, some testing resources will be critical<br />

to the success of the application.

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

Saved successfully!

Ooh no, something went wrong!