Suppose that I login to a website. When I type my personal data, aka, password and email, the password is sent in clear text to the server, correct? Then, a network card in promiscuous mode can capture the password?

How this can be avoided?


https is designed to prevent this kind of attack: The communication between you and the server is encrypted. The server will provide a certificate to ensure that it is the correct one and not a man in the middle.. If the certificate is signed by an certification authority trusted by your browser, the connection will be accepted automatically. Otherwise you will get a warning about an untrusted certificate. If you are in doubt, don't click it away.

There is really no excuse not to use https for login, as simple trusted certificates are really cheap or free of charge. https should be used for everything, but some huge sites argue that it uses too much processing power.

  • then, i can capture a password if the facebook login is made in http? – Fel Jul 1 '11 at 12:00
  • 1
    yes, if you can trick a user into using http instead of the default https for the login (e. g. if he goes to the http version of the start page and you manipulate the login form not to point to https://www.facebook.com/login.php?login_attempt=1) – Hendrik Brummermann Jul 1 '11 at 13:23
  • @Hendrik Brummermann: sslstrip will do it for you. As such it's important for the whole page to be provided over a secure channel, otherwise the password can be sent over unsecured connection by manipulating the web site code on the fly. – Hubert Kario Jul 11 '11 at 23:20
  • @Hubert Kario, in order to protect the password, the login form and the target of the login form must use SSL (and the same for a change password form). If the rest of the page does not use SSL the password cannot be exposed using sslstrip, although other nasty things can be done in the name of the victim. – Hendrik Brummermann Jul 12 '11 at 5:36
  • @Hederik Brummermann: when page is not served over SSL the user won't notice when the whole session is performed over plain HTTP, the attacker can modify the HTML, and remove the parts that enforce SSL or direct to https. The server won't notice because the connection it gets will be over ssl, just not the user's but attacker's. User has no way of knowing if the transaction is performed over secure link when only part of the connection is performed over SSL. – Hubert Kario Jul 12 '11 at 9:08

Please refrain from thinking "it's passing through an SSL stream so nobody will be able to intercept it".
It's the same thing as saying "I'm sending money via a letter, nobody is entitled to open it".

A lot of companies can generate a valid HTTPS certificate, some shady sells their certificate to unauthorized people, some other simply are vulnerable and generate certificate unwillingly, either way you can buy a certificate in the black market for less than 1000$.

I suggest to use hash challenge on top of HTTPS:

  1. The server sends a random string
  2. The client append the random string to the password and send back the hashed string
  3. The server does the same and the hash match the user is authenticated

To do this you have either (1) to have the password in the server-side, (2) use an hashing algorithm which doesn't use hidden state so you can load an already hashed password from db and append the random string.

Avoid choosing a fast hashing algorithm, such as SHA, but choose instead a designed-to-be-slow algorithm, such as bcrypt.

There are also other ways to authenticate using the password but without sending it.

  • 3
    You completely overstate the problem with certificates in TLS in your first paragraph. And you need more than just a certificate in order to decrypt a TLS stream. Like, the stream. The rest of your answer is about designing a new password passing scheme, which is beyond the scope of the question. – schroeder May 12 at 18:42
  • Once you have a valid certificate performing a man in the middle become trivial (unless the site is using certificate pinning). And the question is "How can I avoid sending passwords in plain text when logging into a website?" so, implementing a new password passing scheme is within the scope if you ask me. – workless May 12 at 21:28
  • 1
    not as an end user – schroeder May 12 at 21:29
  • oh, the thought that was an end-user only questione never crossed my mind, you are right – workless May 12 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.