840 likes | 1.03k Views
Computer Security: Computer Science with Attackers. Usable Privacy and Security Fall 2009 As told by David Brumley. Find X. There it is. X is 5. X. 3. 4. My Security Axioms. I. Attackers Get Lucky Defenders Do Not. II. Attackers are Creative. Agenda.
E N D
Computer Security: Computer Science with Attackers Usable Privacy and SecurityFall 2009 As told by David Brumley
Find X There it is X is 5 X 3 4
My Security Axioms I. Attackers Get Lucky Defenders Do Not II. Attackers are Creative
Agenda • Examples of Axioms, (aka, how to think like an attacker) • Example I: Ken Thompson • Example II: APEG • Example III: RSA • How to argue security
Ken Thompson • Born Feb 4, 1943 • Notable Work: • B Programming Language • UNIX • Plan 9 • Popularized regular expressions • 1983: Turing Award (joint with Ritchie) for UNIX and work in OS • 1999: US National Medal of Technology • 1999: First IEEE Tsutomu Kanai Award
A Self-Reproducing Program main(){printf(f,34,f,34,10);} char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c";
When Executed char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} printf(“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c” ,34,f,34,10); char *f=
When Executed char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} printf(“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c” ,34,f,34,10);// 34 ascii is a quote (“) char *f=“
When Executed char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} printf(“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c” ,34,f,34,10); char *f=“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c
When Executed char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} printf(“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c” ,34,f,34,10); // 34 is a quote char *f=“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c”
When Executed char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} printf(“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c” ,34,f,34,10); // 34 is a quote char *f=“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c”;main() {printf(f,34,f,34,10);}
When Executed char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} printf(“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c” ,34,f,34,10); // 10 is newline char *f=“char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c”;main() {printf(f,34,f,34,10);}
Note • This program can contain an arbitrary amount of excess baggage that will be reproduced along with the main algorithm. main(){printf(f,34,f,34,10);} char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c";
The C Compiler • The C compiler (cc) is written in C • Special characters, such as newlines, quotes, etc., are escaped with backslashes. This is called a “character escape sequence” c = next(); if(c != ‘\\’) // Note, since compiler itself is written in C, must escape backslash return c; c = next(); if(c == ‘\\’) return ‘\\’; // Will return “\\” if(c == ‘n’) return ‘\n’ etc.
Adding a New Escape Sequence • The C compiler (cc) is written in C • How do we add a new escape sequence? • Not yet valid C until added to compiler • But compiling modified compiler will not work because not valid C c = next(); if(c != ‘\\’) // Note, since compiler itself is written in C, must escape backslash return c; c = next(); … if(c == ‘v’) return ‘\v’; /// INVALID! etc.
What you do • Solution: Encode in current valid C • ‘\v’ is ASCII 11 c = next(); if(c != ‘\\’) // Note, since compiler itself is written in C, must escape backslash return c; c = next(); … if(c == ‘v’) return 11; // Works etc.
Checkpoint • Can make a program that prints itself out • Can change the semantics of a compiler
How a compiler works Source Language TargetLanguage Compiler Source Code get(s); compile(s); ExecutableCode
Trojaning Login Compiler ‘login’ get(s); compile(s); if(s == ‘login’) compile(backdoor); Trojaned ‘login’
Trojaning Compiler Compiler ‘cc’ get(s); compile(s); if(s == ‘login’) compile(backdoor); if(s == ‘cc’)compile(cc-backdoor); Trojaned ‘cc’
Using Trojaned Compiler Source ‘cc’ source ‘login’ source Compiler get(s); compile(s); if(s == ‘login’) compile(backdoor); if(s == ‘cc’)compile(cc-backdoor); Trojaned ‘cc’ trojaned exec ‘cc’ trojaned exec ‘login’
Agenda • Examples of Axioms, (aka, how to think like an attacker) • Example I: Ken Thompson • Example II: APEG • Example III: RSA • How to argue security
BBuggy Program PPatched New Program Patches Help Security “Regularly Install Patches”− Computer Security Wisdom
Patches Can Help Attackers −Evil David Evil David
Delayed PatchAttack Evil David Use Patch to Reverse Engineer Bug Gets Patch Attack Unpatched Users T1 T2 Evil David’s Timeline
Patch Delay N. Americagets patched version P Asia gets P [Gkantsidis et al 06]
I can reverse engineer the patched bug and create an exploit in minutes Minutes Gets Patch Reverse Engineer Bug Attack Unpatched Users T1 T2 Evil David’s Timeline
Intuition ParticularInput program Bad Good Trigger Bug
Intuition Exploit BBuggy Program program Bad Good
Intuition BBuggy Program PPatched Program program Bad Good Patch leaks:1) Where2) How to exploit
AutomaticPatch-Based Exploit Generation Step 3: Automatically CalculateExploit Step 1: Get program B P Bad Good Step 2: Diff B & P
AutomaticPatch-Based Exploit Generation Step 3: Automatically CalculateExploit Step 1: Get program B P Bad Good Profit! Step 2: Diff B & P
All integers unsigned 32-bits All arithmetic mod 232 B is binary code IE6 Bug Example B read input if input % 2==0 F T s := input + 3 s := input + 2 ptr := realloc(ptr, s)
input = 232-2 IE6 Bug Example B read input if input % 2==0 232-2 % 2 == 0 F T s := input + 3 s := input + 2 s := 0 (232-2 + 2 % 232) ptr := realloc(ptr, s) ptr := realloc(ptr,0) Using ptr is a problem
IE6 Bug Example B read input Wanted: s > input Integer Overflow when:¬(s > input) if input % 2==0 F T s := input + 3 s := input + 2 ptr := realloc(ptr, s)
Patch B read input P read input if input % 2==0 if input % 2==0 F T F T s := input + 3 s := input + 2 s := input + 3 s := input + 2 ptr := realloc(ptr, s) if s > input T F Error ptr := realloc(ptr, s)
Patch B read input P read input if input % 2==0 if input % 2==0 F T F T s := input + 3 s := input + 2 s := input + 3 s := input + 2 ptr := realloc(ptr, s) if s > input T F Error ptr := realloc(ptr, s) Exploits for B are inputs that fail new safety condition check in P(s > input) = false
Result Overview • No public exploit for 3 out of 5 • Exploit unique for other 2
Does Automatic Patch-Based Exploit Generation Always Work? NO! However, in security attackers get lucky, defenders do not Current Delayed Patch Distribution Insecure
Agenda • Examples of Axioms, (aka, how to think like an attacker) • Example I: Ken Thompson • Example II: APEG • Example III: RSA • How to argue security
RSA Cryptosystem • Invented in 1978 by Rivest, Shamir, and Adleman • RSA is widely used • Apache+mod_SSL (https) • stunnel (Secure TCP/IP servers) • sNFS (Secure NFS) • bind (name service) • ssh (secure shell) • We believe RSA is secure
RSA Algorithm • RSA Initialization: • pick prime p (secret) • pick prime q (secret) • Let N = pq (N is public) • pick e (public) • Find ds.t. d*e = 1 mod (p-1)(q-1) (private) • RSA encryption of m: calculate me mod N = c • RSA decryption of c: calculate cdmod N =m • p = 61, q = 53 • N = 3233 • e = 17 • d = 2753 • Suppose m = 123 • c = 12317 mod 3233 = 855 • m = 8552753 mod 3233 = 123
Why is RSA Secure • Step 1: define “security” • Step 2: Show that RSA meets definition
Step 1: Define Security • Public Parameters • N = pq (N is public) • e (public) • Private Parameters • p (secret) • q (secret) • d (derived from e, p, and q, private) RSA Problem: Given N,e, me mod N, compute m RSA is secure if the RSA problemcannot be solved efficiently
Step 2: Show RSA Meets Definition RSA Problem: Given N,e, me mod N, compute m • Public Parameters • N = pq (N is public) • e (public) • Private Parameters • p (secret) • q (secret) • d (derived from e, p, and q, private) Fact: we do not know RSA is secure
2 Ways to Break RSA RSA Problem: Given N,e, me mod N, compute m Fact: if we can factor, we can break RSA Public N e Private pq d FactoringAlgorithm Given me, we can decrypt just like those who know d
2 Ways to Break RSA RSA Problem: Given N,e, me mod N, compute m Fact: if we can take roots modulo N, we can break RSA Public me mod N Roots m
Arguing Security • Define what is public and private • Define protocol • What bad guy gets to see • What bad guy cannot see • Show that any run of the protocol the bad guy • cannot see what he is not suppose to • cannot efficiently compute what he is not suppose to