authentication - university of southern californiacsci530l/slides/lab-authentication-color.pdf ·...

31
1 Authentication Authentication September 11, 2020 Administrative Administrative – new VM new VM for this lab exercise for this lab exercise import, then don't forget to create a snapshot named "base"

Upload: others

Post on 07-Aug-2020

24 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

1

AuthenticationAuthentication

September 11, 2020

Administrative Administrative –– new VMnew VMfor this lab exercisefor this lab exercise

import, then don't forget

to create a snapshot named

"base"

Page 2: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

2

Administrative Administrative –– VM login credentialsVM login credentials

fedora30-fall20

student/c$l@bLinuX

root /c$l@bLinuX

( mnemonic: compter science lab linux )

kali-linux1.0.7

root/c$l@bLinuX

Administrative Administrative –– submittal instructionssubmittal instructions

� answer the lab assignment’s questions in written report form, as a text, pdf, or Word document file (no obscure formats please)

� email to [email protected]

� exact subject title must be “authenticationlab”

� deadline is start of your lab session the following week

� reports not accepted (zero for lab) if– late

– you did not attend the lab (except DEN or prior arrangement)

– email subject title deviates

Page 3: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

3

Authentication definitionAuthentication definition

� binding an identity to a subject– withdrawing money at a bank counter

verifying a bank customer (subject) is the person/name (identity) on a savings account

(e.g., by driver's license evaluation)

– logging inverifying a keyboard user (subject) is the person/name (identity) on a user account

(e.g., by password evaluation)

– using a secure websiteverifying the web server (subject) is that of an organization (identity)

(e.g., by digital signature evaluation)

““AuthAuth””enticationentication vsvs ““authauth””orizationorization

� authentication != authorization

– authorization establishes what user can do

once authenticated

� authentication happens first

� authorization comes later

– employing the information established during

authentication

Page 4: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

4

Usage of a login IDUsage of a login ID

� user account’s ID number (UID) gets “embedded” in its human user(if any)’sshell/gui process and other processes they then spawn (which is their job)

� user accounts in/of processes are revealed by ps (process status) command in linux

the users in/of 3 processes

Bigger picture Bigger picture -- how we think of ithow we think of it

user filereads

Page 5: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

5

#include <unistd.h>

#include <sys/stat.h>

#include <fcntl.h>

int main()

{

char c;

int in, out;

in = open("file.in", O_RDONLY);

out = open("file.out", O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);

while(read(in,&c,1) == 1)

write(out,&c,1);

exit(0);

}

Bigger picture Bigger picture -- how it actually workshow it actually works

user filereads

processruns

note system calls “open” “read” “write”

They do the file access

user? isn’t even mentioned in the calls

UID

users don’t read files, processes do

program that copies one file to another

#include <unistd.h>

#include <sys/stat.h>

#include <fcntl.h>

int main()

{

char c;

int in, out;

in = open("file.in", O_RDONLY);

out = open("file.out", O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);

while(read(in,&c,1) == 1)

write(out,&c,1);

exit(0);

}

user filereads

processruns

note system calls “open” “read” “write”

They do the file access

user? isn’t even mentioned in the calls

UID

AUTHENTICATION HERE

up front, determines account

for first (shell) processsame account, carried forward by inheritance

from shell process to this spawned one

Bigger picture Bigger picture -- how it actually workshow it actually works

Page 6: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

6

Bases for authenticationBases for authentication

� something people know

� password

� pin number

� something about them

� retina/iris

� fingerprint

� DNA

� voice

� ear

� face

� something they have

� smart card

� sim (subscriber identity module) card

� hardware token

� somewhere they are

� login only works at certain terminals

Extent of authenticationExtent of authentication

� one or a combination of methods may be used– depending on needed degree of protection

– “single-factor” “multi-factor”

� examples– system login

� for user account, the matching password (single-factor)

– system with fingerprint reader (e.g. modern laptop)

� for user account, the matching password and finger (2-factor)

– ATM transaction

� for bank account, the card and matching pin (2-factor)

Page 7: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

7

TFA at TFA at myviterbi.usc.edumyviterbi.usc.edu

Step 1,

1st factor

Step 2,

2nd factor

Example: passwordsExample: passwords

� something people know

� most common, familiar basis for authentication

Page 8: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

8

WhatWhat’’s makes bad ones?s makes bad ones?

� only letters or only numbers (hackme, 09112002)

� recognizable words (john1, R2D2)

� foreign language words (bonjour1, hastalavistababy)

� hacker terminology (H4XOR, 1337)

� personal info (names, birthdates, addresses)

� reverse words (nauj, esrever)

� what do these all have in common?they are predictable

WhatWhat’’s makes good ones?s makes good ones?

� at least 8 characters (conventionally, but why 8?? still “enough” today? no)

� mixed case

� mixed letters and numerals

� punctuation/non-alphanumeric symbols included

� something you can remember

Page 9: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

9

Making a good oneMaking a good one

� think of a memorable phrase– “wasn’t that a dainty dish to set before the king”

– “in the beginning god created the heavens and the earth”

� make it an acronym– wtaddtsbtk

– itbgcthate

� substitute non-letters for letters ("leetspeak")

– w7@dd7$b7k

– i7bgcth@te

� capitalize something– w7@DD7$b7k

– i7BGCTH@te

Forcing strong passwordsForcing strong passwords

� create them for users, don’t let users choose them

� use PAM’s pam_cracklib module

– enforces a password strength policy at creation time

� or other PAM password evaluation modules

– pam_passwdqc (http://www.openwall.com/passwdqc)

Page 10: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

10

PAM architecture PAM architecture ((““pluggable authentication modulespluggable authentication modules””))

PAM1

2/etc/pam.d

per-application

configuration files(text)

PAM modules(executable)

PAM-aware

applications(e.g., /bin/login

/bin/su

/bin/ssh/bin/passwd, etc )

3

4

Operation sequenceOperation sequence

� app calls PAM (1)

� PAM reads app’s PAM config file (2)

� PAM calls PAM modules as listed in the file (3)

– each succeeds or fails independently

� PAM itself succeeds or fails, depending on the modules’ outcomes

– returns its overall outcome to app (4)

� app proceeds (if success) or terminates (if failure)

Page 11: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

11

Password crackersPassword crackers

� John the Ripper (http://www.openwall.com/)

� Cain and Abel

� hashcat (http://hashcat.net/hashcat/)

Is guesswork easy or hard?Is guesswork easy or hard?

� an alphabet is a set of symbols

� how many words of a certain length can you compose from an alphabet?

� depends on

– the number of symbols in the alphabet

– the particular wordlength

Page 12: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

12

Two password strength determinantsTwo password strength determinants

� the number of possible characters it contains

– its character set

� its length

– its character count

Is guesswork easy or hard?Is guesswork easy or hard?

� a 2-symbol alphabet has

– 2 one-letter words

– 4 two-letter words

– 8 three-letter words

� a 3-symbol alphabet has

– 3 one-letter words

– 9 two-letter words

– 27 three-letter words

� a 10-symbol alphabet has– 10 one-letter words

– 100 two-letter words

– 1000 three-letter words

� an α-symbol alphabet has– α one-letter words

– α2 two-letter words

– α3 three-letter words

– αp p-letter words(alphabet length raised to password length)

Page 13: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

13

How many words are there?How many words are there?

� 26-letter alphabet, wordlength 3: 263 = 17576

� 52-letter alphabet, wordlength 3: 523 = 140,608– double alphabet length yields 8 times as many words

� 26-letter alphabet, wordlength 6: 266 = 308,915,776– double word length yields 17576 times as many words

� 52-letter alphabet, wordlength 6: 526 = 19,770,609,660

� a fish is in a pond – harder to catch in a bigger pond

https://www.grc.com/passwords.htm

16-character alphabet

94-character alphabet

62-character alphabet

1664 = 1077

9463 = 10124

6263 = 10112

Password space:

How many words are there? *How many words are there? *

* * i.e.i.e. ““WhatWhat’’s the password space?s the password space?””

comparatively IPv6

address space, considered

“really really big” - 1038

Page 14: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

14

Password strength determinantsPassword strength determinants

� the number of possible characters it contains

� its length

� the randomness of character selection

a 3rd criterion!! human-dependent!(arguably, the most important factor these days)

2013 dynamic attack, 2013 dynamic attack, my UCLA server my UCLA server **

� about 700000 login attempts

� from about 2100 remote IPs

� from several to 53000 login attempts each

� using about 26000 user name guesses

� with unknown password guesses– but no doubt predicable ones

log file, victim machine

*but real-world attacks are not “dynamic”

they are in-situ at attacker’s place upon

an exfiltrated user/password file

Page 15: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

15

How you can help the cracker:How you can help the cracker:

---- shrink the pond!shrink the pond!� the cracker’s task:

– finding the password = = eliminating all the other candidates

� how you can do part of the cracker’s task for him– eliminate candidates, reduce the candidate-space

� how you can eliminate candidates:– use only letters, or only numbers (eliminates using both)

– use recognizable words, foreign words (eliminates non-words)

– use personal info …

– use hacker terminology …

– use reverse words …

� better yet: just text the cracker your password

Stated differentlyStated differently

� cracking is process of eliminating the non-passwords

� by confining passwords to known (predictable) patterns users pre-eliminate huge parts of the password space

“For instance, the cracking programs rely on the fact that a typical user will probably

not start a password with a special character in the first position but will nearly

always put it somewhere near the end of the space-- therefore you can shave

enormous amounts of cracking time with a cracking program that is written to

contemplate this - so that it will not start a brute force guessing attack on a password

that assumes a special character is in the first position....

“In essence, these cracking programs go through a protocol of routines or hacking

steps from greatest reward/least effort to finally greatest effort/least reward (i.e.

purely random) hoping to get lucky and snag an answer before they have to go

through the entire keyspace.”

BFTCalc.xls from http://www.mandylionlabs.com/PRCCalc/BruteForceCalc.htm

Page 16: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

16

Human factor discoveryHuman factor discovery

From passwords captured in large volume in recent publicized

leaks, more commonly than expected, people chose 9-character

passwords whose first 5 characters are letters, last 4 are numbers,

first character is sometimes capitalized, others are not.

101010102626262652

numnumnumnumlowerlowerlowerloweralpha

969696969696969696

anyanyanyanyanyanyanyanyany

Random:

Observed:

wordspace 96^9 = 7 * 10^17

wordspace 52*26*26*26*26*10*10*10*10 = 2 * 10^11

1 million times bigger

1 million times smaller

Password cracking methodsPassword cracking methods

� dictionary attack

� brute force attack

� hybrid attacks(e.g., hashcat’s “Combination,” “Toggle-Case,” “Permutation” attack modes)

� normally applied against a (captured) file containing the password hashes, offline

Page 17: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

17

Where Where unixunix stores passwordsstores passwords

� historical

– /etc/passwd –list of users & their hashed passwords

� was readable by any user (rw-r--r--)

� current (since ~1990)

– /etc/passwd –list of users only (no passwords)

� is readable by any user (rw-r--r--)

– /etc/shadow –their hashed passwords

� is readable by root user only (rw-------)

/etc//etc/passwdpasswd entries holdentries hold

user informationuser information

craig:x:507:507:Craig Smith:/home/craig:/bin/bash

official

name

password

(placeholder,

was historical

storage location)

UID GID real

name

home

directory

login

shell

Page 18: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

18

/etc/shadow entries hold/etc/shadow entries hold

ancillary user informationancillary user information

craig:$1$2YL52jhL$:11992:60:75:3:14:12417:134550548

user

name

stored password(based on a hash algorithm)

other, unrelated items

reserved

Newer distributions,Newer distributions,

longer default stored password lengthslonger default stored password lengths

MD5

SHA512

Page 19: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

19

Password Password ““scramblingscrambling””

is not precisely is not precisely ““hashinghashing””

what gets stored

actual hash of salted password

Hash algorithm Hash algorithm selectabilityselectability (fedora)(fedora)

red – algorithm code

green – salt

purple – hash of (salt+ password)

Page 20: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

20

Dictionary attackDictionary attack

� generated/dynamic dictionary attack

– list of dictionary words that are tried (i.e., hashed and

compared to hash of actual password)

– very quick

� file-based/static dictionary attack– pre-compute hashes of all the words in the dictionary

– re-sort it, on the hashes instead of the words

– password crack becomes a computationless hash lookup

� if the password is not an exact match to a word on the list, crack will fail

Hybrid attackHybrid attack

� uses a dictionary list but can detect slight variations to words, or combinations of words.

� example: if the word hello is in the database, but the password is Hello, a dictionary attack will not break the password, but a hybrid attack will

� generally finds many more words than a dictionary attack

� not as quick as dictionary attack

Page 21: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

21

BruteforceBruteforce attackattack

� tries every character combination until it finds the password

� time-consuming in proportion to password space

� will always find the password, given time

� cf. “The Library of Babel” by Jose Luis Borges

BruteforceBruteforce attack time estimatorattack time estimator

http://www.mandylionlabs.com/PRCCalc/BruteForceCalc.htm

Page 22: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

22

NextNext--gen cracking platformgen cracking platform

“This $12,000 computer, dubbed Project

Erebus v2.5 by creator d3ad0ne, contains

eight AMD Radeon HD7970 GPU cards.

Running version 0.10 of oclHashcat-lite, it

requires just 12 hours to brute force the

entire keyspace for any eight-character

password containing upper- or lower-case

letters, digits or symbols. “

http://arstechnica.com/security/2012/08/passwords-under-assault/

Raw speed estimated advancesRaw speed estimated advances

� 2004 PC: 2^34/hr (per Mandylion spreadsheet, from 2004)

� 2012 PC, single HD7970 GPU: 8.2 billion/sec

� Factor of 1718

� 2012 dedicated cracker, 8 GPUs: 8x? 64 billion/sec?

� 2020??

Page 23: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

23

Last week Last week –– why did it work?why did it work?

We solved “Encrypting the whole message is too slow!”

by hashing the whole message instead.

It works because: hashing is fast (with most algorithms)

that’s good for signatures

also good for for password cracking

Deliberate obstacles to crackingDeliberate obstacles to cracking

� add extra code to hash algorithm code to slow it

– diminish brute force attempts possible per unit time

– bcrypt is a deliberately slow, and tunable, algorithm

� password salting

– render static dictionary attack infeasible

Page 24: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

24

unsalted password: generatingunsalted password: generating

typed password

hash-based algorithm

“hash”

Generate time

Storage:

“hash”

* “hash” is quoted because the algorithm that produced it

is based on a hash algorithm but isn’t that hash algorithm itself.

The output therefore is not the hash itself.

*

hash-based algorithm

“hash”

Generate time Authenticate time

Storage:

“hash”hash-based algorithm

“hash”

comparison

match or mismatch

unsalted password: authenticating unsalted password: authenticating

typed password typed password

Page 25: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

25

Generate time Storage:

“hash”salthash-based algorithm

“hash”

salted password: generating salted password: generating

salt typed password

Generate time Authenticate timeStorage:

hash-based algorithm

“hash”

comparison

match or mismatch

“hash”salthash-based algorithm

“hash”

salted password: authenticating salted password: authenticating

salt typed password salt typed password

Page 26: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

26

Benefit of saltBenefit of salt

� a given password is no longer deterministically mapped to a particular hash

– greatly raises cost of file-based/static dictionary attack

– identical passwords not detectable by their hashes

Hardware authentication tokensHardware authentication tokens

RSA SecureID

Yubico YubiKey

Page 27: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

27

Pressing Pressing yubikeyyubikey, in Notepad, in Notepad

yubikey is a USB keyboard device – it types 44 letters whenever pressed

right 32 letters one-time password, generated this time

left 12 letters invariant public ID of this yubikey, generated every time

from command history recall buffer 2 seconds later

(one-time key, used 2nd time, is stale)

Good play, bad replayGood play, bad replay

from pressing keyboard from pressing yubikeyykclient utility queries

validation server with key

Page 28: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

28

play:play:

replay:replay:

red – client to server

blue – server to client

PAM for PAM for sshdsshd::involving involving yubikeyyubikey in in sshssh loginslogins

PAM1

2/etc/pam.d

configuration file

for sshd programPAM module

for yubikey

a PAM-aware

application

3

4

sshd

pam_yubico.so

sshd

specifies pam_yubico.so

Page 29: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

29

Configuration detailsConfiguration details

corresponds this machine’s “david” account to the particular white yubikey I bought recently,

so a valid key from that yubikey device is “good for admission” to this account

clie

nt

clie

nt

yubikey pressed heres

e r

v e

r

i n c r e a s i n g t i m e

1 yubikey types one-time key to client PuTTY

2 client PuTTY sends key to server sshd

3 sshd passes key to pam_yubico.so

4 pam_yubico.so ships it to api.yubico.com for validation

5 api.yubico.com returns “OK” to pam_yubico.so

6 pam_yubico.so returns “OK” to sshd

7 sshd launches shell

per yubico authentication server

ssh

ssh

log

in b

y

log

in b

y y

ub

ike

yyu

bik

ey

Page 30: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

30

encrypt

Construction of outputConstruction of output

cccccccvrjbctjjneccdnuerugkclcvenbilblgkdiie

cccccccvrjbc

s t a t i c a l l y s t o r e d

d y n a m i c a l l y

g e n e r a t e d

tjjneccdnuerugkclcvenbilblgkdiiecccccccvrjbc

cccccccvrjbc = unique public ID

00000000B3D6 = unique secret ID

= unique symmetric key (for AES)

c o n c a t e n a t e output

17900000000B3D6cccccccvrjbc

etclast sequence

number

symmetric keysecret IDpublic ID“serial no.”

Authentication processingAuthentication processing

application client

application

server

authentication

server

d a t a b a s eapp re

quest

app re

sponse

validation request

validation response

Page 31: Authentication - University of Southern Californiacsci530l/slides/lab-authentication-color.pdf · authentication != authorization – authorization establishes what user can do once

31

This weekThis week’’s lab exercises lab exercise

use hashcat to crack passwords in a supplied file holding 50 scrambled passwords extracted from /etc/shadow