minemu protecting buggy binaries from memory corruption
play

Minemu: Protecting buggy binaries from memory corruption attacks - PowerPoint PPT Presentation

Minemu: Protecting buggy binaries from memory corruption attacks Erik Bosman <erik@minemu.org> Programming Languages type-safe vs. not type-safe Programming Languages type-safe vs. not type-safe Java Python Ruby Javascript


  1. Taint tracking (1/2): - remember whether data is trusted or not - untrusted data is 'tainted' - when data is copied, its taint is copied along - taint is ORed for arithmetic operations

  2. Taint tracking (2/2): When the code jumps to an address in memory, the source of this address is checked for taint. eg.: - RET - CALL *%eax - JMP *0x1c(%ebx)

  3. T aint tracking photo: sammydavisdog@ fl ickr useful, but slow as hell

  4. Is this slowness fundamental? minemu fast emulator memory layout use SSE registers to hold taint

  5. Is this slowness fundamental? minemu fast emulator memory layout use SSE registers to hold taint

  6. Emulator compile jit code

  7. Emulator run jit code compile jit code

  8. Emulator indirect jump run jit code find jump compile jit code address

  9. Emulator indirect jump lookup miss run jit code find jump compile jit code address

  10. Dynamic instrumentation t_eax = t_eax | t_ecx eax = eax + ecx eax = eax + ebx original code jit code

  11. Is this slowness fundamental? minemu fast emulator memory layout use SSE registers to hold taint

  12. Linux stack User heap/libs executable

  13. Memory layout (linux) linux kernel USER

  14. Memory layout (minemu) linux USER kernel minemu TAINT

  15. Memory layout (minemu) linux USER kernel minemu TAINT

  16. Memory layout (minemu) linux write to x USER kernel minemu TAINT

  17. Memory layout (minemu) linux write to x USER kernel minemu TAINT x+const

  18. Memory layout (minemu) taint data to linux user USER memory kernel minemu user TAINT data to taint memory

  19. Memory layout (minemu) taint data to linux user USER memory kernel minemu user TAINT data to taint memory

  20. Addressing shadow memory mov EAX, (EDX)

  21. Addressing shadow memory mov EAX, (EDX) address: EDX

  22. Addressing shadow memory mov EAX, (EDX) address: EDX taint: EDX+ const

  23. Addressing shadow memory mov EAX, (EDX+EBX*4)

  24. Addressing shadow memory mov EAX, (EDX+EBX*4) address: EDX+EBX*4

  25. Addressing shadow memory mov EAX, (EDX+EBX*4) address: EDX+EBX*4 taint: EDX+EBX*4+ const

  26. Addressing shadow memory push ESI

  27. Addressing shadow memory push ESI address: ESP

  28. Addressing shadow memory push ESI address: ESP taint: ESP+ const

  29. Is this slowness fundamental? minemu fast emulator memory layout use SSE registers to hold taint

  30. T aint propagation in SSE registers xmm5 scratch register scratch register xmm6 T(eax) T(eax) T(ecx) T(ecx) T(edx) T(edx) T(ebx) T(ebx) xmm7 T(esp) T(esp) T(ebp) T(ebp) T(esi) T(esi) T(edi) T(edi) 128-bit

  31. T aint propagation in SSE registers add EDX, x xmm5 scratch register scratch register xmm6 T(eax) T(eax) T(ecx) T(ecx) T(edx) T(edx) T(ebx) T(ebx) xmm7 T(esp) T(esp) T(ebp) T(ebp) T(esi) T(esi) T(edi) T(edi) 128-bit

  32. T aint propagation in SSE registers add EDX, x xmm5 scratch register scratch register xmm6 T(eax) T(eax) T(ecx) T(ecx) T(edx) T(edx) T(ebx) T(ebx) xmm7 T(esp) T(esp) T(ebp) T(ebp) T(esi) T(esi) T(edi) T(edi)

  33. T aint propagation in SSE registers add EDX, x xmm5 T(x) T(x) xmm6 T(eax) T(eax) T(ecx) T(ecx) T(edx) T(edx) T(ebx) T(ebx) xmm7 T(esp) T(esp) T(ebp) T(ebp) T(esi) T(esi) T(edi) T(edi) vector insert

  34. T aint propagation in SSE registers add EDX, x xmm5 T(x) T(x) xmm6 T(eax) T(eax) T(ecx) T(ecx) T(edx) T(edx) T(ebx) T(ebx) xmm7 T(esp) T(esp) T(ebp) T(ebp) T(esi) T(esi) T(edi) T(edi) or

  35. E ff ectiveness Application Type of vulnerability Security advisory Snort 2.4.0 Stack over fl ow CVE-2005-3252 Cyrus imapd 2.3.2 Stack over fl ow CVE-2006-2502 Samba 3.0.22 Heap over fl ow CVE-2007-2446 Memcached 1.1.12 Heap over fl ow CVE-2009-2415 Nginx 0.6.32 Buffer underrun CVE-2009-2629 Proftpd 1.3.3a Stack over fl ow CVE-2010-4221 Samba 3.2.5 Heap over fl ow CVE-2010-2063 Telnetd 1.6 Heap over fl ow CVE-2011-4862 Ncompress 4.2.4 Stack over fl ow CVE-2001-1413 Iwcon fi g V.26 Stack over fl ow CVE-2003-0947 Aspell 0.50.5 Stack over fl ow CVE-2004-0548 Htget 0.93 Stack over fl ow CVE-2004-0852 Socat 1.4 Format string CVE-2004-1484 Aeon 0.2a Stack over fl ow CVE-2005-1019 Exim 4.41 Stack over fl ow EDB-ID#796 Htget 0.93 Stack over fl ow Tipxd 1.1.1 Format string OSVDB-ID#12346

  36. Performance HTTP HTTPS

  37. Performance SPECINT 2006 2.4x overall 5 4 3 2 1 0 400.perlbench 401.bzip2 403.gcc 429.mcf 445.gobmk 456.hmmer 458.sjeng 462.libquantum 464.h264ref 471.omnetpp 473.astar 483.xalancbmk overall 3 2 1 0 gzip OpenSSH PostgreSQL MediaWiki (scp+sshd) (pgbench) (HTTPS)

  38. Limitations

  39. Limitations Doesn't prevent memory corruption, only acts when the untrusted data is used for arbitrary code execution.

  40. Limitations Tainted pointer dereferences ->some_field = useful_untainted_value; tainted_pointer

  41. Limitations Tainted pointer dereferences ->some_field = useful_untainted_value; tainted_pointer propagation can lead to false positives: dispatch_table[ ](); checked_input

  42. Limitations Taint whitewashing out = latin1_to_ascii[ ]; in

  43. Limitations Format string attacks: printf( ); "%65534s %123$hn" // Propagates taint in glibc printf( ); // Does not :-( "FillerFiller...%123$hn"

  44. Limitations Does not protect against non-control-flow exploits

  45. Limitations Does not protect against non-control-flow exploits void char char try_system( *username, *cmd) { user_rights = get_credentials(username); int 16 char buf[16] ; strcpy(buf, username); (user_rights & ) ALLOW_SYSTEM if system(cmd); else log_error( , buf); "user attempted login" %s }

  46. Limitations Does not protect against non-control-flow exploits void char char try_system( *username, *cmd) { user_rights = get_credentials(username); int 16 char buf[16] ; strcpy(buf, username); (user_rights & ) ALLOW_SYSTEM if system(cmd); else log_error( , buf); "user attempted login" %s }

  47. Limitations Does not protect against non-control-flow exploits void char char try_system( *username, *cmd) { user_rights = get_credentials(username); int 16 char buf[16] ; strcpy(buf, username); (user_rights & ) ALLOW_SYSTEM if system(cmd); else log_error( , buf); "user attempted login" %s }

Recommend


More recommend