Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending passwords over the web

So I'm working on a mobile platform application that I'd like to have users authenticate over the web. I was wondering the best way to do security. The user is sending a password for HTTP to a php server wich authenticates against a mysql database on the same server. Obviously I don't want to send the password in plain text over the internet, but I also don't want to do 2 SHA hashes.

This is what the server looks like (in pseudocode)

$pass = $_POST['pass'];

if ((get PASSWORD where USERNAME = USERNAME) == SHA($pass)) return PASS;

This is pretty standard and I don't think there's any other way to do this. But I was wondering how I should prepare the data before sending it over the internet.

like image 932
Falmarri Avatar asked May 09 '10 09:05

Falmarri


People also ask

Is it safe to send passwords over HTTPS?

Quick Answer:It is a standard practice to send "plain text" passwords over HTTPS via POST method. As we all know the communication between client-server is encrypted as per TLS, so HTTPS secures the password.

Is it safe to share passwords over email?

You might be wondering why it's a bad idea to share passwords via email and the answer is a very simple one — security. Emails are often sent in “clear” or “plain” text. That means the content of the email is unencrypted. If the email is intercepted, it's trivial to extract your password from it.

Should you share your password online?

You should never share your password or another individual's password for the following reasons: Your unique IPFW username and password is your identity in the digital world. Sharing passwords at the workplace is the same as giving away a personal identity.


2 Answers

  1. If you want security, YOU. MUST. USE. HTTPS. With a proper, non-self-signed certificate. Whatever you do, identities that are authenticated in unencrypted communication will be trivial to steal. (Never mind the password, the attacker can simply steal the session cookie that is provided with every request.)
  2. Hashing is worthless in itself, you must salt it. (This is not really related to authentication - it is a second layer of defense for the case when someone steals your database. Which will probably happen sooner or later if you become a promising target.) Use bcrypt with long random per-user salt, sha* is insecure because it is too fast.
  3. Use methods that are already in use by large, security-aware projects. Those methods have, to some degree, withstood the test of time. There are challange-response based methods that avoid sending the password in any form, but crypto is hard, and it is very easy to implement secure algorithms in an insecure way. Use a good security framework (e.g. PHPass), don't rely on code that is not widely in use.
like image 108
Tgr Avatar answered Sep 26 '22 10:09

Tgr


You could use SSL if your client app supports it.

like image 29
Pekka Avatar answered Sep 26 '22 10:09

Pekka