Authentication
Authentication
Cybersecurity
Passwords and Authentication
Authentication
• Authentication is the process of verifying an actor’s identity
• Critical for security of systems
• Permissions, capabilities, and access control are all contingent upon
knowing the identity of the actor
• Typically parameterized as a username and a secret
• The secret attempts to limit unauthorized access
• Desirable properties of secrets include being unforgeable,
unguessable, and revocable
Types of Secrets
• Actors provide their secret to log-in to a system
• Three classes of secrets:
1. Something you know
• Example: a password
2. Something you have
• Examples: a smart card or smart phone
3. Something you are
• Examples: fingerprint, voice scan, iris scan
4
Password Storage
Hashing and Salting
Key Stretching and Work Factor
Honeywords
Attacker Goals and Threat Model
• Assume we have a system storing usernames and passwords
• The attacker has access to the password database/file
I wanna login to
those user accounts!
Database
Cracked Passwords
User Password User Password
cbw p4ssW0rd cbw p4ssW0rd
sandi puppies sandi puppies
amislove 3spr3ss0 amislove 3spr3ss0
Checking Passwords
• System must validate passwords provided by users
• Thus, passwords must be stored somewhere
• Basic storage: plain text
password.txt
cbw p4ssw0rd
sandi i heart doggies
amislove 93Gd9#jv*0x3N
bob security
Problem: Password File Theft
• Attackers often compromise systems
• They may be able to steal the password file
• Linux: /etc/shadow
• Windows: c:\windows\system32\config\sam
• If the passwords are plain text, what happens?
• The attacker can now log-in as any user, including root/administrator
• Passwords should never be stored in plain text
Hashed Passwords
• Key idea: store hashed versions of passwords
• Use one-way cryptographic hash functions
• Examples: MD5, SHA1, SHA256, SHA512, bcrypt, PBKDF2, scrypt
• Cryptographic hash function transform input data into
scrambled output data
• Deterministic: hash(A) = hash(A)
• High entropy:
• MD5(‘security’) = e91e6348157868de9dd8b25c81aebfb9
• MD5(‘security1’) = 8632c375e9eba096df51844a5a43ae93
• MD5(‘Security’) = 2fae32629d4ef4fc6341f1751b405e45
• Collision resistant
• Locating A’ such that hash(A) = hash(A’) takes a long time (hopefully)
• Example: 221 tries for md5
Hashed Password Example
MD5(‘p4ssw0rd’) =
2a9d119df47ff993b662a8ef36f9ea20
User: cbw
MD5(‘2a9d119df47ff993b662a8ef36f9ea20’)
= b35596ed3f0d5134739292faa04f7ca3
hashed_password.txt
cbw 2a9d119df47ff993b662a8ef36f9ea20
sandi 23eb06699da16a3ee5003e5f4636e79f
amislove 98bd0ebb3c3ec3fbe21269a8d840127c
bob e91e6348157868de9dd8b25c81aebfb9
Attacking Password Hashes
• Recall: cryptographic hashes are collision resistant
• Locating A’ such that hash(A) = hash(A’) takes a long time (hopefully)
• Are hashed password secure from cracking?
• No!
• Problem: users choose poor passwords
• Most common passwords: 123456, password
• Username: cbw, Password: cbw
• Weak passwords enable dictionary attacks
Most Common Passwords
Rank 2013 2014 2020
1 123456 123456 123456
2 password password 123456789
3 12345678 12345 picture1
4 qwerty 12345678 password
5 abc123 qwerty 12345678
6 123456789 123456789 111111
7 111111 1234 123123
8 1234567 baseball 12345
9 iloveyou dragon 1234567890
10 adobe123 football senha
Dictionary Attacks
hash(
)
English List of hashed_
Dictionary possible password.txt
password
hashes
hash()
Common
Passwords
cbw 2a9d119df47ff993b662a8ef36f9ea20
sakib 23eb06699da16a3ee5003e5f4636e79f
amislove 98bd0ebb3c3ec3fbe21269a8d840127c User: cbw
bob e91e6348157868de9dd8b25c81aebfb9
hashed_and_salted_password.txt
MD5(‘a8’ + ‘p4ssw0rd’) =
cbw a8 af19c842f0c781ad726de7aba439b033 af19c842f0c781ad726de7aba439b033
sakib 0X 67710c2c2797441efb8501f063d42fb6
amislove hz 9d03e1f28d39ab373c59c7bb338d0095
bob K@ 479a6d9e59707af4bb2c618fed89c245
Attacking Salted Passwords
No matches
List of hashed_
hash() possible and_salted_
password password.txt
hashes
cbw a8
List of
sakib 0X List of
possible
hash(‘a8’ + word) possible
password cbw XXXX
hash(‘0X’ + word) sakib YYYY
password
hashes w/
hashes
salt a8 w/
salt 0X
Breaking Hashed Passwords
• Stored passwords should always be salted
• Forces the attacker to brute-force each password individually
• Problem: it is now possible to compute hashes very quickly
• GPU computing: hundreds of small CPU cores
• nVidia GeForce GTX Titan Z: 5,760 cores
• GPUs can be rented from the cloud very cheaply
• $0.9 per hour (2018 prices)
Examples of Hashing Speed
• A modern x86 server can hash all possible 6 character long
passwords in 3.5 hours
• Upper and lowercase letters, numbers, symbols
• (26+26+10+32)6 = 690 billion combinations
• A modern GPU can do the same thing in 16 minutes
• Most users use (slightly permuted) dictionary words, no symbols
• Predictability makes cracking much faster
• Lowercase + numbers (26+10)6 = 2B combinations
Hardening Salted Passwords
• Problem: typical hashing algorithms are too fast
• Enables GPUs to brute-force passwords
• Old solution: hash the password multiple times
• Known as key stretching
• Example: crypt used 25 rounds of DES
• New solution: use hash functions that are designed to be slow
• Examples: bcrypt, PBKDF2, scrypt
• These algorithms include a work factor that increases the time
complexity of the calculation
• scrypt also requires a large amount of memory to compute, further
complicating brute-force attacks
bcrypt Example
• Python example; install the bcrypt package
20
Password Storage Summary
1. Never store passwords in plain text
2. Always salt and hash passwords before storing them
3. Use hash functions with a high work factor
Password Theory
Hash Chains
Rainbow Tables
Attacker Goals and Threat Model
• Assume we have a system storing usernames and passwords
• The attacker has access to the password database/file
I wanna login to
those user accounts!
Database
Cracked Passwords
User H(PW) User Password
cbw iuafNas cbw p4ssW0rd
sandi 23asZR sandi puppies
amislove 9xgGw/ amislove 3spr3ss0
Basic Password Cracking
• Problem: humans are terrible at generating/remembering random
strings
• Passwords are often weak enough to be brute-forced
• Naïve way: systematically try all possible passwords
• Slightly smarter way: take into account non-uniform distribution of characters
• Dictionary attacks are also highly effective
• Select a baseline wordlist/dictionary full of likely passwords
• Today, the best wordlists come from lists of breached passwords
• Rule-guided word mangling to look for slight variations
• E.g. password Password p4ssword passw0rd p4ssw0rd password1 etc.
• Many password cracking tools exist (e.g. John the Ripper, hashcat)
“Deep Crack”: The EFF DES Cracker
• DES uses a 56-bit key
• $250K in 1998, capable of brute-
forcing DES keys in 56 hours
• Uses 1856 custom ASIC chips
• Similar attacks have been
demonstrated against MD5, SHA1
• Modern equivalent?
• Bitcoin mining ASICs
Speeding Up Brute-Force Cracking
• Brute force attacks are slow because hashing is CPU intensive
• Especially if a strong function (SHA512, bcrypt) is used
• Idea: why not pre-compute and store all hashes?
• You would only need to pay the CPU cost once…
• … for a given salt
• Given a hash function H, a target hash h, and password space P, goal
is to recover such that
• Problem: naïve approach requires Θ(|P|n) bits, where n is the space
of the output of H
Hash Chains
• Hash chains enable time-space efficient reversal of hash functions
• Key idea: pre-compute chains of passwords of length k…
• … but only store the start and end of each chain
• Larger k fewer chains to store, more CPU cost to rebuild chains
• Small k more chains to store, less CPU cost to rebuild chains
• Building chains require H, as well as a reduction R : H ↦ P
• Begin by selecting some initial set of password
• For each ’, apply for k iterations
• Only store and
• To recover hash h, apply R and H until the end of a chain is found
• Rebuild the chain using and
• H(p) = h may be within the chain
Uncompressed Hash Chain Example
Only these two columns
get stored on disk
125 26 Characters
100
75
50
Very
25 Weak
0
0 5 10 15 20 25 30 35
1. Pick a word
2. Capitalize the first or last letter
3. Add a number (and maybe a symbol) to the beginning or end
4. Pick a word
5. Replace some of the letters with symbols (a @, s $, etc.)
6. Maybe capitalize the first or last letter
Human Generated Passwords
Password Entropy (bits) Strength Crackability Problem
Computer3@ 60 Weak Easy Dictionary word, obvious transformations
cl4ssr00m 47 Weak Easy Dictionary word, obvious transformations
7Dogsled* 54 Weak Easy Dictionary word, obvious transformations
Tjw1989&6 54 Weak Easy Users initials and birth year, obvious transformations
B4nk0f4m3r1c4! 83 Medium Easy Includes service name, obvious transformations
• Use mnemonics
• Choose a sentence or phrase
• Reduce it to the first letter of each word
• Insert random uppercase, digits, and symbols
SMS
Authentication Codes
55
Biometrics
• ancient Greek: bios ="life", metron ="measure“
• Physical features
• Fingerprints
• Face recognition
• Retinal and iris scans
• Hand geometry
• Behavioral characteristics
• Handwriting recognition
• Voice recognition
• Typing cadence
• Gait
Fingerprints
• Ubiquitous on modern smartphones, some laptops
• Secure?
• May be subpoenaed by law enforcement
• Relatively easy to compromise
1. Pick up a latent fingerprint (e.g. off a glass) using tape or
glue
2. Photograph and enhance the fingerprint
3. Etch the print into gelatin backed by a conductor
4. Profit ;)
https://www.theregister.co.uk/2002/05/16/gummi_bears_defeat_fingerprint_sensors/
Facial Recognition
• Popularized by FaceID on the iPhone X
• Secure?
• It depends
• Vulnerable to law enforcement requests
• Using 2D images?
• Not secure
• Trivial to break with a photo of the target’s face
• Using 2D images + 3D depth maps?
• More secure, but not perfect
• Can be broken by crafting a lifelike mask of the target
Voice Recognition
• Secure?
• Very much depends on the implementation
• Some systems ask you to record a static phrase
• E.g. say “unlock” to unlock
• This is wildly insecure
• Attacker can record and replay your voice
• Others ask you to train a model of your voice
• Train the system by speaking several sentences
• To authenticate, speak several randomly chosen words
• Not vulnerable to trivial replay attacks, but still vulnerable
• Given enough samples of your voice, an attacker can train a synthetic voice AI that
sounds just like you
Fundamental Issue With Biometrics
• Biometrics are immutable
• You are the password, and you can’t change
• Unless you plan on undergoing plastic surgery?
• Once compromised, there is no reset
• Passwords and tokens can be changed
• Example: the Office of Personnel Management (OPM) breach
• US gov agency responsible for background checks
• Had fingerprint records of all people with security clearance
• Breached by China in 2015, all records stolen :(
Token-based Two Factor
Authentication
Types of Secrets
• Actors provide their secret to log-in to a system
• Three classes of secrets:
1. Something you know
• Example: a password
2. Something you have
• Examples: a smart card or smart phone
3. Something you are
• Examples: fingerprint, voice scan, iris scan
63
Something You Have
• Two-factor authentication has become more commonplace
• Possible second factors:
• SMS passcodes
• Time-based one time passwords
• Hardware tokens
SMS Two Factor
• Relies on your phone number as the second factor
• Key assumption: only your phone should receive SMS
sent to your number
• SMS two factor is deprecated. Why?
• Social engineering the phone company
1. Call and pretend to be the victim
2. Say “I got a new SIM, please activate it”
3. If successful, phone calls and SMS are now sent to your
SIM in your phone, instead of the victim
• Not hypothetical: successfully used against many
victims
One Time Passwords
Changes
• Generate ephemeral passcodes that every few
change over time minutes
• To login, supply normal password and
the current one time password
• Relies on a shared secret between
your mobile device and the service
provider Duo Mobile
• Shared secret allows both parties to
know the current one time password Lastpass Authenticator
Google Authenticator
Time-based One-time Password Algorithm
T0 = <the beginning of time, typically Thursday, 1 January 1970 UTC>
TI = <length of time the password should be valid>
K = <shared secret key>
d = <the desired number of digits in the password>
TC = floor((unixtime(now) − unixtime(T0)) / TI),
TOTP = HMAC(K, TC) % 10d
username:x:UID:GID:full_name:home_directory:shell
cbw:x:1001:1000:Christo Wilson:/home/cbw/:/bin/bash
amislove:1002:2000:Alan Mislove:/home/amislove/:/bin/sh
$<algo>$<salt>$<hash>
Algo: 1 = MD5, 5 = SHA256, 6 = SHA512
/etc/shadow
username:password:last:may:must:warn:expire:disable:reserved
cbw:$1$0nSd5ewF$0df/3G7iSV49nsbAa/5gSg:9479:0:10000::::
amislove:$1$l3RxU5F1$:8172:0:10000::::
77
Distributed Authentication
Distributed Authentication
• Early on, people recognized the need for authentication in distributed
environments
• Example: university lab with many workstations
• Example: file server that accepts remote connections
• Synchronizing and managing password files on each machine is not
scalable
• Ideally, you want a centralized repository that stores policy and credentials
The Yellow Pages
• Network Information Service (NIS), a.k.a. the Yellow Pages
• Developed by Sun to distribute network configurations
• Central directory for users, hostnames, email aliases, etc.
• Exposed through yp* family of command line tools
• For instance, depending on /etc/nsswitch.conf, hostname lookups can
be resolved by using
• /etc/hosts
• DNS
• NIS
• Superseded by NIS+, LDAP
• Crypt based password hashes
NIS Password Hashes • Can easily be cracked
• Many networks still rely on insecure NIS
messages
• In some cases, may be able to
steal information from users
Auth Server
• Idea: client forwards
user/password to service,
service queries Auth Server cbw
• Problems:
• Passwords being sent in the clear Database
• Attacker can observe them!
• Clearly we need encryption
cbw:p4ssw0rd
• Database learns about passwords
• Additional point of compromise
• Ideally, only the user and the Auth Please verify
Server should know their password cbw:p4ssw0rd cbw:p4ssw0rd
Needham-Schroeder Protocol
• Let Alice A and Bob B be two parties that trust server S
• KAS and KBS are shared secrets between [A, S] and [B, S]
• KAB is a negotiated session key between [A, B]
• Ni and Nj are random nonces generated by A and B
KAS is not sent in the clear, authenticates S and A
Auth Server
cbw
db
cbw
cbw
Database
cbw-db
db
{}K, db,
cbw,
{Kcbw-db cbw}K
cbw-db
db cbw-db
{}K
cbw-db
Attacking Needham-Schroeder
{, Kcbw-db, db, {Kcbw-db, cbw}Kdb}Kcbw
• Spoof the client request
• Fail! Client key is needed to decrypt
cbw Auth Server
• Spoof the Auth Server response
• Fail! Need to know the client key cbw cbw
evil cbw-db
tgt
{Kcbw-db}Kcbw-tgs , {Kcbw-db}Kdb
Ticket Granting
Server
cbw
tgt
TGT
cbw
db
cbw-tgs
{TGT, db,
cbw }K {cbw,
, {cbw,T}T}Kcbw-tgs
cbw-db Database
Kcbw-db Kcbw-db
db
db {T - 1}K
cbw-db
cbw-db
Attacking Kerberos
• Don’t put all your eggs in one basket
• The Kerberos Key Distribution Server (KDS) is a central point of failure
• DoS the KDS and the network ceases to function
• Compromise the KDS leads to network-wide compromise
• Time synchronization
• Inaccurate clocks lead to protocol failures (due to timestamps)
• Solution?
• Use NTP ;)
Sources
1. Many slides courtesy of Wil Robertson: https://wkr.io
2. Honeywords, Ari Juels and Ron Rivest: http://www.arijuels.com/wp-content/uploads/2013/09/JR13.pdf
• For more on generating secure passwords, and understanding people’s mental models of passwords, see the excellent
work of Blas Ur: http://www.blaseur.com/pubs.htm