deploying dynamic analyses and preventing compiler
play

Deploying Dynamic Analyses and Preventing Compiler Backdoors with - PowerPoint PPT Presentation

Deploying Dynamic Analyses and Preventing Compiler Backdoors with Multi-Version Execution Lus Pina l.pina@imperial.ac.uk Joint work with Cristian Cadar , Anastasios Andronidis , and John Regehr Imperial College London, UK University of


  1. Deploying Dynamic Analyses and Preventing Compiler Backdoors with Multi-Version Execution Luís Pina l.pina@imperial.ac.uk Joint work with Cristian Cadar , Anastasios Andronidis , and John Regehr Imperial College London, UK University of Utah, USA Runtime Verification beyond Monitoring (ArVi) ICT COST Action IC1402 Barcelona, March 10th, 2016

  2. Deploying Dynamic Analysis? Why? ./server 2

  3. Deploying Dynamic Analysis? Why? ./server Segmentation fault 3

  4. Deploying Dynamic Analysis? Why? ./server 4

  5. Deploying Dynamic Analysis? Why? valgrind --tool=memcheck server Invalid read of size 32 by 0x40B07FF4: memcpy (mc_replace_strmem.c:635) by 0x40AC751B: dtls1_process_heartbeat(SSL *s) (ssl/d1_both.c:1497) Address 0xBFFFF0E0 is not stack’d, malloc’d or free’d 5

  6. Deploying Dynamic Analysis? Why? valgrind --tool=memcheck server Invalid read of size 32 by 0x40B07FF4: memcpy (mc_replace_strmem.c:635) by 0x40AC751B: dtls1_process_heartbeat(SSL *s) (ssl/d1_both.c:1497) Address 0xBFFFF0E0 is not stack’d, malloc’d or free’d 7x–57x slowdown 6

  7. Deploying Dynamic Analysis? Why? gcc -fsanitize=address server.c -o server ./server ==2268==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x629000013748 at pc 0x7f228f5f0cfa READ of size 32768 at 0x629000013748 thread T0 #0 0x43d075 in memcpy /usr/include/bits/string3.h:51 #1 0x43d075 in tls1_process_heartbeat ssl/t1_lib.c:2586 #2 0x50e498 in ssl3_read_bytes ssl/s3_pkt.c:1092 #3 0x51895c in ssl3_get_message ssl/s3_both.c:457 ... ==2268== ABORTING 1.10x–2.67x slowdown 7

  8. N-Version Execution Server 8

  9. N-Version Execution Version 1 Server Coordinator Version 2 9

  10. N-Version Execution Version 1 Server Coordinator Version 2 10

  11. N-Version Execution Version 1 Server Coordinator Version 2 11

  12. N-Version Execution Version 1 Server Coordinator Version 2 12

  13. Varan Version 1 Coordinator Version 2 13

  14. Varan Version 1 Leader Coordinator Version 2 Follower 1 14

  15. Varan Version 1 Leader Version 2 Follower 1 15

  16. Varan Version 1 Leader Version 2 Follower 1 16

  17. Varan Version 1 Leader Version 2 Follower 1 17

  18. Varan Version 1 Leader Version 2 Follower 1 18

  19. Varan Version 1 Leader Version 2 Follower 1 19

  20. Varan Version 1 Leader Version 2 Follower 1 20

  21. Varan Version 1 Leader Version 2 Follower 1 21

  22. Varan Version 1 Leader Version 2 Follower 1 22

  23. Varan Version 1 Leader Version 2 Follower 1 23

  24. Varan System calls 01 02 while ( true ) { 03 04 sckt = accept(); // Wait for client 05 req = parse(read(skt)); // Handle request 06 07 file = open(req); 08 rsp = read(file); 09 10 11 // Send response 12 write(skt, rsp); 13 14 } 15 24

  25. Varan System calls 01 02 while ( true ) { 03 04 sckt = accept (); // Wait for client 05 req = parse( read (skt)); // Handle request 06 07 file = open (req); 08 rsp = read (file); 09 10 11 12 write (skt, rsp); // Send response 13 14 } 15 25

  26. Varan Version 1 Leader Version 2 Follower 1 26

  27. Varan Version 1 Leader Version 2 Follower 1 1x–1.17x slowdown 27

  28. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 28

  29. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 29

  30. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 30

  31. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 31

  32. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 32

  33. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 33

  34. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 34

  35. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 35

  36. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 36

  37. Varan + Dynamic Analysis Leader Native Follower 1 Sanitized 37

  38. Larger ringbuffer? Leader Native Follower 1 Sanitized 38

  39. Larger ringbuffer? Leader Native Follower 1 Sanitized 39

  40. Larger ringbuffer Interactive applications ◮ alias vim =’vx vim vim-asan’ ◮ alias htop =’vx htop htop-asan’ ◮ alias mutt =’vx mutt mutt-asan’ ◮ alias ssh =’vx ssh ssh-asan’ ◮ alias ls =’vx ls ls-asan’ 40

  41. Drop requests Leader Native Follower 1 41 Sanitized

  42. Drop requests Leader ? Native Follower 1 42 Sanitized

  43. Drop requests Leader ✓ ? Native Follower 1 43 Sanitized

  44. Drop requests Leader ? Native Follower 1 44 Sanitized

  45. Drop requests Leader ✗ ? Native Follower 1 45 Sanitized

  46. Experiment Check performance with varying drop rate on simple HTTP server ◮ Single process/thread ◮ gcc -fsanitize=address on follower ◮ BZip2 the response 46

  47. Results 219 # files downloaded in 30 seconds 196 HTTP Server HTTP Server Native HTTP Server Native No Varan Varan 47

  48. Results 219 219 # files downloaded in 30 seconds # files downloaded in 30 seconds 196 196 HTTP Server HTTP Server Native HTTP Server HTTP Server 93 82 Sanitized Native HTTP Server No Varan No Varan Varan Varan Sanitized 48

  49. Results 219 219 216 204 209 201 # files downloaded in 30 seconds # files downloaded in 30 seconds # files downloaded in 30 seconds 196 196 197 HTTP Server HTTP Server 182 141 Native 122 HTTP Server HTTP Server 109 99 93 82 Sanitized Native HTTP Server No Varan No Varan Varan Varan 2.75 13.3 23.7 32.1 38.8 50.3 65.6 82.5 88.3 97.0 Sanitized sanitized requests (%) 49

  50. Multi-version execution for security 50

  51. a or b? 01 int x = 1; 02 03 void f(void) { if (5 % (3 * x) + 2 != 4) 04 05 puts("a"); else 06 07 puts("b"); 08 } 51

  52. a or b? 01 int x = 1; 02 03 void f(void) { if (5 % (3 * x) + 2 != 4) 04 05 puts("a"); else 06 07 puts("b"); 08 } Clang 3.3 says a https://llvm.org/bugs/show_bug.cgi?id=15940 52

  53. sudo 01 htop 02 # command not found: htop 03 04 apt-get install htop 05 # Permission denied, are you root? 06 07 sudo apt-get install htop 08 # Installing... 09 10 htop 11 # running htop... 53

  54. sudo 01 whoami 02 # user 03 04 sudo whoami 05 # root 54

  55. sudo backdoor 01 gcc sudo.c -o sudo-gcc 02 clang sudo.c -o sudo-clang 03 04 ./sudo-gcc whomai 05 # user is not in the sudoers file. 06 # This incident will be reported. 07 08 ./sudo-clang whomai 09 # root 10 11 12 https://github.com/regehr/sudo-1.8.13/tree/ compromise/backdoor-info 55

  56. sudo backdoor 01 gcc sudo.c -o sudo-gcc 02 clang sudo.c -o sudo-clang 03 04 ./sudo-gcc whomai 05 # user is not in the sudoers file. 06 # This incident will be reported. 07 08 ./sudo-clang whomai 09 # root 10 11 vx ./sudo-gcc ./sudo-clang -- whoami 12 # divergence detected, terminating Cristian Cadar and Luís Pina and John Regehr, Multi-Version Execution Defeats a Compiler-Bug-Based Backdoor , http://blog.regehr.org/archives/1282 , 2015 56

  57. Undefined behavior 01 int saturating_add(int x, int y) { 02 if (x > 0 && y > 0 && x + y < 0) return INT_MAX; 03 if (x < 0 && y < 0 && x + y > 0) 04 return INT_MIN; 05 return x + y; 06 07 } 57

  58. Undefined behavior 01 int saturating_add(int x, int y) { 02 if (x > 0 && y > 0 && x + y < 0) return INT_MAX; 03 if (x < 0 && y < 0 && x + y > 0) 04 return INT_MIN; 05 return x + y; 06 07 } x y Result 1 2 3 58

  59. Undefined behavior 01 int saturating_add(int x, int y) { 02 if (x > 0 && y > 0 && x + y < 0) return INT_MAX; 03 if (x < 0 && y < 0 && x + y > 0) 04 return INT_MIN; 05 return x + y; 06 07 } x y Result 1 2 3 1000000000 1000000000 2000000000 59

  60. Undefined behavior 01 int saturating_add(int x, int y) { 02 if (x > 0 && y > 0 && x + y < 0) return INT_MAX; 03 if (x < 0 && y < 0 && x + y > 0) 04 return INT_MIN; 05 return x + y; 06 07 } x y Result 1 2 3 1000000000 1000000000 2000000000 2000000000 2000000000 2147483647 60

  61. Undefined behavior 01 int saturating_add(int x, int y) { 02 if (x > 0 && y > 0 && x + y < 0) return INT_MAX; 03 if (x < 0 && y < 0 && x + y > 0) 04 return INT_MIN; 05 return x + y; 06 07 } x y gcc -O0 gcc -O2 1 2 3 3 1000000000 1000000000 2000000000 2000000000 2000000000 2000000000 2147483647 -294967296 61

  62. Multi-version execution for security ◮ Prevents compiler backdoors ◮ Detects exploits based on undefined behavior ◮ Interesting programs: ◮ Sudo ◮ OpenSSH ◮ Password vaults ◮ GnuPG 62

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend