lecture 10 - pointless tainting? evaluating the practicality of pointer

40
Lecture 10 Pointless Tainting? Evaluating the Practicality of Pointer Tainting Asia Slowinska, Herbert Bos Advanced Operating Systems December 15, 2010 SOA/OS Lecture 10, Pointer Tainting 1/40

Upload: lyliem

Post on 06-Feb-2017

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Lecture 10Pointless Tainting? Evaluating the Practicality of Pointer

Tainting

Asia Slowinska, Herbert Bos

Advanced Operating Systems

December 15, 2010

SOA/OS Lecture 10, Pointer Tainting 1/40

Page 2: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 2/40

Page 3: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 3/40

Page 4: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Exploiting

I buffer overflowsI inject code – alter control flow

I attack non-control dataI user identityI user privilege levelI server configuration string

I non-control data attacks are more difficult to detect

SOA/OS Lecture 10, Pointer Tainting 4/40

Page 5: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Protection from non-control data attacks

I type-safe languages

I compiler extensions

I formal methods verificationI however . . .

I C/C++I source unavailable – recompilation not possible

I trojansI masquerade as useful programsI no exploit requiredI “stealthy spies” harder to detect

SOA/OS Lecture 10, Pointer Tainting 5/40

Page 6: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Control flow diversion

I pointer dereferenceI control diversion attacks

I execute instructions different from the ones it would normallyexecute

I alter flow of control

I non control diversion attacksI memory corruption attacks against non-control data

(non-function return address etc.)I privacy breaching malware (keyloggers and sniffers)I elevated privileges, unusual repliesI address space layout randomization & stack guard don’t work

SOA/OS Lecture 10, Pointer Tainting 6/40

Page 7: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Pointer tainting

I focused by non control diversion attacks

I also works against control-diverting attacksI a form of dynamic information flow tracking (DIFT)

I origin of data through a taint bit in a shadow memoryunaccessible to software

I check whether values derived from tainted origin ends up inplaces it should never be stored

I popularI apply on software without need of recompilationI (stated by advocates) incurs hardly false positivesI one of the only techniques of detecting both control-diverting

and non-control diverting attacks

SOA/OS Lecture 10, Pointer Tainting 7/40

Page 8: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Pointer tainting – not working

I keylogger detectorI the method is flawedI incurs both false positives and negative

I existing applications not suitable for x86 architecture andWindows operating systems

I analyse fundamental limitations of the method when appliedto detection of privacy-breaching malware

I fixing the method is breaking it

SOA/OS Lecture 10, Pointer Tainting 8/40

Page 9: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 9/40

Page 10: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Control diverting attacks

I manipulate data that is subsequently loaded in the processor’sprogram counter

I struct req {

char reqbuf[64];

void (*handler)(char *);

};

void do_req(int fd, struct req *r)

{

// now the overflow

read(fd, r->reqbuf, 64);

r->handler(r->reqbuf);

}

SOA/OS Lecture 10, Pointer Tainting 10/40

Page 11: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Non-control diverting attacks

I modify security-critical data (do not alter control flow)I non control data attacks

void serve (int fd)

{

char *name = globMyHost;

char cl name[64];

char svr reply[1024];

// now the overflow:

read(fd,cl name,128);

sprintf(svr reply,

"hello %s, I am %s",

cl name, name);

svr send(fd,svr reply,1024);

}

I privacy breaching malware (trojans, keyloggers)

SOA/OS Lecture 10, Pointer Tainting 11/40

Page 12: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 12/40

Page 13: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Basic tainting

I dynamic taint analysis

I mark (in an emulator or hardware) all data coming fromsuspect sources

I taint is propagated

I source operands in ALU – destination is tainted

I copy source operands – taint propagates

I “cleaning” instructions (xor eax,eax)

I jump to “tainted” address – alarm is raised

I protection against control-diverting attacks, but not againstnon-control diverting attacks

SOA/OS Lecture 10, Pointer Tainting 13/40

Page 14: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Memory corruption

I dereference of attack-manipulated pointers (same ascontrol-diverting attacks)

I heap corruption – change links in lists

I format string attack

I basic tainting analysis raises alerts only for dereferences due tojumps, branches and function calls/returns

SOA/OS Lecture 10, Pointer Tainting 14/40

Page 15: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Privacy-breaching

I “possibly malicious” program spying on users’ behaviour –keyloggers

I basic taint analysis is weak in the face of translation tablesI x is taintedI y = a[x] is not taintedI similar for atoi, to_upper, strtol

I taint analysis is powerless in the face of privacy-breachingmalware

SOA/OS Lecture 10, Pointer Tainting 15/40

Page 16: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Pointer tainting

I designed to handle non-control diverting attacksI limited pointer tainting (detecting non-control data attacks)

I p is taintedI raise an alert on any dereference of pI inapplicable in the general caseI LPT prescribe that taint of and index is cleanedI LPT cannot be used for tracking keystrokesI if p is tainted raise an alert on any dereference of p

I full pointer tainting (detect privacy breaching)I propagates taintI if p is tainted, any dereference of p taints the destinationI looks ideal for privacy-breaching malware applications

SOA/OS Lecture 10, Pointer Tainting 16/40

Page 17: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 17/40

Page 18: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Test environment

I Qemu 0.9

I Ubuntu 8.04.1, kernel 2.6.24-19-386

I Windows XP SP2I depending on test, modify emulator to taint either

I typed keyboard charactersI network data

I inspect taintedness of register at context-switch timesI the more register are tainted the worse the problem

I particularly serious for esp and ebp

SOA/OS Lecture 10, Pointer Tainting 18/40

Page 19: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Test environment (2)

I conservative measurementsI register may be clean but not bytes in process’ address spaceI check registers only at context-switch timesI sufficient to present the problem of false positives

I taintedness in LinuxI schedule()I context_switch() – monitor taintedness inside the kernel

I taintedness in WindowsI cr3 inspection – contains the physical address of the top-level

page directoryI cr3 change → a new process is scheduled

SOA/OS Lecture 10, Pointer Tainting 19/40

Page 20: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

False positives in LPT

I taint data from network

I alerts raised for benign actions like configuring the machine’sIP address

I LPT propagates taint when combining and untainted basepointer and a tainted index

I dereferencing causes an alert

SOA/OS Lecture 10, Pointer Tainting 20/40

Page 21: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Taint explosion for FPT

I simple keystroke tracing – all taint that is applied

I simple C program – reads a user typed character from thecommand line

SOA/OS Lecture 10, Pointer Tainting 21/40

Page 22: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Taint explosion for FPT (2)

SOA/OS Lecture 10, Pointer Tainting 22/40

Page 23: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Taint explosion for FPT (3)

SOA/OS Lecture 10, Pointer Tainting 23/40

Page 24: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Taint pollution

I containment measures required

I pollution of the kernel

I problematic usage of esp and ebp

SOA/OS Lecture 10, Pointer Tainting 24/40

Page 25: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Taint analysis by opening files

SOA/OS Lecture 10, Pointer Tainting 25/40

Page 26: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

False positives and root causes of taint pollution

I tainting of ebp and espI LPT raises alarms quicklyI FPT spreads taint indiscriminately

I pointers are tainted in the same wayI A tainted, what about B = (A+0x4)?

I if taint is applied only for detecting memory corruptionattacks, taint may leak due to table lookups

SOA/OS Lecture 10, Pointer Tainting 26/40

Page 27: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

False negatives

I pure LPT and FTP does not have many false negativesI however . . .

I LPT will miss modification of non-control data by means of adirect buffer overflow

I miss implicit information flowsI if (x == 0) y = 0; else y = 1

I reduce false positive → opportunities for false negatives willincrease significantly

SOA/OS Lecture 10, Pointer Tainting 27/40

Page 28: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 28/40

Page 29: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

ebp/esp protection

I both LPT and FPT

I basic idea – never apply pointer tainting to tainted values ofebp and esp

I ebp is used as a general purpose register

I clean ebp when value is large enough to represent a framepointer

I although taint is slowed down, it still propagates quickly

SOA/OS Lecture 10, Pointer Tainting 29/40

Page 30: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

LPT-specific containment techniques

I prevent taint from leaking due to table lookupsI detect and sanitise table accesses

I impractical on x86 – no specific instructions for pointerarithmetic

I bounds checks – safe even if index is tainted provided theindex was properly bounds-checked

I identified by a cmp instructionI suffers from false positives and false negatives

I pointer injection detectionI use a P bit to mark valid pointersI applied on SPARC v8 architectureI false positives possible – overflow a buffer, modify and index,

add index to a legitimate addressI not easily applicable to x86

SOA/OS Lecture 10, Pointer Tainting 30/40

Page 31: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

FTP-specific techniques

I white lists and black listsI white list all places where tainting should be propagatedI black list all places where tainting should not be propagatedI unfeasible for large applicationsI heavy impact on performance

I landmarkingI an address is “ready to be used for a dereference”I dereferencing a landmark – propagate taintI derived values have to be modified with tainted dataI opportunities for false positives and false negatives abound

SOA/OS Lecture 10, Pointer Tainting 31/40

Page 32: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Landmarking and esp/ebp protection

SOA/OS Lecture 10, Pointer Tainting 32/40

Page 33: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 33/40

Page 34: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

FPT is broken

I prone to false negatives

I only slow down the outburst of false positives

I difficult to distinguish access to a translation table fromaccess to a next field in a linked list

I without a priori information it’s impossible to successfullyapply FPT (on current hardware)

SOA/OS Lecture 10, Pointer Tainting 34/40

Page 35: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Challenges for LPT

I pointer injection (P bit) seems promising

I have to get it to work on common hardware

I possible for Linux on SPARC

I open challenge to do it for x86

SOA/OS Lecture 10, Pointer Tainting 35/40

Page 36: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Overall

I pointer tainting – considered one of the most powerfultechniques to detect keyloggers and memory corruptionattacks on non-control data

I proved problematic – large number of false positives

I FPT is probably not suited for detecting keyloggers

I unclear whether LPT can be applied to automatically detectmemory corruption attacks on x86

SOA/OS Lecture 10, Pointer Tainting 36/40

Page 37: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 37/40

Page 38: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Keywords

I exploit

I DIFT

I taint analysis

I pointer tainting

I control diversion

I control data

I non-control data

I memory corruption

I keylogger, trojans

I x86 (Linux & Windows)

I limited pointer tainting(LPT)

I full pointer tainting (FPT)

I false positives, falsenegatives

I esp/ebp protection

I pointer injection detection

I landmarking

SOA/OS Lecture 10, Pointer Tainting 38/40

Page 39: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Resources

I Asia Slowinska, Herbert Bos – Pointless Tainting? Evaluatingthe Practicality of Pointer Tainting

I Asia Slowinska, Herbert Bos – Pointer tainting still pointless:(but we all see the point of tainting)

SOA/OS Lecture 10, Pointer Tainting 39/40

Page 40: Lecture 10 - Pointless Tainting? Evaluating the Practicality of Pointer

Outline

Introduction

Threat model

Pointer tainting

Problems with pointer tainting

Containment techniques

Conclusion

Keywords

Questions

SOA/OS Lecture 10, Pointer Tainting 40/40