Jump to content

Archived

This topic is now archived and is closed to further replies.

KittyKate

Security tips

Recommended Posts

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?

[list]
[*]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[/list]

Further suggestions? Anything obvious I've missed?
[/list]

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
-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):

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

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

[quote]$_SESSION = array();
session_destroy();
session_write_close();[/quote]

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.