tags:

views:

122

answers:

6

I am creating a website that is using a perl script, PHP, a MySQL database, and HTML. My main concern is making sure there is not anyway someone can gain access to anything that give them access to my information. I mean is there anyway for someone to get my perl script and see my database information. I know about sql injection but I have no forms for information to be entered into. Is there anything I should keep in mind with this stuff.

+2  A: 

The breadth of this question is kind of overwhelming, but it's a great question and definitely important.

Much of the issues you are going to have with your server can be tied to server access itself, make sure you don't use any software you don't need. If you don't need a name server, turn off bind; same goes for ftp, even sendmail if you can. Use strong passwords and alternate ports if possible.

For PHP, see http://us3.php.net/manual/en/security.php and http://php-ids.org/; definitely use mysql_real_escape_string() and htmlentities().

For HTML/PHP/JS, see http://en.wikipedia.org/wiki/Cross-site_scripting

There is a lot to think about. I'd recommend trying to find a mentor to help you figure out what is important. I'm mentoring a guy right now and it helps him a lot even if I'm not perfect. SO can help, but a person you trust who can look at how you do things can make recommendations you just won't get here unless you post your entire code base.

Hans
+1  A: 

Web application security is a big topic. However, you know about one of the biggest vulnerabilities out there, SQL Injection, so that's a good start.

A couple other big ones are Cross Site Scripting (XSS) and Cross Site Request Forgery (CSRF - "See-Surf")

XSS - http://en.wikipedia.org/wiki/Cross-site_scripting
CSRF - http://en.wikipedia.org/wiki/Csrf

As usual Wikipedia provides a good intro.

You may also want to look in to verifying request authenticity by using an HMAC
http://en.wikipedia.org/wiki/HMAC

Eric
+1  A: 

Really go read this community wiki. Its full of information. Or just search here on stackoverflow there are many questions.

Iznogood
+2  A: 

is there anyway for someone to get my perl script and see my database information

This will only happen when the webserver doesn't parse/process the script and returns it as plaintext. Usually this parsing/processing only happens on specific file extensions like .pl for perl files and .php for PHP files. If you (or the hacker) renames it to .txt, the client will be able to obtain the entire script as plaintext. Nevertheless, if a hacker is able to rename it, it has access to the whole script anyway. This would then be done by a security hole in FTP or CMS.

Further, I've seen scripts which reads files (usually images or other static files) from (outside) the webapp context based on the path as a parameter. E.g. download.php?filename.ext If such a script doesn't do any sanity checks on the file path, a smart hacker may be able to obtain scripts as plaintext by download.php?%2Fserver%2Fhtdocs%2Fscript.php.

BalusC
This is a great point!!!
Mark
That's not the only way to see the source of a script. :)
brian d foy
+2  A: 
  1. Use placeholders for SQL, even PHP supports it.

  2. Escape your output. Your templating system may help here.

  3. Use cgi-bin directory. It really helps to protect accidental leaks. It is easy to make URLs without cgi-bin.

  4. In Perl use taint mode, in PHP use hardened PHP.

Alexandr Ciornii
+1  A: 

Never ever trust any user input in any form.. Ever :)

The hard part is figuring out all the ways a user can supply input to your site..

Øyvind Skaar