Checking a password without sending it

Basics

Checking against breach databases sounds like a contradiction: to check it, you must send it. Here is the trick that avoids that.

“Check your password against breach databases” sounds like a trap: to find out whether a password is in a database, you would seem to have to send it there. The technique that avoids this was worked out long ago, and it is elegant enough to be worth walking through in full.

Three steps

  1. The password is hashed on your side

    In the browser, with no network request at all. A hash is a forty-character string from which the password cannot be recovered.

  2. Only the first five characters go to the server

    Not the whole hash, just its beginning. That is far too little to identify a password: tens of thousands of different hashes share any given prefix.

  3. The server returns every matching hash

    All the hashes in its database starting with those five characters. The comparison then happens in your browser, among the ones sent back.

1in ~30,000
Is how much the server learns about your password

It sees a request for five characters and hands back the whole list under them. Which of the thirty thousand is yours — or whether any of them is — it never finds out: the comparison happens after the reply, on your side.

What the server does see

WhatVisible?
Your passwordNo
The full hash of your passwordNo
The first five characters of the hashYes — but that covers thousands of passwords
Your IP address and the time of the requestYes — as with any request
Whether the password was foundNo — the comparison happens on your side
How many times you checkedYes — from the number of requests
The technique protects the password, not the fact that you used the service. Those are different things, and it does not hide the second.

What to do with the result

A password that is found means one thing: it exists in public databases and is being tried automatically across hundreds of sites. It does not matter how it got there or how complex it looked.

  • Change it everywhere it was used, not only where you happen to remember.
  • Start with email — everything else is recovered through it.
  • Do not try to “patch” the password by adding a character: variations are generated automatically.

A password that is not found does not mean it is strong. The databases are incomplete and a fresh breach takes time to reach them — this is a check for known compromise, not a certificate of strength. What actually makes a password strong is covered in entropy.

Copied