Wirebook

Wirebook › Lesson 15 of 18

How does a website check your password without keeping it?

About 8 minutes · hands-on · nothing you type leaves your browser unless a button says so

You type your password, and the website lets you in. So the website must keep a copy of your password somewhere… right? A careful one doesn't. It keeps something cleverer: a scrambled fingerprint it can check against but can't turn back into your password. Here are three pretend websites storing the same accounts, a thief who steals all three, and a meter that shows how long your password would last.

The password vault

Make up a password, never one you really use. We'll create your account, plus four friends', on three websites that store passwords in different ways. Then a thief steals the databases. Everything happens inside this page: nothing you type is sent anywhere.

Type a made-up password, then press Make the accounts.

Site A stores the password itself

    Site B stores a plain fingerprint (SHA-256)

      Site C salt + slow fingerprint (PBKDF2)

        How can a website check a password it doesn't keep?

        When you make an account, a careful website runs your password through a hash: a recipe that turns any text into a long jumble of letters and numbers, a fingerprint. The same password always makes the same fingerprint, but you can't run the recipe backwards. The website saves only the fingerprint.

        When you log in, it runs what you typed through the same recipe and compares the two fingerprints. If they match, you typed the right password. The website never needed to remember the password itself, and nobody who works there can read it. That's why a good site can't "email you your password" when you forget it; it can only let you set a new one.

        Site A is the bad one. If a website can tell you your old password, it's storing it, and anyone who breaks in can read every password at once. Thieves then try those same passwords on other sites, which is why using one password everywhere is risky.

        What are salt and slow fingerprints for?

        Fingerprints alone aren't enough. A thief who steals Site B's list can't reverse the fingerprints, but they can guess: take a list of favourite passwords ("123456", "sunshine", "pizza2015"…), fingerprint each one and look for matches. Plain fingerprints are so fast to make that one gaming graphics card can try around ten billion guesses a second. Worse, two people with the same password get the same fingerprint, so one lucky guess opens both.

        Careful sites add a salt: a few random characters, different for every person, mixed in before the fingerprint is made. Now Otter's and Badger's "sunshine" fingerprints look completely different, and the thief has to start over for every single person. Then they make the recipe deliberately slow, repeating it thousands of times (recipes called PBKDF2, bcrypt, scrypt and Argon2). You don't notice a quarter of a second when you log in once, but a thief making billions of guesses does.

        Salt and slowness buy time. They don't make "sunshine" safe, because it's near the top of every guess list. That part is up to you.

        How long would a thief need?

        Type a made-up password. The meter thinks like a thief: common passwords first, then words with numbers stuck on, then whole words, then every combination. It's a rough guide; real thieves are cleverer still.

        Passphrase words come from the EFF short word list (Electronic Frontier Foundation, CC BY 3.0 US), picked with your browser's secure random numbers.

        Long and random beats clever

        A thief doesn't try letters one by one. They try the things people actually choose: names, pets, football teams, "password1", a word with a year and an exclamation mark on the end. Swapping "o" for "0" doesn't fool them either; their lists already include those swaps. What really slows a thief is length chosen at random.

        That's why a passphrase works so well: five or six random words, like the ones the dice button makes. Each extra random word multiplies the guessing by over a thousand, and a silly picture ("a blade, a diner, a nutty radar") is easier to remember than "Tr0ub4dor&3". Better still, let a password manager invent a different long password for every site and remember them for you; then you only need one strong passphrase.

        A second lock: the code on your phone

        Suppose a thief got your password anyway. With two-step verification, the site also asks for a short code that only your phone can show, and it changes every few seconds.

        Your phone––– –––

        Press a button to start the pretend phone.

        The one trick that beats the code. Thieves can't guess the code, so they try to make you hand it over: a message that looks like it's from a game or a bank, saying "type your password and the code here". A real website will never ask you to send it the code in a message. If you didn't just try to log in yourself, don't type the code anywhere, and tell a grown-up or change your password. Spotting lookalike links is in anatomy of a web address.
        Same idea as face unlock. Your phone doesn't keep a photo of your face; it keeps numbers that describe it and checks new scans against them (see how face unlock knows it's you). Passwords work the same way: keep a fingerprint, compare, never store the real thing.

        Words from this lesson

        Earn your stamp

        Get all 3 right to collect the Passwords stamp. Wrong answers are fine: just try again.

        1. What does a careful website store instead of your password?

        2. Two people both use 'sunshine'. Why does salt help?

        3. Which is hardest for a thief to guess?

        Try another lesson

        1. 16How can you spot a fake message?7 min · interactive
        2. 17What are bots doing on the web?7 min · interactive
        3. 18What is a cookie on a website?7 min · interactive