practical and effective sandboxing for non root users
play

Practical and Effective Sandboxing for Non-root users Taesoo Kim - PowerPoint PPT Presentation

Practical and Effective Sandboxing for Non-root users Taesoo Kim and Nickolai Zeldovich MIT CSAIL Why yet another sandbox for desktop applications? There are many existing sandbox mechanisms Chroot / Lxc (Unix/Linux) Jail (Freebsd)


  1. Practical and Effective Sandboxing for Non-root users Taesoo Kim and Nickolai Zeldovich MIT CSAIL

  2. Why yet another sandbox for desktop applications? ● There are many existing sandbox mechanisms – Chroot / Lxc (Unix/Linux) – Jail (Freebsd) – Seatbelt (Mac OS X) – VM? ... ● Difficult-to-use, requiring root privilege, or slow! 2

  3. TL;DR Our tool Unknown binary downloaded from the $ mbox -- ./downloaded-bin Internet ... Network Summary: > [11279] -> 173.194.43.51:80 > [11279] Create socket(PF_INET,...) > [11279] -> a00::2607:f8b0:4006:803:0 ... Sandbox Root: > /tmp/sandbox-11275 > N:/tmp/index.html [c]ommit, [d]iff, [i]gnore, [l]ist, [s]hell, [q]uit ?> 3

  4. TL;DR $ mbox -- ./downloaded-bin ... Network Summary: Where to connect? > [11279] -> 173.194.43.51:80 > [11279] Create socket(PF_INET,...) > [11279] -> a00::2607:f8b0:4006:803:0 ... Sandbox Root: > /tmp/sandbox-11275 > N:/tmp/index.html [c]ommit, [d]iff, [i]gnore, [l]ist, [s]hell, [q]uit ?> 4

  5. TL;DR $ mbox -- ./downloaded-bin ... Network Summary: > [11279] -> 173.194.43.51:80 > [11279] Create socket(PF_INET,...) > [11279] -> a00::2607:f8b0:4006:803:0 ... Protecting the host filesystem Sandbox Root: from modification > /tmp/sandbox-11275 > N:/tmp/index.html [c]ommit, [d]iff, [i]gnore, [l]ist, [s]hell, [q]uit ?> 5

  6. TL;DR $ mbox -- ./downloaded-bin ... Network Summary: > [11279] -> 173.194.43.51:80 > [11279] Create socket(PF_INET,...) > [11279] -> a00::2607:f8b0:4006:803:0 ... Sandbox Root: > /tmp/sandbox-11275 > N:/tmp/index.html [c]ommit, [d]iff, [i]gnore, [l]ist, [s]hell, [q]uit ?> Revision-control-system like interface 6

  7. TL;DR Without root privilege! $ mbox -- ./downloaded-bin ... Network Summary: > [11279] -> 173.194.43.51:80 > [11279] Create socket(PF_INET,...) > [11279] -> a00::2607:f8b0:4006:803:0 ... Sandbox Root: > /tmp/sandbox-11275 > N:/tmp/index.html [c]ommit, [d]iff, [i]gnore, [l]ist, [s]hell, [q]uit ?> 7

  8. Design overview ● Layered sandbox filesystem – Overlaying the host filesystem – Confining modification made by sandboxed processes – Persistent storage: in fact, just a regular directory ● System call interposition – Commodity OSes provide one for non-root users – Enabling a variety of applications: installing pkgs, restricting network, build/dev. env ... 8

  9. Design overview ● Layered sandbox filesystem – Overlaying the host filesystem – Confining modification made by sandboxed processes – Persistent storage: in fact, just a regular directory ● System call interposition – Commodity OSes provide one for non-root users – Enabling a variety of applications: installing pkgs, restricting network, build/dev. env ... 9

  10. Installing packages as normal user $ mbox -R -- apt-get install git (-R: emulate a fakeroot environment) ● Mbox provides a writable sandbox layer on top of the host filesystem – User owns the sandbox directory – Contain newly installed files, and package databases ● Mbox emulates a fakeroot environment – Use standard package managers without modification – Support: apt-get (Ubuntu), dpkg (Debian), pip (Python) 10

  11. Running unknown binary safely $ mbox -n -- ./downloaded-bin (-n: disable remote network accesses) ● Mbox protects the host filesystem from modifications ● Mbox restricts or monitors network accesses – Interpret socket-like system calls – Summarize network activity when terminated 11

  12. Checkpointing filesystem $ mbox -i -- emacs ~/.emacs (-i: enable interactive commit-mode) Host Filesystem ~/.emacs 12

  13. Checkpointing filesystem $ mbox -i -- emacs ~/.emacs (-i: enable interactive commit-mode) Sandbox Edit .emacs Read Write Sandbox FS ~/.emacs Host Filesystem ~/.emacs 13

  14. Checkpointing filesystem $ mbox -i -- emacs ~/.emacs (-i: enable interactive commit-mode) Sandbox Edit .emacs Read Write Read Sandbox FS ~/.emacs Host Filesystem ~/.emacs 14

  15. Checkpointing filesystem $ mbox -i -- emacs ~/.emacs (-i: enable interactive commit-mode) Sandbox Edit .emacs Read Write Read Sandbox FS ~/.emacs Commit Host Filesystem ~/.emacs 15

  16. Build/development environment $ tree linux-git ... Sandbox FS +--mm--mmap.c *.o +-mlock.c Host Filesystem linux-git $ mbox -r outdir -- make (-r dir: specify a sandbox directory) ● Mbox can separate out the generated obj files – make clean == rm -rf outdir ● Mbox can also be used for virtual dev. env. – Install packages with standard package managers 16

  17. Outline ● Motivation / use cases ● Layered sandbox filesystem ● System call interposition (using seccomp/BPF) ● Implementation / evaluation ● Related work ● Summary 17

  18. Sandbox filesystem supports copy-on-write Sandboxed process Sandbox filesystem Host .emacs filesystem 18

  19. Sandbox filesystem supports copy-on-write Sandboxed process open(“.emacs”, R) Read Sandbox filesystem Host .emacs filesystem 19

  20. Sandbox filesystem supports copy-on-write Sandboxed process open(“.emacs”, RW) Sandbox filesystem Host .emacs filesystem 20

  21. Sandbox filesystem supports copy-on-write Sandboxed process open(“.emacs”, RW) Sandbox filesystem .emacs Copy Host .emacs filesystem 21

  22. Sandbox filesystem supports copy-on-write Sandboxed process open(“.emacs”, RW) Read/Write Sandbox filesystem .emacs Copy Host .emacs filesystem 22

  23. Copy-on-write by rewriting path arguments Sandboxed process open(“.emacs”, RW) Read/Write Sandbox /tmp/sbox/ filesystem .emacs Copy Host .emacs filesystem 23

  24. Copy-on-write by rewriting path arguments /tmp/sbox/home/taesoo/.emacs Sandboxed process open(“.emacs”, RW) Read/Write Sandbox /tmp/sbox/ filesystem .emacs Copy Host .emacs filesystem 24

  25. All subsequent read/write should happen on the sandbox filesystem Sandboxed process open(“.emacs”, RW) ... open(“.emacs”, R) Read Sandbox filesystem .emacs Host .emacs filesystem 25

  26. All subsequent read/write should happen on the sandbox filesystem /tmp/sbox/home/taesoo/.emacs Sandboxed process open(“.emacs”, RW) ... open(“.emacs”, R) Read Sandbox /tmp/sbox/ filesystem .emacs Host .emacs filesystem 26

  27. Sandbox filesystem keeps track of deleted files Sandboxed process unlink(“.emacs”) ... Mbox Hashmap of deleted files .emacs Sandbox ... filesystem Host .emacs filesystem 27

  28. Sandbox filesystem keeps track of deleted files /tmp/sbox/home/taesoo/.emacs Sandboxed process unlink(“.emacs”) ... open(“.emacs”, R) Mbox Hashmap of Read deleted files .emacs Sandbox /tmp/sbox/ ... deleted filesystem .emacs Host .emacs filesystem 28

  29. Mbox doesn't have to interpose on every system call fd = open(“.emacs”, R) fd = open(“.emacs”, RW) read(fd, buf, size) write(fd, buf, size) ● After redirecting the path in open(), we don't have to interpose on read/write() system calls ● Mbox needs to interpose on 48 system calls getting a path argument to provide a layered sandbox filesystem 29

  30. Mechanism: system call interposition ● Ptrace is a common technique, but slow – Interpose entry/exit of every system call – Serialize system calls of child processes ● Using seccomp/BPF (>= Linux 3.5) – Seccomp is a security mechanism for isolating a process by allowing a certain set of system calls – Seccomp/BPF uses BPF (Berkeley Packet Filter) to specify rules for filtering system calls 30

  31. BPF program for interposition Mbox User space Kernel 31

  32. BPF program for interposition Mbox User space prctl() ① Kernel Seccomp/BPF BPF_STMT(LD, OFF_SYSCALL) BPF_JUMP(#open, 0, 1) BPF_STMT(RET, TRACE) … BPF_STMT(RET, ALLOWED) BPF 32

  33. BPF program for interposition Mbox User space prctl() ① Kernel Seccomp/BPF BPF_STMT(LD, OFF_SYSCALL) BPF_JUMP(#open, 0, 1) BPF_STMT(RET, TRACE) … BPF_STMT(RET, ALLOWED) BPF 33

  34. BPF program for interposition Sandboxed process Mbox exec() ② User space prctl() ① Kernel Seccomp/BPF BPF_STMT(LD, OFF_SYSCALL) BPF_JUMP(#open, 0, 1) BPF_STMT(RET, TRACE) … BPF_STMT(RET, ALLOWED) BPF 34

  35. BPF program for interposition Sandboxed process Mbox exec() ② User space prctl() open(“/a", RW) ① ③ Kernel Seccomp/BPF BPF_STMT(LD, OFF_SYSCALL) BPF_JUMP(#open, 0, 1) BPF_STMT(RET, TRACE) … BPF_STMT(RET, ALLOWED) BPF 35

  36. BPF program for interposition Sandboxed process Mbox exec() ② wait() User space prctl() open(“/a", RW) ① ③ Kernel Seccomp/BPF BPF_STMT(LD, OFF_SYSCALL) BPF_JUMP(#open, 0, 1) EVENT_SECCOMP ④ BPF_STMT(RET, TRACE) … BPF_STMT(RET, ALLOWED) BPF 36

  37. BPF program for interposition ptrace (PEEK/POKE) ⑤ “/a” “/tmp/sbox/a” → Sandboxed process Mbox exec() ② wait() User space prctl() open(“/a", RW) ① ③ Kernel Seccomp/BPF BPF_STMT(LD, OFF_SYSCALL) BPF_JUMP(#open, 0, 1) EVENT_SECCOMP ④ BPF_STMT(RET, TRACE) … BPF_STMT(RET, ALLOWED) BPF 37

  38. More story to come ... ● How to avoid time-of-check-to-time-of-use? ● How to avoid replicating OS state? ● ... Please, check the paper! 38

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