Sub topic 5
Authenticator Apps and Time-Based Codes
Assume you know how to sign in to a centralized exchange and understand basic two-factor authentication. This chapter focuses on authenticator apps, which generate short-lived codes without using cellular service.
What an authenticator app does
An authenticator app stores a shared secret, which is a secret value known by both your exchange and your app. The app combines that secret with the current time to generate a time-based one-time password (TOTP).
A TOTP is usually a six-digit code that changes every 30 seconds. The exchange performs the same calculation when you submit the code. If both results match, the second factor is accepted.
| Factor | Main dependency | Important weakness |
|---|---|---|
| SMS code | Mobile network and phone number | SIM swapping and message interception |
| TOTP code | Shared secret and device clock | Phishing and secret theft |
| Passkey | Private key and matching website | Recovery and device availability |
TOTP is stronger than SMS because an attacker cannot receive the code merely by taking control of your phone number. However, a phishing site can ask for your current code and immediately forward it to the real exchange.
Enrollment and the `otpauth` URI
During setup, the exchange displays a QR code. The QR code contains an otpauth URI, which tells the app the account name, issuer, shared secret, algorithm, code length, and time period.
otpauth://totp/Example%20Exchange:alice%40example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Example%20Exchange&algorithm=SHA1&digits=6&period=30Scan the QR code only with the authenticator app you intend to use. Treat the QR code and displayed setup key like a password. Anyone who copies the shared secret can generate valid codes.
After scanning, enter the current code into the exchange to confirm enrollment. Save the exchange's recovery codes offline before leaving the setup page.
Clock drift and verification windows
Both sides need approximately the same time. Exchanges commonly accept the current 30-second interval plus one interval before and after it. This tolerates a small amount of clock drift, but a large difference usually causes failures.
Set your phone to automatic date and time. Do not repeatedly submit codes if one fails. First check the phone clock, the selected account, and whether the code has just changed.
The exchange should also prevent replay. Once it accepts a code for a time interval, it should reject the same code again for that sign-in attempt.
Exercise
Why is TOTP safer than SMS but still vulnerable to a real-time phishing site?
Show answer
TOTP does not depend on a phone number, so SIM swapping does not directly capture it. A phishing site can still collect the current code and relay it to the exchange before it expires.