sandboxing and isolation
play

Sandboxing and isolation Deian Stefan Today Lecture objectives: - PowerPoint PPT Presentation

CSE 127: Computer Security Sandboxing and isolation Deian Stefan Today Lecture objectives: Understand basic principles for building secure systems Understand mechanisms used to build secure systems Principles of secure design


  1. CSE 127: Computer Security Sandboxing and isolation Deian Stefan

  2. Today Lecture objectives: • Understand basic principles for building secure systems • Understand mechanisms used to build secure systems

  3. Principles of secure design • Least privilege • Privilege separation • Complete mediation • Defense in depth • Fail safe/closed • Keep it simple

  4. Some photos from Smith’s A Contemporary Look at Saltzer and Schroeder’s 1975 Design Principles and Wikipedia (e.g., https://en.wikipedia.org/wiki/Beaumaris_Castle)

  5. The privilege separation recipe: • Break system into compartments • Ensure each compartment is isolated • Ensure each compartment runs with least privilege • Treat compartment interface as trust boundary

  6. How do break things up? Depends on the attacker model & isolation mechanism

  7. What isolation mechanisms can we use? • Hardware-based isolation: ➤ Physical machine, CPU modes (e.g., rings), virtual memory (MMU), memory protection unit (MPU), trusted execution environments, … • Software-based isolation: ➤ Language virtual machines (e.g., JavaScript), 
 software-based fault isolation (e.g., WebAssembly), 
 binary instrumentation, type systems, …

  8. What isolation mechanisms can we use? • Hardware-based isolation: ➤ Physical machine, CPU modes (e.g., rings), virtual memory (MMU), memory protection unit (MPU), trusted execution environments, … • Software-based isolation: ➤ Language virtual machines (e.g., JavaScript), 
 software-based fault isolation (e.g., WebAssembly), 
 binary instrumentation, type systems, …

  9. Example: Multi-user OS • In this system: ➤ Users can execute programs (process) ➤ Processes can access resources/assets • What’s the threat model? ➤

  10. What do we want? • Memory isolation ➤ Process should not be able to access another’s memory • Resource isolation ➤ Process should only be able to access certain resources

  11. What do we want? • Memory isolation ➤ Process should not be able to access another’s memory • Resource isolation ➤ Process should only be able to access certain resources

  12. UNIX permission model • Permissions granted according to UID ➤ A process may access files, network sockets, …. ➤ root (UID 0) can access everything • Each file has access control list (ACL) ➤ Grants permissions to users according to UIDs and roles (owner, group, other) ➤ Everything is a file!

  13. How does passwd work then?

  14. There is more than one UID…

  15. Process UIDs • Real user ID (RUID) ➤ Used to determine which user started the process ➤ Typically same as the user ID of parent process • Effective user ID (EUID) ➤ Determines the permissions for process ➤ Can be different from RUID (e.g., because setuid bit on the file being executed) • Saved user ID (SUID)

  16. setuid demystified (a bit) • A program can have a setiud bit set in its permissions • This impacts: fork and exec ➤ Typically inherit three IDs of parent ➤ If setuid bit set: use UID of file owner as EUID

  17. -rwsr-xr-x 1 root root 55440 Jul 28 2018 /usr/bin/passwd

  18. setuid demystified (a bit) • There are actually three bits: ➤ setuid - set EUID of process to ID of file owner ➤ setgid - set EG roup ID of process to GID of file ➤ sticky bit ➤ on: only file owner, directory owner, and root can 
 rename or remove file in the directory ➤ off: if user has write permission on directory, can 
 rename or remove files, even if not owner

  19. drwxrwxrwt 16 root root 700 Feb 6 17:38 /tmp/

  20. What do we want? • Memory isolation ➤ Process should not be able to access another’s memory • Resource isolation ➤ Process should only be able to access certain resources

  21. Process memory isolation • How are individual processes memory- isolated from each other? ➤ Each process gets its own virtual address space, managed by the operating system • Memory addresses used by processes are virtual addresses (VAs) not physical addresses (PAs) ➤ When and how do we do the translation? https://en.wikipedia.org/wiki/Virtual_memory#/media/File:Virtual_memory.svg

  22. When do we do the translation? • Every memory access goes through address translation (complete mediation) ➤ Load, store, instruction fetch • Who does the translation?

  23. When do we do the translation? • Every memory access goes through address translation (complete mediation) ➤ Load, store, instruction fetch • Who does the translation? ➤ The CPU’s memory management unit (MMU)

  24. How does the MMU translate VAs to PAs? • Using 64-bit ARM architecture as an example… • How do we translate arbitrary 64bit addresses? ➤ We can’t map at the individual address granularity! ➤ 64 bits * 2 64 (128 exabytes) to store any possible mapping

  25. Address translation (closer) 00…00 FF…FF … … … … … • Page: basic unit of translation ➤ Usually 4KB = 2 12 • How many page mappings? ➤ Still too big! ➤ 52 bits * 2 52 (208 petabytes)

  26. So what do we actually do? 00…00 FF…FF … … … … … 00 01 FF 00 01 FF 00 01 FF Multi-level page tables 00 01 FF 00 01 FF ➤ Sparse tree of page mappings 00 01 FF 00 01 FF ➤ Use VA as path through tree 00 01 FF ➤ Leaf nodes store PAs ➤ Root is kept in register so MMU can walk the tree

  27. How do we get isolation between processes? • Each process gets its own tree ➤ Tree is created by the OS ➤ Tree is used by the MMU when doing translation ➤ This is called “page table walking” ➤ When you context switch: OS needs to change root

  28. 
 Example of page table walk In reality, the full 64bit address space is not used. ➤ Working assumption: 48bit addresses Table[Page] address Byte index 47 11

  29. Page table walk 4KB … 64 bits 512 (2 9 ) entries … … Invalid Descriptor … … Table Descriptor address of next-level table Page Descriptor address of page … … … Translation Table Base Register 63..48 11..0 47 11

  30. Page table walk 4KB … 64 bits 512 (2 9 ) entries … … Invalid Descriptor … … Table Descriptor address of next-level table Page Descriptor address of page … … … Level 0 Translation Table Base Register 9 63..48 47..39 11..0 47 11

  31. Page table walk 4KB … 64 bits 512 (2 9 ) entries … … Invalid Descriptor … … Table Descriptor address of next-level table Page Descriptor address of page … … Level 1 … Level 0 Translation Table Base Register 9 9 63..48 47..39 38..30 11..0 47 11

  32. Page table walk 4KB … 64 bits 512 (2 9 ) entries … … Invalid Descriptor … … Level 2 Table Descriptor address of next-level table Page Descriptor address of page … … Level 1 … Level 0 Translation Table Base Register 9 9 9 63..48 47..39 38..30 29..21 11..0 47 11

  33. Page table walk 4KB … 64 bits 512 (2 9 ) entries Level 3 … … Invalid Descriptor … … Level 2 Table Descriptor address of next-level table Page Descriptor address of page … … Level 1 … Level 0 Translation Table Base Register 9 9 9 9 63..48 47..39 38..30 29..21 20..12 11..0 47 11

  34. Make it fast: Translation Lookaside Buffer

  35. Make it fast: Translation Lookaside Buffer • Small cache of recently translated addresses ➤ Before translating a referenced address, the processor checks the TLB • What does the TLB give us?

  36. Make it fast: Translation Lookaside Buffer • Small cache of recently translated addresses ➤ Before translating a referenced address, the processor checks the TLB • What does the TLB give us? ➤ Physical page corresponding to virtual page 
 (or that page isn’t present)

  37. Make it fast: Translation Lookaside Buffer • Small cache of recently translated addresses ➤ Before translating a referenced address, the processor checks the TLB • What does the TLB give us? ➤ Physical page corresponding to virtual page 
 (or that page isn’t present) ➤ Access control: if mapping allows the mode of access

  38. Access control • Not everything within a processes’ virtual address space is equally accessible • Page descriptors contain additional access control information ➤ Read, Write, eXecute permissions ➤ Who sets these bits? (The OS!)

  39. What should we do about TLB on context switch?

  40. What should we do about TLB on context switch? • Can flush the TLB (was most popular) • If HW has process-context identifiers (PCID), don’t need to flush: entries in TLB are partitioned by PCID

  41. What do we want? • Memory isolation ➤ Process should not be able to access another’s memory • Resource isolation ➤ Process should only be able to access certain resources

  42. Process isolation and virtual memory are powerful abstractions… where else are they used?

  43. Process isolation and virtual memory are powerful abstractions… where else are they used?

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