Top Banner
CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz
27

CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

CMSC 414Computer and Network Security

Lecture 23

Jonathan Katz

Page 2: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Database security

Page 3: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Data perturbation: k-anonymity

Ensure that any “identifying information” is shared by at least k members of the database

Example…

Page 4: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Example: 2-anonymityRace ZIP Smoke? Cancer?

Asian 02138 Y Y

Asian 02139 Y N

Asian 02141 N N

Asian 02142 Y Y

Black 02138 N N

Black 02139 N Y

Black 02141 Y Y

Black 02142 N N

White 02138 Y Y

White 02139 N N

White 02141 Y Y

White 02132 Y Y

- 02138

- 02139

- 02141

- 02142

- 02138

- 02139

- 02141

- 02142

- 02138

- 02139

- 02141

- 02132

Asian 0213x

Asian 0213x

Asian 0214x

Asian 0214x

Black 0213x

Black 0213x

Black 0214x

Black 0214x

White 0213x

White 0213x

White 0214x

White 0213x

Page 5: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Problems with k-anonymity

Hard to find the right balance between what is “scrubbed” and utility of the data

Not clear what security guarantees it provides– For example, what if I know that the Asian person in

ZIP code 0214x smokes?

– Again, does not deal with out-of-band information

Page 6: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Output perturbation

One approach: replace the query with a perturbed query, then return an exact answer to that– E.g., a query over some set of entries C is answered

using some (randomly-determined) subset C’ C

– User only learns the answer, not C’

Second approach: add noise to the exact answer (to the original query)

Page 7: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

A negative result [Dinur-Nissim]

Heavily paraphrased:

Given a database with n rows, if roughly n queries are made to the database (in total) then essentially the entire database can be reconstructed even if O(n1/2) noise is added to each answer

On the positive side, it is known that very small error can be used when the total number of queries is kept small

Page 8: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Formally defining privacy

A problem inherent in all these approaches (and the source of many of the problems we have seen) is that no definition of “privacy” is offered

Recently, there has been work addressing exactly this point– Developing definitions

– Provably-secure schemes!

Page 9: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

A definition of privacy

Differential privacy [Dwork et al.]

Roughly speaking: – For each row r of the database (representing, say, an

individual), the distribution of answers given when r is included in the database are “close” to the answers given when r is not included in the database

– Note: can’t really hope for closeness better than 1/|DB|

Further refining/extending this definition is currently an active area of research

Page 10: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Achieving privacy

A “converse” to the Dinur-Nissim result is that adding some (carefully-generated) noise, and limiting the number of queries appropriately, can be proven to achieve privacy

Currently an active area of research

Page 11: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Programming language/application level security

Page 12: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

PL security

Previous focus in this class has been on secure protocols and algorithms

For real-world security, it is not enough for the protocol/algorithm to be secure, but also the implementation must be secure

Page 13: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Importance of the problem

The amount of time we are devoting to the problem is not indicative of its relative importance

In practice, attacks that exploit implementation flaws are much more common than attacks that exploit protocol flaws– Damage from such flaws also typically much greater

– Viruses/worms almost always exploit such flaws

If you ever program security-sensitive applications, learn about secure programming

Page 14: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Importance of the problem

Most common cause of Internet attacks– Over 50% of CERT advisories related to buffer

overflow vulnerabilities

Morris worm (1988)– 6,000 machines infected

CodeRed (2001)– 300,000 machines infected in 14 hours

SQL slammer worm (2003)– 75,000 machines infected in 10 minutes(!)

Page 15: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

PL attacks Many of the most common PL attacks come down

to not properly validating input from (untrusted) users before use– Buffer overflow attacks– Format string vulnerabilities– Cross-site scripting (XSS) attacks– SQL injection attacks– etc.

There are other PL security issues as well, but we will not cover these in this class

Page 16: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Buffer overflows

Fixed-sized buffer that is to be filled with unknown data, usually provided directly by user

If more data “stuffed” into the buffer than it can hold, that data spills over into adjacent memory

If this data is executable code, the victim’s machine may be tricked into running it

Can overflow buffer on the stack or the heap…

Page 17: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Stack overview

Each function that is executed is allocated its own frame on the stack

When one function calls another, a new frame is initialized and placed (pushed) on the stack

When a function is finished executing, its frame is taken off (popped) the stack

Page 18: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Function frame

Stack grows this way

locals vars ebpret

addr args Frame of thecalling function

Execute code at

this address after func()

finishes

Pointer toprevious

frame

Page 19: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

“Simple” buffer overflow

Overflow one variable into another

gets(color)– What if I type “blue 1” ?

– (Actually, need to be more clever than this)

color ebpret

addr argsFrame of the

calling functionprice

locals vars

Page 20: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

More devious examples… strcpy(buf, str)

What if str has more than buf can hold?

Problem: strcpy does not check that str is shorter than buf

buf sfpret

addr strFrame of the

calling function

Pointer toprevious

frame

Execute code at

this address after func()

finishes

overflow

This will beinterpreted

as a return address!

Page 21: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Even more devious…

buf sfpret

addr strFrame of the

calling functionoverflow

Attacker puts actual assembly instructions into his input string, e.g.,

binary code of execve(“/bin/sh”)

In the overflow, a pointer backinto the buffer appears in

the location where the systemexpects to find return address

Page 22: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Severity of attack?

Theoretically, attacker can cause machine to execute arbitrary code with the permissions of the program itself

Actually carrying out such an attack involves many more details– See “Smashing the Stack…”

Page 23: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Examples; using gdb

Page 24: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Preventing this attack We have seen that strcpy is unsafe

– strcpy(buf, str) simply copies memory contents into buf starting from *str until “\0” is encountered, ignoring the size of buf

Avoid strcpy(), strcat(), gets(), etc.– Use strncpy(), strncat(), instead– Even these are not perfect… (e.g., no null termination)– Always a good idea to do your own validation when

obtaining input from untrusted source– Still need to be careful when copying multiple inputs

into a buffer

Page 25: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Does range checking help? strncpy(char *dest, const char *src, size_t n)

– No more than n characters will be copied from *src to *dest• Programmer has to supply the right value of n!

Bad:

… strcpy(record,user); strcat(record,”:”); strcat(record,cpw); …

Published “fix” (do you see the problem?): … strncpy(record,user,MAX_STRING_LEN-1);

strcat(record,”:”); strncat(record,cpw,MAX_STRING_LEN-1); …

Page 26: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Off-by-one overflow

Consider the following code: char buf[512]; int i; for (i=0; i <= 512; i++) buf[i] = input[i];

1-byte overflow: can’t change return address, but can change pointer to previous stack frame– On little-endian architecture, make it point into buffer

Page 27: CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.

Exam review