Jump to content


Security tips

  • Please log in to reply
4 replies to this topic

#1 KittyKate

  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 04 August 2006 - 05:49 PM

I'm hoping to get some tips on the ever important issue: security.

I've taken over development on a site and already found a half dozen ways to crack it just going through it, and am working on fixing them and adding in more security. Here's a list of what I'm doing, do you have any suggestions for more?

  • all sql strings are created using sprintf("string %s", mysql_real_escape_string($var))
  • all form actions are post
  • form data is set very cautiously (the previous version I was working with set the value of the password on the login page if the password was entered incorrectly!)
  • I'm using an OO design, and checking permissions in each function.
  • session data is stored on the client side as cookies and compared with the server side at the same time as checking permissions
  • cookies expire after 3.5 hours
  • if a call is made to an area permissions aren't granted, the IP address is logged. If an IP has X 'access denied's, it is blocked for 24 hours. If it has Y instances of being blocked, it is banned. I'm thinking X=Y=3, but I'd appreciate suggestions and reasoning for the values. I know it's possible to change IP addresses, but it can help stop the less-skilled hacker or those just looking for holes.
  • database username and password are stored below the public level in an oddly named file
  • user passwords are encripted

Further suggestions? Anything obvious I've missed?
PHP Version 4.3.2
MySQL version unknown (greater or equal to 3.23)

#2 ronverdonk

  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 04 August 2006 - 06:06 PM

And what about validation? You must scrutinize every piece of data that comes into your system, whether it be GET, POST, COOKIE, file data, etc. You can lock your system from the inside, but what about from the outside to in?

Ronald  8)
RTFM is an almost extinct art form, it should be subsidized.

#3 mainewoods

  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 04 August 2006 - 06:10 PM

-regenerate the session id every time the user logs on(helps prevent session hijacking)

session_regenerate_id(); //a little extra security against hackers

--store the users user agent in a session variable when the user logs on and make that part of the security check on each page(just a little extra protection):

if ($_SESSION['yourbrowser'] != $_SERVER['HTTP_USER_AGENT'])
    //fails security!

--if the user logs off, destroy the session:

$_SESSION = array();

#4 HeyRay2

  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 04 August 2006 - 06:18 PM

Lots and lots of animated badgers on your login page. That will keep those hackers at bay! ...  ;D

Seriously though, it sounds like you are on the right track.

Just be sure to validate all input your get from the user, and keep tabs on where they go and what they do.

Good luck!

#5 KittyKate

  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 04 August 2006 - 07:46 PM

Thanks! I forgot to say that! Yes, I am validating all data coming in, and doing some extra validation on the client-side using javascripts.

I'm still working on figuring out sessions (I've been going through the code I know how to work with or can learn by reading a paragraph, then I'll come back to what is new) in php. My previous web languages experience was in PERL. Horrible, horrible, ugly language! I've obviously done cookies before, but actually having a session variable is new. I'll be looking into fully using them, and thanks for the snippets of what to make sure I include!

Badgers huh? Well, I'll have lots of trees.... (the company I work for is in Forestry)
PHP Version 4.3.2
MySQL version unknown (greater or equal to 3.23)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users