tags:

views:

84

answers:

3

A new project requires a simple panel (page) for admin and staff members that:

  • Preferably will not use SSL or any digital ceritification stuff, a simple login from via http will just be fine.
  • has basic authentication which allows only admin to login as admin, and any staff member as of the group "staff". Ideally, the "credentials(username-hashedpassword pair)" will be stored in MySQL.
  • is simple to configure if there is a package, or the strategy is simple to code.
  • somewhere (PHP session?) somehow (include a script at the beginning of each page to check user group before doing anything?), it will detect any invalid user attempt to access protected page and redirect him/her to the login form.
  • while still keeps high quality in security, something I worry about the most.

Frankly I have little knowledge about Internet security, and how modern CMS such as WordPress/Joomla handle this.

I only have one thing in my mind: that I need to use a salt to hash the password (SHA1?) to make sure any hacker who gets the username and password pair across the net cannot use that to log into the system. And that is what the client wants to make sure.

But I am really not sure where to start, any ideas?

A: 

This has been much discussed on SO already, here are some of the useful links:

Sarfraz
@Sarfraz : thanks for the links, I am looking at them :)
Michael Mao
@Michael Mao: You are welcome....
Sarfraz
-1 its impossible to have a secure session without https. This is a clear violation of owasp a3: "Broken Authentication and Session Management." I'm sorry but i have to give a -1 to anyone on SO that purposes a vulnerability, its just the rules.
Rook
+1  A: 

Not using SSL would leave a pretty substantial hole in the whole system as it is pretty easy to sniff network traffic

nduplessis
@nduplessis : Yeah, this is what I am afraid of. I don't think the client will spend a dime for verisign. OpenSSL seems a bit hard to code from scratch for me. Maybe the hosting server will be so kind to offer the SSL channel?
Michael Mao
No special coding needed. Just get an SSL certificate. You can find many for under $20. You're webhost will install for you for a small fee. Small price for a lot of piece of mind.
webbiedave
@webbiedave : That's so wonderful to hear. I will convince the client to do this with his web hosting.
Michael Mao
+1 SSL is a **requirement** for any authenticated session.
Rook
+2  A: 

The use of HTTPS is an absolute requirement, and must be used for the entire life of the session. Keep in mind that session id's are used to authenticate browsers and if an attacker can obtain one (sniffing or xss), then he doesn't need a username/password. This is laid out by The OWASP Top 10 2010 A3 Broken Authentication and Session Management. If you want to implement secure session you must read that link.

md4,md5 sh0 and sha1 are all a broken message digest functions and can never be used for passwords. Any member of the sha-2 family is a good choice, sha256 is very large and is a great choice for passwords.

You should absolutely never transfer a password hash across the network or spill it to a user/attacker. If you are sending a hash to the server to authenticate then you have introduced a very serious vulnerability into your system. Using sql injeciton the password hash can be obtained from the database, then this hash can be simply replayed to authenticate, bypassing the need to crack the password hash. This is as if you are storing passwords in clear text.

Use the $_SESSION superglobal and session_start() to maintain your session state, never re-invent the wheal. The default PHP session handler is secure and will do what you need.

session_start();
if(!$_SESSION['logged_in']){
   die("Authentication required!");
}

Also make sure to implement CSRF protection into your system. Using CSRF an attacker can access the administrative panel by forcing your browser to send requests. Make sure to test your application for XSS this is a good free xss scanner, again xss can be used to hijack an authenticated session by using XHR or by obtaining the value of document.cookie. It is also a good idea to test for SQL Injection and other vulnerabilities, wapiti will do the trick.

Rook
@The Rook : thanks you so much for pushing up the basic rules. Now I see the point of having SSL is just a start. I will definitely seek ways to make sure the "average" hackers will not be too easy to crack the login system, and I must let the client know it is for his own good to take this long to implement such a "little" thing :)
Michael Mao