One-time codes, tokens and passkeys

9 min 5 sections 5 practice questions 10 sources citedISC2 objective 5.1

A phone, a key fob or a small security key can prove who someone is, because only one person is carrying it. Some of these devices show a code to type. Others answer the website directly, with nothing typed at all. No background is assumed. A security professional has to know which of them a fake website can defeat, and how to protect the device itself.

By the end of this unit you will be able to:

  • Tell apart counter-based (HOTP) and time-based (TOTP) one-time passwords
  • Tell apart synchronous and asynchronous tokens
  • Explain why codes, text messages and push approvals do not resist phishing
  • Explain how a passkey signs a user in without a shared secret
  • Choose controls for access to a device that holds an authenticator

Two genuine factors, typed into the wrong page

An illustrative example

A payroll officer at a building firm receives an email saying her session on the pension portal has expired. The link opens a page that looks exactly like the real one.

She types her password, then the six-digit code from the authenticator app on her phone. The page shows an error and asks her to try later. In those few seconds the people behind the page have typed the same password and code into the real portal. They are signed in as her.

She used two factors and both were genuine. What allowed someone else to use them?

What makes a device proof of identity

A token is a device or program that a user holds and that produces proof for authentication. A hardware token is a separate object, such as a key fob or a card. A software token is a program on a phone or computer that does the same job.

Most tokens hold a secret and prove they hold it without revealing it. For a code token, the server keeps a copy of the same secret. For a security key or smart card, the secret never leaves the device. Tokens differ in how the proof reaches the system. It can be a code the user reads and types, a message on a second channel, or a direct answer computed by the device.

A hand pushes a white identity card upright into a slot built into a computer keyboard, just above the number keys.

A smart card pushed into a reader built into a keyboard signs its holder in to the computer, and the card's secret never leaves the card.

  1. 1Card reader slot. The card's chip is read here, inside the keyboard.

Photograph: Someone inserting a Common Access Card in a keyboard (USMC-10139), public domain. Cropped and resized.

A static token gives the same value every time, like a card with a fixed number, so anyone who sees the value can reuse it. A one-time password (OTP) is a code that is valid for one sign-in or for a short moment and is useless afterwards.

One-time passwords: HOTP and TOTP

The token and the server share a , and each computes the same code from it. A second input changes every time, so that the code changes too.

Two standard ways to compute a one-time password
StandardThe changing inputWhat follows
HOTP, the HMAC-based one-time password (RFC 4226)A counter that goes up by one with each codeA code stays valid until it is used. The server accepts a few codes ahead, in case the button was pressed without a sign-in
TOTP, the time-based one-time password (RFC 6238)The current time, cut into steps of 30 seconds by defaultA code expires when its step ends. The clocks of token and server must agree

is a way of a message together with a secret key. Codes have at least six digits. An authenticator app on a phone is a software TOTP token.

Close view of a grey key fob with a small grey display window showing the six digits 225 646, and a cap covering one end.

A hardware token shows a six-digit one-time password that it computes from the current time and a secret key it shares with the server.

Photograph: RSA SecurID SID800 by Alexander Klink, CC BY 3.0. Cropped and resized.

Both kinds are synchronous tokens: token and server stay in step, by counter or by clock, and nothing is sent to the token. An asynchronous token uses challenge-response. The server shows a random number, the challenge. The user enters it into the token, and the token computes the answer from the challenge and its secret key. No clock or counter has to match.

A server must refuse a code it has already accepted. Otherwise someone who watched the code being typed could use it again within the same 30 seconds.

Out-of-band checks, and three ways they are abused

Out-of-band authentication uses a second, separate channel. The user signs in on a laptop, and the system sends a code or a request to the user's phone. An attacker would have to control both channels.

Text message or voice call
The code travels over the telephone network. In a SIM swap, an attacker persuades the phone company to move the victim's number to a new SIM card, and the codes follow. NIST treats the telephone network as a restricted channel: permitted, with the assessed and another method offered. Email is not accepted as a second channel.
Push notification
An app on the phone asks the user to approve or deny. In MFA fatigue, also called , an attacker who has the password sends request after request until the user approves one to make them stop. Number matching counters it: the sign-in screen shows a number that the user must type into the app.
Real-time phishing
A fake page asks for the password and the code and passes both to the real site at once. Any proof a user can read and type can be relayed like this.

These methods cost an attacker far more effort than a password alone. None is , because each fails to the same move: persuading the user to hand over the proof or approve the request.

Common misconception

“Multi-factor authentication stops phishing.”

It depends on the factor. A code or an approval can be collected by a fake page or given by a tired user. Only authenticators that tie their proof to the real site, such as passkeys and smart cards, resist phishing.

Passkeys: signing in with nothing to type

Passwordless sign-in removes the shared secret. Its standards come from the FIDO Alliance, short for Fast Identity Online. WebAuthn is the web standard through which a website asks a browser for this kind of sign-in. The Client to Authenticator Protocol (CTAP) carries the request from the browser to a separate security key or phone. WebAuthn and CTAP together are called FIDO2.

It rests on a key pair: two linked keys. The private key stays inside the user's device and signs messages. The public key can be given to anyone and can only check those signatures.

  1. Registration: the device creates a new key pair for this one website and sends the public key. The site stores it against the account.
  2. Sign-in: the site sends a random challenge.
  3. The user approves on the device with a fingerprint, a face or a PIN. The check happens on the device, and the fingerprint is never sent to the site.
  4. The device signs the challenge together with the address of the site that asked, and returns the signature.
  5. The site checks the signature with the stored public key.

A passkey is a credential of this kind. A device-bound passkey never leaves one device, such as a hardware security key. A synced passkey is copied between the user's devices through a cloud account, which is easier to live with and rests on that account's security.

A small black security key on a wooden desk, with gold USB contacts at one end, a round copper touch pad in the middle and a metal key ring through a hole at the other end.

A hardware security key holds a device-bound passkey: its private key never leaves the key, and the user touches it to approve each sign-in.

  1. 1USB connector. Plugs into the computer, so the browser's request can reach the key.
  2. 2Touch contact. The user touches it to approve the sign-in on the device.

Photograph: Yubikey with RFID in black by Dennis, CC0 1.0. Cropped and resized.

Phishing fails, because a signature made for a fake site's address is useless at the real one. A break-in at the website leaks only public keys. Every site has its own pair, so nothing is reused. The biometric is local and releases the key, which gives two factors in one action. A smart card that holds a private key and a certificate signs in the same way.

What a fake sign-in page can do with each authenticator
AuthenticatorUse to a fake page
PasswordCollected and reused at any time
One-time code from a token or appRelayed to the real site within its short life
Code by text messageRelayed in the same way. Also redirected by a SIM swap
Push approvalTriggered by the attacker's own sign-in and approved by the user
Passkey or smart cardNone. The proof is tied to the real site's address

Controlling access to the device that holds the key

A device here is equipment a person carries or works on: a phone, a laptop, a tablet or a security key. Once it holds authenticators, access to the device is access to every account behind them.

Device lock
A PIN, password or biometric is needed to use the device. It locks itself after a short idle time and slows or stops after repeated wrong attempts.
Storage encryption
The contents of a stolen device cannot be read without the lock secret.
Mobile device management (MDM)
Software through which the organisation sets these rules on every device, checks that they are still in force and keeps an .
Remote wipe
An administrator erases the organisation's data from a lost device over the network.
Device certificate
A installed on the device lets the network confirm that it is a known, managed device before admitting it. The user's own sign-in comes on top.

Physical care completes the set: the device stays with its user, or is locked away. A lost device is a lost authenticator. Reporting it at once lets the organisation withdraw the keys it held before anyone can use them.

A question, worked through

A law firm's partners sign in to the case system with a password and a six-digit code from an authenticator app. An email took two partners to a copy of the sign-in page. Each typed both, and each account was used by someone else within a minute. The managing partner wants a control that defeats the same attack, and will pay for new authenticators.

Which change BEST defeats this attack?

  1. Send the code by text message instead of using the app
  2. Issue security keys that hold a passkey for the case system
  3. Replace codes with push requests that partners approve by a tap
  4. Shorten the life of each code from 30 seconds to 15 seconds
Decide on your answer, then open the reasoning
  1. The attack passed what the partners typed to the real site within a minute. The question asks for a control that such a relay cannot get through.
  2. Rule out a: a code sent by text is still read and typed, so it can be relayed in the same way. Text messages also add the risk of a SIM swap.
  3. Rule out d: the relay took seconds. A shorter life narrows the window and leaves the method working.
  4. Between b and c: a push request cannot be typed into a fake page, which looks like progress. But the fake page can start a real sign-in, and a partner who is expecting a request will approve it.
  5. A passkey signs the address of the site that asked. A signature made for the copy is useless at the real site, whatever the partner believes. Option b is phishing-resistant, so it is the best answer.

Answer: B. Issue security keys that hold a passkey for the case system

Choosing between good answers

Phishing or a fake sign-in page is the stated threat
choose a passkey, security key or smart card. Codes, text messages and push approvals can all be relayed or approved by a user who is fooled.
A code stays valid until it is used
it is counter-based: HOTP. A code that expires after a short time is time-based: TOTP.
The server shows a number for the user to enter into the token
the token is asynchronous, using challenge-response. No clock or counter is involved.
Users approve sign-in requests they did not start
the attack is MFA fatigue. Choose number matching, or better, a phishing-resistant authenticator.
A device holding authenticators is lost
revoke its authenticators first and wipe it second. The accounts are worth more than the device.

Check your understanding

5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.

These questions are drafts that no named reviewer has approved yet.

Question 1 of 5

A key fob shows a new six-digit code every 30 seconds, whether or not it is used. Which kind of one-time password does it produce?

What to remember

  • A one-time password is computed from a shared secret and a changing input: a counter for HOTP, the time for TOTP.
  • Synchronous tokens stay in step with the server by counter or clock. Asynchronous tokens answer a challenge.
  • Anything a user can read and type, or approve with a tap, can be captured through a fake site. Codes, text messages and push approvals are not phishing-resistant.
  • A passkey keeps a private key on the device and gives each website only a public key. Its signature is tied to the real site's address, so phishing fails.
  • With a passkey the biometric stays on the device. It releases the key and is never sent to the website.
  • A device that holds authenticators needs a lock, encryption, management and remote wipe, and its loss must be reported at once.

Say it from memory

  1. How is access to a device such as a phone or laptop controlled?

    A device lock (PIN, password or biometric) engages after idle time and wrong attempts, and storage is encrypted. Mobile device management sets and checks those rules, and remote wipe erases a lost device. A device certificate lets the network recognise the device. A loss is reported at once so that the authenticators on the device can be revoked.

    Read this part again

  2. How does a hardware token differ from a software token, and a static token from a one-time password?

    A hardware token is a separate object, such as a key fob or a card. A software token is a program on a phone or computer doing the same job. A static token gives the same value every time, so anyone who sees it can reuse it. A one-time password is valid for one sign-in or a short moment and useless afterwards.

    Read this part again

  3. How do HOTP and TOTP differ, and how does an asynchronous token work?

    HOTP uses a counter that goes up by one with each code, and a code stays valid until used. TOTP uses the current time, in steps of 30 seconds by default, and the clocks must agree. Both are synchronous. An asynchronous token uses challenge-response: the server shows a random challenge and the token computes the answer from it and its secret key.

    Read this part again

  4. What are a SIM swap and MFA fatigue, and what counters MFA fatigue?

    In a SIM swap, an attacker persuades the phone company to move the victim's number to a new SIM card, and text message codes follow. In MFA fatigue, an attacker with the password sends push request after request until the user approves one. Number matching counters it: the user must type into the app a number shown on the sign-in screen.

    Read this part again

Sources