Click here to Skip to main content
15,895,084 members

The Insider News

   

The Insider News is for breaking IT and Software development news. Post your news, your alerts and your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be removed. If you wish to ask a programming question please post it here.

Get The Daily Insider direct to your mailbox every day. Subscribe now!

 
GeneralRe: Salted Password Hashing - Doing it Right Pin
wout de zeeuw27-Oct-12 3:37
wout de zeeuw27-Oct-12 3:37 
GeneralRe: Salted Password Hashing - Doing it Right Pin
TheGreatAndPowerfulOz27-Oct-12 4:25
TheGreatAndPowerfulOz27-Oct-12 4:25 
GeneralRe: Salted Password Hashing - Doing it Right Pin
wout de zeeuw27-Oct-12 4:32
wout de zeeuw27-Oct-12 4:32 
GeneralRe: Salted Password Hashing - Doing it Right Pin
Marco Miltenburg28-Oct-12 20:54
Marco Miltenburg28-Oct-12 20:54 
GeneralRe: Salted Password Hashing - Doing it Right Pin
wout de zeeuw29-Oct-12 0:28
wout de zeeuw29-Oct-12 0:28 
GeneralRe: Salted Password Hashing - Doing it Right Pin
Schmuli29-Oct-12 8:20
Schmuli29-Oct-12 8:20 
GeneralRe: Salted Password Hashing - Doing it Right Pin
TheGreatAndPowerfulOz29-Oct-12 8:37
TheGreatAndPowerfulOz29-Oct-12 8:37 
GeneralRe: Salted Password Hashing - Doing it Right Pin
Taylor Hornby30-Oct-12 9:09
Taylor Hornby30-Oct-12 9:09 
Thanks for the feedback. I got a few emails about this so I added a subsection to the page explaining it. It's under the heading 'In a Web Application, always hash on the server' if you want to read it in HTML, but I'll copypaste it here so readers don't need to hunt it down.

Here's what I wrote:

If you are writing a web application, you might wonder where to hash. Should the password be hashed in the user's browser with JavaScript, or should it be sent to the server "in the clear" and hashed there?

Even if you are hashing the user's passwords in JavaScript, you still have to hash the hashes on the server. Consider a website that hashes users' passwords in the user's browser without hashing the hashes on the server. To authenticate a user, this website will accept a hash from the browser and check if that hash exactly matches the one in the database. This seems more secure than just hashing on the server, since the users' passwords are never sent to the server, but it's not.

The problem is that the client-side hash logically becomes the user's password. All the user needs to do to authenticate is tell the server the hash of their password. If a bad guy got a user's hash they could use it to authenticate to the server, without knowing the user's password! So, if the bad guy somehow steals the database of hashes from this hypothetical website, they'll have immediate access to everyone's accounts without having to guess any passwords.

This isn't to say that you shouldn't hash in the browser, but if you do, you absolutely have to hash on the server too. Hashing in the browser is certainly a good idea, but consider the following points for your implementation:

- Client-side password hashing is not a substitute for HTTPS (SSL/TLS). If the connection between the browser and the server is insecure, a man-in-the-middle can modify the JavaScript code as it is downloaded to remove the hashing functionality and get the user's password.

- Some web browsers don't support JavaScript, and some users disable JavaScript in their browser. So for maximum compatibility, your app should detect whether or not the browser supports JavaScript and emulate the client-side hash on the server if it doesn't.

- You need to salt the client-side hashes too. The obvious solution is to make the client-side script ask the server for the user's salt. Don't do that, because it lets the bad guys check if a username is valid without knowing the password. Since you're hashing and salting (with a good salt) on the server too, it's OK to use the username (or email) concatenated with a site-specific string (e.g. domain name) as the client-side salt.

GeneralRe: Salted Password Hashing - Doing it Right Pin
fickendichdu29-Oct-12 9:59
fickendichdu29-Oct-12 9:59 
GeneralRe: Salted Password Hashing - Doing it Right Pin
bpfh29-Oct-12 10:25
bpfh29-Oct-12 10:25 
GeneralRe: Salted Password Hashing - Doing it Right Pin
ThatEffinIanHarrisBloke29-Oct-12 20:14
ThatEffinIanHarrisBloke29-Oct-12 20:14 
GeneralRe: Salted Password Hashing - Doing it Right Pin
bpfh30-Oct-12 10:28
bpfh30-Oct-12 10:28 
GeneralRe: Salted Password Hashing - Doing it Right Pin
ThatEffinIanHarrisBloke30-Oct-12 15:39
ThatEffinIanHarrisBloke30-Oct-12 15:39 
NewsWhy Coding Style Matters PinPopular
Terrence Dorsey25-Oct-12 11:03
sitebuilderTerrence Dorsey25-Oct-12 11:03 
GeneralRe: Why Coding Style Matters Pin
Andrew Torrance28-Oct-12 13:54
Andrew Torrance28-Oct-12 13:54 
NewsSSH key and passwordless login basics for developers Pin
Terrence Dorsey25-Oct-12 11:02
sitebuilderTerrence Dorsey25-Oct-12 11:02 
NewsRob Pike - 'Concurrency Is Not Parallelism' [video] Pin
Terrence Dorsey25-Oct-12 11:02
sitebuilderTerrence Dorsey25-Oct-12 11:02 
NewsTypescript - a real world story of adoption in TFS Pin
Terrence Dorsey25-Oct-12 11:02
sitebuilderTerrence Dorsey25-Oct-12 11:02 
GeneralRe: Typescript - a real world story of adoption in TFS Pin
Ravi Bhavnani25-Oct-12 11:25
professionalRavi Bhavnani25-Oct-12 11:25 
NewsThe future of .NET lies in Mono. The future of F# lies in MonoDevelop. Pin
Terrence Dorsey25-Oct-12 11:01
sitebuilderTerrence Dorsey25-Oct-12 11:01 
GeneralRe: The future of .NET lies in Mono. The future of F# lies in MonoDevelop. Pin
Marc Clifton25-Oct-12 11:58
mvaMarc Clifton25-Oct-12 11:58 
GeneralRe: The future of .NET lies in Mono. The future of F# lies in MonoDevelop. Pin
devvvy25-Oct-12 15:02
devvvy25-Oct-12 15:02 
GeneralRe: The future of .NET lies in Mono. The future of F# lies in MonoDevelop. Pin
Jörgen Andersson25-Oct-12 20:29
professionalJörgen Andersson25-Oct-12 20:29 
GeneralRe: The future of .NET lies in Mono. The future of F# lies in MonoDevelop. Pin
Nemanja Trifunovic26-Oct-12 3:01
Nemanja Trifunovic26-Oct-12 3:01 
GeneralRe: The future of .NET lies in Mono. The future of F# lies in MonoDevelop. Pin
BrainiacV26-Oct-12 3:47
BrainiacV26-Oct-12 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.