engineering robust server software - andrew hilton · • keep bad things from happening • reduce...

55
Andrew Hilton / Duke ECE Engineering Robust Server Software Defense In Depth

Upload: others

Post on 24-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Engineering Robust Server Software

Defense In Depth

Page 2: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

You Are Building YourAwesomeSite.com

• Use all the best practices you know

2

Django

Built In Authen

Sanitization

Distrust clients

Page 3: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

You Are Building YourAwesomeSite.com

• …But also lots of things you didn't write

• Adds a lot of complexity…

3

Django

AwesomeThingyLib

ReallyNeatWhatzit

BlahBlahToolkit

Built In Authen

Sanitization

Distrust clients

Page 4: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

You Are Building YourAwesomeSite.com

• Oh plus what about the other developers on your team?

4

Hey Beavis, I found this code on StackOverflow

I dont know but they said its really awesome.

Heheh Whats it do Butthead? Heheh

Page 5: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

What Happens If Something Goes Wrong?

• Suppose a vulnerability exists: what is the damage?

5

CC numbersAuth Info

User Activity Logs

Images, etc

User Profiles

Page 6: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Defense In Depth

• Idea: Assume one layer of security might fail

• Multiple layers of security

• Minimize damage if one layer is compromised6

CC numbersAuth Info

User Activity Logs

Images, etc

User Profiles

CC numbersAuth Info

User Activity Logs

Images, etc

User Profiles

Page 7: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Example of This That We Have Seen?• What have we already seen that is an example of mitigating damage if

compromised?

• A: nop slide

• B: CSRF token

• C: Diffie-Hellman Key Exchange

• D: Salt and hash passwords

7

Page 8: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Famous Example of NOT Defense In Depth• Equifax got hacked

• Bug in web library they were using

• Many users' personal data (SSNs, etc) stolen

• Why/how?

• What should they have done?

8

CC numbersAuth Info

User Activity Logs

Images, etcUser Profiles

Page 9: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Vulnerability -> Access To All Things

9

Django

AwesomeThingyLib

ReallyNeatWhatzit

BlahBlahToolkit

Built In Authen

Sanitization

Distrust clients

Page 10: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Vulnerability -> Access To All Things

10

Django

AwesomeThingyLib

ReallyNeatWhatzit

BlahBlahToolkit

Built In Authen

Sanitization

Distrust clients

SELECT * from userssns;

Page 11: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

What Could We Do Instead?

11

Web CodeAuth Server

CC Server

SSN Server

Users Internal APIs

Page 12: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

What Could We Do Instead?

12

Web CodeAuth Server

CC Server

SSN Server

Users Internal APIs

+Firewalls

Page 13: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast: Make a Purchase

13

Web Code

UsersAuth InfoCC Info….

Page 14: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast: Make a Purchase

14

Web Code

UsersAuth InfoCC Info….

GET /selectPayment Authen info

Payment Info(Payment page)

Page 15: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast: Make a Purchase

15

Web Code

UsersAuth InfoCC Info….

GET /selectPayment Authen info

Payment Info(Payment page)

POST /makePayment Authen info

Payment InfoTo CC Processor

Page 16: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast: Make a Purchase

16

Web Code

UsersAuth InfoCC Info….

GET /selectPayment Authen info

(all the info)Get all user's info

(everyone's credit card #s hashed pwds SSNs…)

Page 17: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

17

Web CodeAuth Server

CC Server

SSN Server

GET /selectPayment

Page 18: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

18

Web CodeAuth Server

CC Server

SSN Server

GET /selectPayment

isSessionValid?

Page 19: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

19

Web CodeAuth Server

CC Server

SSN Server

GET /selectPayment

Yes

Page 20: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

20

Web CodeAuth Server

CC Server

SSN Server

GET /selectPayment

Get Cards for user=drew sid=123456789

Page 21: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

21

Web CodeAuth Server

CC Server

SSN Server

GET /selectPayment

Get Cards for user=drew sid=123456789

IsValid? Yes

Page 22: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

22

Web CodeAuth Server

CC Server

SSN Server

GET /selectPayment

Get Cards for user=drew sid=123456789

ending in 9876 ending in 0000

Only give back what is needed to web server! (e.g., not full credit card #s)

Page 23: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

23

Web CodeAuth Server

CC Server

SSN Server

Purchase $579,cardid=1 user=drew…

POST /makePayment

IsValid? Yes

Page 24: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

24

Web CodeAuth Server

CC Server

SSN Server

POST /makePayment

Bank's Server

Page 25: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

25

Web CodeAuth Server

CC Server

SSN Server

POST /makePayment

Ok!

No need to ever report full credit card numbers back to web code (only time it sees is when user adds them)

Page 26: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

26

Web CodeAuth Server

CC Server

SSN Server

Page 27: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

27

Web CodeAuth Server

CC Server

SSN Server

Page 28: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

28

Web CodeAuth Server

CC Server

SSN Server

Page 29: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Contrast Make A Purchase

29

Web CodeAuth Server

CC Server

SSN Server

Page 30: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Let Us Revisit This

30

Web CodeAuth Server

CC Server

SSN Server

Page 31: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Let Us Revisit This

31

Web CodeAuth Server

CC Server

SSN Server

I'm going to play a longer game…

Page 32: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Let Us Revisit This

32

Web CodeAuth Server

CC Server

SSN Server

Every time someone logs in - Get their auth info - Send request to CC server Purchase something with their card

Less bad, but still bad… (why?)

Page 33: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Let Us Revisit This

33

Web CodeAuth Server

CC Server

SSN Server

Every time someone logs in - Get their auth info - Send request to CC server Purchase something with their card

How to defend against this?

Page 34: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Remember this "plan"?

• Most secure:

• Run program Handle web request on a computer

• Throw away computer

• Buy new computer

• Run next program Handle next web request on it

34

$$$$

Page 35: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Ok that plan was bad… but• That plan was bad, but what did we decide we could do instead?

35

Page 36: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Prevention + Detection + Response• So far have talked about prevention

• Keep bad things from happening

• Reduce badness if they do happen

• Also want detection

• Know when a bad thing has happened / is happening

• …and to be able to respond to the attack

• Nice if we can do something about it…

36

Page 37: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• Monitor system for suspicious activity

37

?????

Page 38: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• Monitor system for suspicious activity

38

?????

SYN, port 22 (encrypted traffic) FIN

Seems normal. Some short ssh activity

Page 39: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• Monitor system for suspicious activity

39

?????

SYN, port 22 (encrypted traffic) FIN

Again… Odd, thats two in quick succession…

Page 40: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• Monitor system for suspicious activity

40

?????

SYN, port 22 (encrypted traffic) FIN

Hmm maybe they are trying passwords?

Seems bad Detection

Page 41: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• Monitor system for suspicious activity

41

?????

SYN, port 22 (encrypted traffic) FIN

Ban this IP in the firewalll Response

Page 42: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• Monitor system for suspicious activity

42

?????

SYN, port 22 (encrypted traffic) FIN

Ban this IP in the firewalll Response

Page 43: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Was this response good?• Detected something suspicious

• Responded strongly:

• Blocked traffic from originating site

• Good or bad?

43

Page 44: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Was this response good?• Detected something suspicious

• Responded strongly:

• Blocked traffic from originating site

• Good or bad?

• It depends!

44

Page 45: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• If true positive, outcome was good

45

SYN, port 22 (encrypted traffic) FIN

Ban this IP in the firewalll Response

I was trying common passwords…

Page 46: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Intrusion Detection

• If false positive, then it was bad

• Abnormal is not always bad

46

SYN, port 22 (encrypted traffic) FIN

Ban this IP in the firewalll

I once accidentally got CC's IP banned by Duke's firewall this way… Oops.

I was just trying to scp several small files one at a time…

Page 47: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Detection• Automated: Algorithmic analysis + detection

• Signature based: look for patterns

• This seems to be trying many passwords

• This seems to be port scanning

• Anomaly detection:

• Develop ML model of normal behavior

• Find things that deviate

• Human:

• Look at logs, system behavior etc

47

Page 48: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Detection• Not limited to network activity

• These aren't queries that we ever run…

• This return address has been overwritten

• This pattern of system calls is unusual

• There have been 4 failed login attempts for user "drew"

• …

• Similar ideas in non-computer security

• Bank watches credit card purchases for suspicious activity

• Unattended bags at airport

• …48

Page 49: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Think Pair Share• What could our responses be?

• What factors should we consider in determining an appropriate response?

49

Page 50: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Responses• Notify administrators

• Send email: Hey something is strange… Here is what is up!

• Pros and cons?

50

Page 51: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Responses• Notify administrators

• Send email, text, etc: Hey something is strange… Here is what is up!

• Pros and cons?

• Block suspicious behavior

• Lock account, firewall traffic, ….

• Pros and cons?

51

Page 52: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Responses• Notify administrators

• Send email, text, etc: Hey something is strange… Here is what is up!

• Pros and cons?

• Block suspicious behavior

• Lock account, firewall traffic, ….

• Pros and cons?

• Shutdown affected system

• Power that machine off

• Pros and cons?

52

Page 53: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Responses• Notify administrators

• Send email, text, etc: Hey something is strange… Here is what is up!

• Pros and cons?

• Block suspicious behavior

• Lock account, firewall traffic, ….

• Pros and cons?

• Shutdown affected system

• Power that machine off

• Pros and cons?

• Nuke and restore from backup? (or even throw away hw?)53

Page 54: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Factors in Choosing Response• False positive rate

• How certain are we that suspicious = bad?

• Severity of suspected attack

• How bad is it?

• Someone trying to find a vulnerability vs

• Server was rooted

• Impacts of response on "good" users/ how many affected

• Bad impacts: services temporarily unavailable, …

• Good impacts: prevent leakage of sensitive info,…

54

Page 55: Engineering Robust Server Software - Andrew Hilton · • Keep bad things from happening • Reduce badness if they do happen • Also want detection • Know when a bad thing has

Andrew Hilton / Duke ECE

Wrap Up• Assume security measures will fail!

• Multiple levels: mitigate damage if one fails

• Detect suspicious activity

• Don't just assume everything is good, look for bad stuff

• Respond to threats

• What to do: it depends…

55