A fake page that gets nothing
A member of staff gets an email: their account will close unless they sign in. The link opens a perfect copy of the college's page at a look-alike address. A password, or even a one-time code, typed there goes straight to the attacker.
With a passkey, the phone has nothing to give that page. This lesson shows why.
By the end of this lesson
Note
I can explain why a passkey resists phishing by checking what a site verifies.
Key words
| Word | What it means | Example |
|---|---|---|
| Passkey | a key pair that signs you in to one site | |
| Relying party | the site a passkey belongs to | rp id site |
| Authenticator | the phone, laptop or key that holds the private key | |
| Challenge | random bytes the site asks to have signed | |
| Origin | the address the browser is really on | |
| Sign count | a number that rises with every use |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsThe rule for this lesson
Warning
The look-alike site in this lesson is a script inside your own lab. Never build a copy of a real organisation's sign-in page without written permission, even as a test. Using what it collects is a crime under the Computer Misuse Act 1990.
A passkey is one site's key pair
When you add a passkey, your authenticator makes a new key pair for that site alone. The private key never leaves it. The site stores only the public key, which is useless to a thief.
To sign in, the site sends a random challenge. The authenticator checks you are there, often with a fingerprint or PIN that stays on the device, and signs. The site checks the signature with the public key.
Add a passkey to amira's account
docker exec john python3 steps/passkey.py registerShown here, not run. Press Start lab to type it into your own lab’s terminal.
Sign in with the passkey
docker exec john python3 steps/passkey.py loginShown here, not run. Press Start lab to type it into your own lab’s terminal.
Worked example: register and sign in
| What passkey.py printed | What happened |
|---|---|
| new key pair for rp id site, credential 48235ee546c6c10d | A key pair just for the site |
| public key x starts cd1563f3d39e4c31 | Only the public half went to the site |
| challenge from the site: 16 random bytes | A fresh challenge each time |
| signed ... with sign count 1, site says: ok | The signature checked out |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsThe browser says where it really is
Two things beat the fake page. The authenticator picks a key by the site's name, the relying party id, so a look-alike name finds no key at all.
And the browser writes the real origin into what is signed. A look-alike that forwards the real site's challenge still gets an origin the site refuses. The user never has to spot the fake address.
Play the look-alike site
docker exec john python3 steps/passkey.py phishShown here, not run. Press Start lab to type it into your own lab’s terminal.
Send an old signature again
docker exec john python3 steps/passkey.py replayShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think a passkey is a password kept on the phone. Nothing secret is sent or stored by the site: the phone proves it holds a private key by signing a fresh challenge. A stolen copy of the site's table holds only public keys.
Check
Have a go
Check
3 questionsTry it: a key chosen by name
# A passkey is chosen by the site's name, never by what a page looks like.
passkeys = {"site": "key 48235ee5"}
for page in ["site", "site-login.example", "slte"]:
if page in passkeys:
print(page, "->", passkeys[page])
else:
print(page, "-> no passkey, nothing signed")
# Add a passkey for "college.example", then ask for it, and press Run.
Make a free account to save your work and track your progress.
Synced passkeys, recovery and roll-out
Most passkeys sync across a person's devices through their phone or browser maker's account, so losing one phone loses nothing. NIST allows synced passkeys for most accounts, and device-bound security keys for the highest assurance.
Roll out by offering passkeys beside the password first, with recovery codes or a second key. Then turn passwords off for staff who have one.
The fix, and how to detect phishing
Fix: offer passkeys, and for admins and staff with access to student data, require them. A site must check the type, challenge, origin, relying party, user presence, signature and sign count every time.
Detect: log every refused assertion with its reason. Bursts of "wrong origin" show a look-alike in use, and a sign count that goes back suggests a cloned key.
Check
Have a go
Check
3 questionsAssignment: check an assertion
Write the checks a site makes on a passkey sign-in, before the signature. rp_hash(rp_id) returns the SHA-256 of the relying party id as lowercase hex. check(client, auth, expected) takes three dictionaries: client with "type", "challenge" and "origin"; auth with "rp_id_hash", "flags" and "count"; expected with "challenge", "origin", "rp_id" and "count" (the last sign count stored). Return the first problem found, in this order: "wrong type" unless the type is "webauthn.get"; "wrong challenge"; "wrong origin"; "wrong rp id"; "no user presence" when flags is even; "sign count went back" when the count is not above the stored one, unless both are 0. Otherwise return "ok".
import hashlib
def rp_hash(rp_id):
return ""
def check(client, auth, expected):
return "ok"
Make a free account to save your work and track your progress.
Exit quiz
Have a go