CS 161: Computer Security http://inst.eecs.berkeley.edu/~cs161/ - - PowerPoint PPT Presentation

cs 161 computer security
SMART_READER_LITE
LIVE PREVIEW

CS 161: Computer Security http://inst.eecs.berkeley.edu/~cs161/ - - PowerPoint PPT Presentation

CS 161: Computer Security http://inst.eecs.berkeley.edu/~cs161/ January 16, 2017 ROOM FIRE CODE Prof. Raluca Ada Popa And a team of a talented TAs Head TAs: Keyhan and Won and talented readers Jianan Lu Kijung Kim Katharine Jiang Kate


slide-1
SLIDE 1

CS 161: Computer Security

http://inst.eecs.berkeley.edu/~cs161/

January 16, 2017

  • Prof. Raluca Ada Popa

ROOM FIRE CODE

slide-2
SLIDE 2

And a team of a talented TAs

Head TAs: Keyhan and Won

slide-3
SLIDE 3

and talented readers

Jianan Lu Kijung Kim Katharine Jiang Kate Xu Denis Li Audrey Ku Kevin Ma David Niu Billy Zhao Anusha Syed Riku Miyao

slide-4
SLIDE 4

What is Computer Security?

Detects or prevents unwanted use of computer systems or data

slide-5
SLIDE 5

Why security?

slide-6
SLIDE 6
slide-7
SLIDE 7

Why should you care?

  • to-day life

Millions of compromised computers, millions of stolen passwords, stolen money

slide-8
SLIDE 8

It is important for our

physical safety and safety of our possessions confidentiality of data/ privacy functionality

slide-9
SLIDE 9

Safety

Adversaries can affect our safety by tampering with pacemakers, planes, cars

slide-10
SLIDE 10

Privacy/confidentiality

Adversaries get access to medical, financial, personal user data, or sensitive corporate data Pretty much any major company collecting user data has been hacked 140 million records breached (containing SSN, names, credit cards)

slide-11
SLIDE 11

Computer Science 161 Fall 2016 Popa and Weaver

Can aff s economy

X

slide-12
SLIDE 12
slide-13
SLIDE 13

Learn About Security Make a Difference

slide-14
SLIDE 14

Computer security is not only important but it is

FUN!

  • You are playing a game: can you stop the attacker?
  • Beautiful blend of analytical thinking (math) and

engineering (build systems)

slide-15
SLIDE 15

Computer security is varied

Cryptography Network security Operating systems security Web security Database security Distributed systems security Machine learning and security Security usability

It has room for many skills

Big challenge: many of you the expertise in those areas Provides a glimpse of these disciplines Tell us what concepts you need more background in

slide-16
SLIDE 16

Logistics

slide-17
SLIDE 17

Course Structure

Absorb material presented in lectures and section

Lecture will be webcasted

3 course projects (24% total)

Done individually or in small groups

~4 homeworks (16% total)

Done individually

Two midterms (30%) A comprehensive final exam (30%)

slide-18
SLIDE 18

Textbooks

No required textbook. If you want extra reading: Optional: Introduction to Computer Security, Goodrich & Tamassia Optional: The Craft of System Security, Smith & Marchesini

slide-19
SLIDE 19

Class Policies

Late homework: no credit Late project: -10% if < 24 hrs, -20% < 48 hrs,

  • 40% < 72 hrs, no credit

hrs Never read or share solutions, code, etc. with someone else, nor read past materials: work on your own (unless assignment states otherwise). If lecture materials available prior to lecture, use to answer questions during class Participate in Piazza

Send course-related questions/comments, or ask in

  • ffice hours. No

scale.

slide-20
SLIDE 20

Ethics

We will be looking for plagiarism, both manually and using advanced software; we can identify copy even if not exact, including from old material or submissions We will apply severe penalties including reporting to Student Conduct office

slide-21
SLIDE 21

THREAT MODELS

slide-22
SLIDE 22

Threat models

Cannot protect against all possible attackers High-level goal is risk management

Much of the effort concerns raising the bar and trading off resources

How to prudently spend your time & money?

Key notion of threat model: what you are defending against

Determines which defenses are worthwhile

slide-23
SLIDE 23

Threats have evolved

l

Spam, pharmaceuticals, credit card theft, identity theft

slide-24
SLIDE 24

Threats have evolved

Attackers have become more sophisticated; arms race between attackers and defenders fuels rapid innovation in malware

but not all security is an arms race, there are definite solutions to certain settings

Many attacks aim for profit and are facilitated by a well-

slide-25
SLIDE 25

Threats have evolved

l

Spam, pharmaceuticals, credit card theft, click fraud Government actors: Stuxnet, Flame, Aurora, Sony Private activism: Anonymous, Wikileaks

slide-26
SLIDE 26
slide-27
SLIDE 27
slide-28
SLIDE 28
slide-29
SLIDE 29
slide-30
SLIDE 30

Lesson

To protect computer systems, you must know your enemy defenses that are good enough to stop the

slide-31
SLIDE 31

2 CLASSICAL EXPLOITS

slide-32
SLIDE 32

Epic Hack: Internet worm

The first Internet worm, Morris worm A grad student experimented (in the lab) with self-spreading malware It got out.

slide-33
SLIDE 33

Epic Hack: Internet worm

The first Internet worm A grad student experimented (in the lab) with self-spreading malware It got out And took down the Internet

slide-34
SLIDE 34

Epic Hack: Internet worm

The first Internet worm A grad student experimented (in the lab) with self-spreading malware It got out. And took down the Internet. There is a lesson here.

slide-35
SLIDE 35

Epic Hack: Sarah Palin

Guy wants to mess with Tries logging into her Yahoo Mail

slide-36
SLIDE 36

Epic Hack: Sarah Palin

slide-37
SLIDE 37

Epic Hack: Sarah Palin

slide-38
SLIDE 38

Epic Hack: Sarah Palin

slide-39
SLIDE 39

Epic Hack: Sarah Palin

slide-40
SLIDE 40

Epic Hack: Sarah Palin

slide-41
SLIDE 41

Epic Hack: Sarah Palin

slide-42
SLIDE 42

Epic Hack: Sarah Palin

Sentenced to 1 year in federal prison Lesson: your system is only as secure as the weakest link.

slide-43
SLIDE 43

Epic Hack: Sarah Palin

Aftermath: in 2012, someone hacks Mitt

slide-44
SLIDE 44

Epic Hack: Sarah Palin

Aftermath: in 2012, someone hacks Mitt Lesson: old attacks remain relevant

slide-45
SLIDE 45

Memory safety

slide-46
SLIDE 46
slide-47
SLIDE 47
slide-48
SLIDE 48
slide-49
SLIDE 49

#2 #293 3 HRE RE- THR THR 850 50 19 1930 AL ALI CE CE SM SM I TH TH CO COACH CH SP SPECI CI AL L I NSTR NSTRUX: X: NO NONE

slide-50
SLIDE 50
slide-51
SLIDE 51

#2 #293 3 HRE RE- THR THR 850 50 19 1930 AL ALI CE CE SM SM I THHH THHHHHH HHHHH HHHH HH HHACH CH SP SPECI CI AL L I NSTR NSTRUX: X: NO NONE

How could Alice exploit this? Find a partner and talk it through.

slide-52
SLIDE 52
slide-53
SLIDE 53

#2 #293 3 HRE RE- THR THR 850 50 19 1930 AL ALI CE CE SM SM I TH TH FI FI RST ST SP SPECI CI AL L I NSTR NSTRUX: X: NO NONE

slide-54
SLIDE 54

#2 #293 3 HRE RE- THR THR 850 50 19 1930 AL ALI CE CE SM SM I TH TH FI FI RST ST SP SPECI CI AL L I NSTR NSTRUX: X: GI GI VE PA PAX E EXTR TRA CHA CHAM PA PAGNE NE.

slide-55
SLIDE 55

char nam e[ 20] ; voi d vul ner abl e( ) { . . . get s( nam e) ; . . . }

slide-56
SLIDE 56

char nam e[ 20] ; char i nst r ux[ 80] = " none" ; voi d vul ner abl e( ) { . . . get s( nam e) ; . . . }

slide-57
SLIDE 57

char nam e[ 20] ; char i nst r ux[ 80] = " none" ; voi d vul ner abl e( ) { . . . get s( nam e) ; . . . }

Memory unsafe code Reading data in name past 20 characters starts overlapping instrux because name and instrux are stored next to each

  • ther in memory
slide-58
SLIDE 58

char l i ne[ 512] ; char com m and[ ] = " / usr / bi n/ f i nger " ; voi d m ai n( ) { . . . get s( l i ne) ; . . . execv( com m and, . . . ) ; }

slide-59
SLIDE 59

char nam e[ 20] ; i nt ( * f npt r ) ( ) ; voi d vul ner abl e( ) { . . . get s( nam e) ; . . . }

slide-60
SLIDE 60

char nam e[ 20] ; i nt seat i nf i r st cl ass = 0; voi d vul ner abl e( ) { . . . get s( nam e) ; . . . }

slide-61
SLIDE 61

char nam e[ 20] ; i nt aut hent i cat ed = 0; voi d vul ner abl e( ) { . . . get s( nam e) ; . . . }

slide-62
SLIDE 62

Linux (32-bit) process memory layout

Reserved for Kernel user stack shared libraries run time heap static data segment text segment (program) unused

  • 0xC0000000
  • 0x40000000
  • 0x08048000

$esp brk Loaded from exec

  • 0x00000000
  • 0xFFFFFFFF
slide-63
SLIDE 63

Stack Frame

user stack shared libraries run time heap static data segment text segment (program) unused

  • 0xC0000000
  • 0x40000000
  • 0x08048000
  • 0x00000000

arguments return address stack frame pointer exception handlers local variables callee saved registers

T

  • previous stack

frame pointer T

  • the point at which

this function was called

Frame corresponding to function invocation

slide-64
SLIDE 64

Code Injection

slide-65
SLIDE 65

m ai n( ) { f ( ) ; } f ( ) { i nt x; g( ) ; } g( ) { char buf [ 80] ; get s( buf ) ; }

0xFFFF0000

ret

main()

ret x

f()

ret buf

g()

Stack (return addresses and local variables)

slide-66
SLIDE 66

m ai n( ) { f ( ) ; } f ( ) { i nt x; g( ) ; }

0xFFFF0000

ret

main()

ret x

f()

ret buf

g()

g( ) { char buf [ 80] ; get s( buf ) ; }

Stack (return addresses and local variables)

slide-67
SLIDE 67

Basic Stack Exploit

Overwriting the return address allows an attacker to redirect the flow of program control. Instead of crashing, this can allow arbitrary code to be executed. Example: attacker chooses malicious shellcode ), compiles to bytes, includes this in the input to the program so it will get stored in memory somewhere, then overwrites return address to point to it.

slide-68
SLIDE 68
slide-69
SLIDE 69

voi d vul ner abl e( ) { char buf [ 64] ; . . . get s( buf ) ; . . . }

slide-70
SLIDE 70

voi d saf e( ) { char buf [ 64] ; . . . f get s( buf , 64, st di n) ; . . . }

slide-71
SLIDE 71

voi d saf er ( ) { char buf [ 64] ; . . . f get s( buf , si zeof buf , st di n) ; . . . }

slide-72
SLIDE 72

voi d vul ner abl e( i nt l en, char * dat a) { char buf [ 64] ; i f ( l en > 64) r et ur n; m em cpy( buf , dat a, l en) ; }

m em cpy( voi d * dst , const voi d * sr c, si ze_t n) ; Attack: attacker supplies negative len, which becomes large value when cast to size_t

slide-73
SLIDE 73

voi d saf e( si ze_t l en, char * dat a) { char buf [ 64] ; i f ( l en > 64) r et ur n; m em cpy( buf , dat a, l en) ; }

Fix:

slide-74
SLIDE 74

voi d f ( si ze_t l en, char * dat a) { char * buf = m al l oc( l en+2) ; i f ( buf == N U LL) r et ur n; m em cpy( buf , dat a, l en) ; buf [ l en] = ' \ n' ; buf [ l en+1] = ' \ 0' ; }

Vulnerable! If l en = 0xf f f f f f f f , allocates only 1 byte Is it safe? Talk to your partner.

slide-75
SLIDE 75