03 Security User Authentication
03 Security User Authentication
Tuomas Aura
CS-C3130 Information security
2
User authentication
▪ Verifying user identity
▪ Needed for access control and auditing
access control = authentication + authorization
▪ User authentication is based on credentials
– Password, key, smart card etc.
Something you know,
something you have, or
something you are
3
Username and password
▪ Password and PIN code are the most common types of
authentication credentials
▪ Password is a shared secret between the user and computer
system
– Limitations arise from the reliance on human memory and input
methods, and from the lack of cryptographic computing capability in
humans
▪ What attacks are there against passwords?
4
PASSWORD STORAGE ON SERVER
5
Storing passwords on server
▪ Assume that your password database is public!
– Unix /etc/passwd is traditionally world readable
– Attackers often read server files or database tables
e.g. with SQL injection
6
Storing passwords on server
User
– Store a one-way hash
value of the password
password
– When user enters a
password, compute its
hash hash and compare
• username – Use a slow hash function,
• salt
hash(password | salt) • H = hash(pw | salt) e.g. PBKDF2, Argon2
– Include salt: a user-
compare
specific random string.
User & password not secret
database
7
Storing passwords on server
User
alice – Store a one-way hash
V"a"ara234r4HA
value of the password
password alice,
– When user enters a
81b1043a557b00e2
21c9d190c6923678,
password, compute its
81b1043a557b00e2 8eca4e58f5b5b864
hash 21c9d190c6923678 cec314ad51c047b6hash and compare
8eca4e58f5b5b864 • username B7f9e7d4d67ecabc– Use a slow hash function,
f91eae5c0b2865a1
cec314ad51c047b6 • salt
B7f9e7d4d67ecabc
hash(password | salt)
f91eae5c0b2865a1 • H = hash(pw | salt) e.g. PBKDF2, Argon2
– Include salt: a user-
8eca4e58f5b5b864
compare
cec314ad51c047b6 specific random string.
B7f9e7d4d67ecabc
User & password
f91eae5c0b2865a1 not secret
database
8
Storing passwords on server
▪ How to store passwords in a public database?
Database record:
username, salt, slowhash( password | salt)
9
One-way function
▪ Cryptographic hash functions have the one-way property:
Easy to compute the hash h(M) for a given message M, but
difficult to compute M given h(M)
– Attacker can only guess M and compare the hashes
10
Slow hash function
▪ Standards hash functions are unnecessarily fast!
▪ Iterative hash:
– hash(pw|hash(pw|salt)) takes twice as long as hash(pw|salt)
– Iterate N times (N > 100 000) for desired delay
▪ Why? Not a significant cost when verifying user login, but
increases a brute-force attacker’s work by factor N
11
Salt in password hash
▪ Why salt?
username, salt, slow_hash( password | salt)
▪ Salt prevents
– Simultaneous brute-force cracking of many passwords
– Pre-computation attacks including rainbow tables
– Equality comparison between passwords
12
Extra
PBKDF2 Standard function for
slow hashing of
material
passwords
▪ PBKDF2 (P, S, c, dkLen)
Many iterations to make
P = password the computation slower
S = salt
c = iteration count Used in WPA2-Personal
dkLen = length of the result for deriving keys from
PRF = keyed pseudorandom function Wi-Fi passphrase
(makes offline cracking
i.e. keyed hash function more difficult)
https://tools.ietf.org/ht
F (P, S, c, i) = U1 xor U2 xor ... xor Uc ml/rfc2898
U1 = PRF (P, S || i)
U2 = PRF (P, U1)
...
Uc = PRF (P, Uc-1)
Repeat for i=1,2,3... until dkLen output bytes produced
13
Extra
Password hashing details material
14
PASSWORD GUESSING ATTACKS
15
Offline cracking
▪ Attacker obtains the password hashes or other data for
!
verifying password guesses, then starts guessing
▪ Brute-force attacks vs. intelligent dictionary attacks
– Most password crackers combine both strategies Easy to crack some
▪ Attacker has great advantages: passwords; hard to
crack them all. Why?
– Unlimited number of guesses
– Can rent elastic computing capacity for quick results
▪ To resist cracking, passwords must have cryptographic
strength (~128 bits of entropy)
16
Online trials – much harder
▪ Online trials: attacker tries to login many times
!
– Try PIN codes on a phone or cash machine
– Guess passwords for a web site
– Port scan ssh servers and guess root password
17
Cost of offline password cracking
▪ Time to crack a random 10-character (printable ASCII)
!
password from its SHA-256 hash?
– High-end multi-core CPU on a PC computes up to 500 MH/s
– High-end graphics card computes up to 7 GH/s, same cost
– Bitcoin miner computes 15 TH/s
▪ Always measure cracking cost in money, not in time, because
brute-force cracking parallelizes easily and computing capacity
can be rented on demand
– One CPU or GPU day ≈ $1 (cloud CPUs may be cheaper)
18
Cost of password cracking - continued
▪ How long does it take / how much does it cost to crack a random 10-character password
(printable 8-bit ASCII) from its SHA-256 hash?
▪ 9510 = 265.7 = 6.0∙1019 possible passwords. Thus, brute-force cracking takes at most this many
trials (50% on average)
▪ High-end CPU on a PC computes up to 0.5 GH/s (SHA-256)
– Thus, cracking the password takes 6.0∙1019 / 0.5∙109 = 1.2∙1011 CPU seconds = 1.3M CPU days
– One CPU day on PC ≈ $1; Thus, cost of cracking the password is about $1.3M
▪ High-end gaming graphics card computes up to 7 GH/s and costs about the same as PC
– Thus, cracking the password takes about 90000 GPU days and costs about $90000
▪ Bitcoin mining rig can compute 15 TH/s (but supports only a specific hash function)
– Thus, cracking the password takes 6.0∙1019 / 15∙1012 = 4.0M seconds = 46 days
– Rig rental online costs $1.50 per day = $69 per password
▪ Time can be shortened by parallelizing; cost remains the same!
▪ What is the effect of 1000 hash iterations? Changing password length to 8 or 20 characters?
http://hashcat.net/oclhashcat/
https://www.miningrigrentals.com/rigs/sha256 Cost data
updated 2020
19
Calculations with powers of 2 and 10
▪ Converting between bases 2 and 10: Mental arithmetic for
kilo k = 210 ≈ 103 every computer scientist!
mega M = 220 ≈ 106
giga G = 230 ≈ 109
tera T = 240 ≈ 1012 Upper and lower bound
▪ Conversion examples:
300M ≈ 300 ∙ 106 (< 256 ∙ 220 = 228, > 128 ∙ 220 = 227)
234 = 24 ∙ 230 = 16G ≈ 16 ∙ 109
▪ Approximate mental arithmetic example: Warning! Potentially big error
when approximating the base
– Number of passwords: 958 ≈ 100 8 = 1016 in exponentiation
21
Measuring password strength
▪ Many possible metrics:
– Number of possible passwords
– Entropy = amount of missing information
– Average/median cost to crack a specific password / any one password
– Success probability / number of cracked passwords as function of cost
22
Password entropy
▪ Entropy = the amount of missing information
Entropy H = - ∑ x ∈ passwords (P(x) ⋅ log2 P(x))
≤ log2(number of possible passwords)
23
Sufficient PIN and password entropy
▪ What is sufficient entropy to resist online guessing?
1. Determine the maximum number of guesses, e.g. K = 3
!
Assuming machine-
2. Decide acceptable success probability, e.g. P = 10-6 generated passwords
with even probability
3. Required entropy H = log2(K/P) = 21.5 bits distribution
https://xkcd.com/936/ 25
Note: Entropy is not a perfect metric for password strength, but
28
Human-chosen 4-digit PINs
Bonneau, Joseph:
Guessing Human-
Chosen Secrets, PhD
Thesis, University of
Cambridge, 2012.
29
Extra
NIST Password Guidelines material
31
Sniffing and key loggers
▪ Password sniffing on the local network is prevented by
cryptographic authentication (SSH, HTTPS, MS-CHAPv2,…)
▪ Key logger: software or hardware that stores all keystrokes
typed on the computer
– Problem in public-access computers
– Malware can sniff passwords on any infected computer
32
Shoulder surfing
▪ Keyboards and screens are highly visible
→ Others may see what you are typing
▪ Password and PIN inputs are usually masked *******
33
Spoofing and phishing attacks
▪ For console login, attacker tries to spoof the login dialog; how do you
know when it is safe to type in the password?
▪ For web login, attacker tries to spoof the login page for a web site
▪ For mobile apps, one app tries to spoof the login interface of another
(e.g. online bank)
34
│
Trusted path
▪ What if attacker spoofs the login dialog?
!
▪ Trusted path is any mechanism that ensures direct and secure
communication between user and a trusted part of the system
– Crtl+Alt+Del in Windows (secure attention key / sequence)
– Reset button in all kinds of devices
– Web browser address bar
38
Other threats
▪ No system is perfectly secure: system designers have a specific
threat model in mind, but the attacker can break these rules
39
BETTER USER AUTHENTICATION?
40
One-time passwords
▪ Use each password only once. Protects against password sniffers
and key loggers
– Random one-time passwords
– Lamport hash chain
– Unix S/KEY or OTP
1: HOLM BONG VARY TIP JUT ROSY
2: LAIR MEMO BERG DARN ROWE RIG
3: FLEA BOP HAUL CLAD DARK ITS
4: MITT HUM FADE CREW SLOG HAST
– Many commercial products such as RSA SecurID
– Code apps and devices for Finnish banks
▪ One-time passwords can be random strings, but most practical implementations use
pseudorandom values and cryptographic (one-way) hash functions
▪ Hash-based one-time passwords HOTP [RFC4226], OPTW
HOTP(K,i) = HMAC-SHA-1(K,i) mod 10D
– Produces one-time PIN codes of D decimal digits from master secret K and counter i
– Server and user’s authentication device only remember K and i
▪ Time-based one-time passwords: instead of counter, use the current time
– Many commercial products such as RSA SecurID
▪ Lamport hash chain:
H1 = hash(secret seed); Hi+1= hash(Hi)
– Convenient storage: server stores initially H100 and asks user to enter H99. Next, it stores H99 and
ask for H98, and so on
– Unix S/KEY [RFC1760] and OTP [RFC1938]
1: HOLM BONG VARY TIP JUT ROSY
2: LAIR MEMO BERG DARN ROWE RIG
3: FLEA BOP HAUL CLAD DARK ITS
4: MITT HUM FADE CREW SLOG HAST
– Usability problem: hashes are long random numbers
42
Weak and low-entropy credentials
▪ PIN, graphical passwords, face recognition, fingerprints have
recently replaced strong passwords. Why would that be ok?
▪ Only for physical access to device, not for remote access to the
device or to related online services
▪ For access to online services, physical possession of the user
device is considered one authentication factor, PIN the other
▪ Main threat now is lost and stolen mobile devices
– Attacker does not know the user
– Hardware feature to lock the device after a few trials
43
Online accounts
▪ User authentication delegated to online server
– Device cryptographically locked, and server releases keys after
successful authentication
– Online server can limit the number of password guesses and
implement risk-based additional authentication, e.g. 2FA
– Device must not store the password database and must be online
▪ But are the password hashes cached locally?
– e.g. Windows login with Microsoft account caches authentication
information locally, unless disables by domain administator
▪ Authentication delegated to a secure hardware module can
have similar benefits
44
Password manager
▪ Password manager for web service passwords
– Generates long, random, services-specific passwords
– Protects them all with a single master password
▪ e.g. LastPass, Dashlane, F-Secure Key
– Can also synchronize the database between the user’s devices
→ Solves the issues with human memory, weak passwords, and
password reuse
→ Creates a new single point of failure
45
PHYSICAL AUTHENTICATION TOKENS,
TWO-FACTOR AUTHENTICATION
46
Physical security tokens
▪ Smart card is a typical physical security token
– Stores cryptographic keys to prove its identity
– Tamperproof: secret keys will stay inside
▪ Used for door keys, computer
login, bank cards
▪ Other security tokens:
smart button, USB dongle,
trusted chip in mobile phone
47
Two-factor authentication (2FA)
▪ Two-factor authentication =
require both a physical token and a PIN or password
– Attacker needs to both steal the physical device and learn the PIN
→ clear qualitative increase in security
48
Issues with physical tokens
▪ Physical tokens require distribution
▪ Computers (or doors etc.) must have readers
▪ It is not easy to integrate cryptographic tokens to all systems
– Application with cached credentials on the client or on a proxy server
– Systems that need to start automatically after unexpected reboot
▪ Process needed for recovering from the loss of tokens
▪ Are the two factors really independent?
– smart card + PIN
– fingerprint swipe and bank code app on your phone
49
Authentication with mobile phone
▪ Two-channel authentication used by major online services:
– Confirmation via telephone: callback, SMS
– Confirmation via dedicated mobile app
– Sending a second secret to a known address: SMS, email, post
– Alerting user to potentially malicious events
50
SUMMARY
51
User authentication summary
Password cracking,
Social Shoulder Key logger, Spyware Rootkit
tampering
engineering surfing TEMPEST
Trusted
Password path
input
User and
OS kernel
credential
database
User
User, interface
credentials
Credential
provisioning,
out-of-band channel
52
Credential lifecycle
User Credential
Credential Account
account expiration or
provisioning removal
provisioning revocation
54
Reading material
▪ Dieter Gollmann: Computer Security, 2nd ed., chapter 3; 3rd
ed. chapter 4
▪ Matt Bishop: Introduction to computer security, chapter 11
▪ Ross Anderson: Security Engineering, 2nd ed., chapters 2, 15
▪ Stallings, Brown: Computer Security: Principles and Practice,
3rd/4th ed., chapter 3
▪ Bonneau, Joseph: Guessing Human-Chosen Secrets, PhD
Thesis, University of Cambridge, 2012.
55
Exercises
▪ Why do you need both the username and password? Would not just one secret identifier (password) be
sufficient for logging in?
▪ What effect do strict guidelines for password format (e.g. 8 characters, at least 2 capitals, at least 2 digits, at
least 1 special symbol) have on the password entropy?
▪ What is the probability of guessing the code for a phone that allows 3 attempts to guess a 4-digit PIN code, then
10 attempts to guess an 8-digit PUK code?
▪ In what respects is PBKDF2 better for password hashing than the old crypt(3)? How does Argon2 improve on
PBKDF2?
▪ How many hash values can a brute-force attacker test in a second with the latest GPUs? Check also the Bitcoin
mining speeds on GPUs.
▪ How do mandatory periodic password changes increase security? What is the optimal interval for password
expiry?
▪ How to limit the number of login attempts without creating a DoS vulnerability? Consider both an online service
and a device like phone.
▪ Learn about graphical passwords and compare their entropy to passwords and PIN codes of various lengths.
▪ Learn about HTTP Digest Authentication [RFC2617] and MS-Chap-V2 [RFC2759]. Explain how to perform an
offline password guessing attack after sniffing a login.
▪ Which attacks do one-time passwords / password managers / physical tokens / 2FA prevent, and which do they
not?
▪ Could authentication be based on who you know (or who knows you), or where you are?
56