|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi.
I am building a simple session-based user system with php. To log in users, I take their login and password and then compare the values against values stored in the mysql database. If values match, I register a session and that is it, the user is loged in. Before rolling it out, I would like to know if these measures are enough securitywise? What else can I do to ensure tight security? The authentication process that I am using is in every PHP book, so I am worrying that hackers must have found a way around this simple step. I am on a shared host on FreeBSD with Apache, PHP and MYSQL. Thank you for all your input. I believe this information will be of use to many of us who are making first steps in PHP development. z01d |
|
|||
|
Quote:
Joe |
|
||||
|
You could run the server in https and have all transmitted data encrypted also. It's a simple matter of setting up ssl and including a directive in the .htaccess file or in the apache config file. Less prone to traffic sniffing that way.
__________________
http://www.usalug.org USA Linux Users Group usalug.org is an online forum for Linux users. |
|
|||
|
Your host also should take care of some points.
Should never allow the warning or error messages to display the full path of the server. If your script sending some error message along with the file name if path is exposed then hacker will get a idea of session dirctory and other sites hosted in the same server. I have seen one host showing this. If you are allowing members to sign up, then only allow numbers or letters. One of my client once asked me to add this check in signup form as this allows hackers to use sysmbls like / , ? etc and get some info on the server , directory etc.. I don't know how this works. Life of the session ID is important and it should not last for more than some few minutes if the browser is in no contact with the server.
__________________
PHP HTML SQL tutorials and articles. Free scripts:Web Hosting Directory:Funny Star Jokes: |
|
|||
|
Smo is right. If you haven't protected against SQL injection your in trouble. Also I would look at saving the password in the database as a hash. Here is an example using mysql's built in function:
mysql> SELECT PASSWORD('mypass'); +--------------------+ | PASSWORD('mypass') | +--------------------+ | 6f8c114b58f2ce9e | +--------------------+ I don't see a link to your site though so it's hard to make more sugestions. |
|
||||
|
I am not entirely sure how or what code would be used but I did read the following from a white paper on web security.
It might allow someone to type in something like this into the form "print `cat /etc/passwd`" (or worse) as the input string. Another common security breach is to do backward directory traversing using ../ Eric <><><><><><><><><><> My two companies: Affordable Web Makeovers | Kanantik – Belize Resort |
|
||||
|
One other simple thing that can be done is to apply validation to the forms to make sure your visitors can only input what is needed and/or wanted.
A surprisingly overlooked mistake is to not set a maxlength value to your input boxes. The likelyhood of accidently excluding someone who has an email address of over 40-50 characters is pretty small. <input type="text" name="MAILFROM" VALUE="" maxlength="40" size="20"> Eric <><><><><><><><><><><><><><> My two companies: Affordable Web Makeovers | Kanantik - Belize Resort |
|
|||
|
USALUG, thanks for your suggestion, I will have to look if my host offers https option for me and how much it costs.
Williamc, good suggestion. I read somewhere that HTTP authentication is the most secure authentication method there is. The problem with HTTP authentication is that I do not want users to be thrown an HTTP Auth password screen nor do I want them to be redirected to a separate “members” area. I would like to have the login and password fields on the main page of the site, in the same as it is done here at webproworld (the top-right “username” and “password” boxes). I recon that if I strive for maximum usability to attract repeat users (and I should, according to the numerous postings on this forum), a user should have access to all frequently-used features of the site on the main page. Xcalabers, I found another hashing method in PHP through md5() function, which one is better mysql password() or php md5()? So now, this is what I am going to do (please critique or comment on the below steps, your input is very valued): 1.Limit the maxlength value to the input boxes to say, 15 letters (thank you, nelsonez). 2.Use addslashes() on the variables to prevent mysql injection. Will have to make sure that magic_quotes is turned off in the php directive on my host (thank you, smo). 3.Encrypt the password through md5() and check it against the encrypted passwords stored in the database. I think this is useful because even if someone gets access to the user table, he will not know the initial password, only its encrypted value. 4.Register a session variable, i.e. $_SESSION['valid_user'] and redirect user to the members area. Z01d |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |