CSE 127: Computer Security
Isolation and side-channels
Deian Stefan
Some slides adopted from Nadia Heninger,John Mitchell, Dan Boneh, and Stefan Savage
Isolation and side-channels Deian Stefan Some slides adopted from - - PowerPoint PPT Presentation
CSE 127: Computer Security Isolation and side-channels Deian Stefan Some slides adopted from Nadia Heninger,John Mitchell, Dan Boneh, and Stefan Savage Today Lecture objectives: Understand basic principles for building secure systems
Deian Stefan
Some slides adopted from Nadia Heninger,John Mitchell, Dan Boneh, and Stefan Savage
Lecture objectives:
➤ Understand basic principles for building secure systems ➤ Understand mechanisms used in building secure
systems
➤ Understand a key limitation of these principles: side-
channels
➤ Use more than one security mechanism ➤ Fail securely/closed
➤ Use more than one security mechanism ➤ Fail securely/closed
➤ Separate the system into isolated least-privileged
compartments
➤ Mediate interaction between compartments
according to security policy
➤ Limit the damage due to any single compromised
component
Network User input File system Network User device File system
➤ Physical Machine ➤ Virtual Machine ➤ OS Process ➤ Library ➤ Function ➤ …
➤ Physical Machine ➤ Virtual Machine ➤ OS Process ➤ Library ➤ Function ➤ …
➤ Physical Machine ➤ Virtual Machine ➤ OS Process ➤ Library ➤ Function ➤ …
Virtual Machine Monitor … VM1 VM2 Host OS (optional)
➤ Used to mediate which files process can read/write
➤ To do anything useful (e.g., open socket, read file, etc.)
process must perform syscall into kernel; interpose on all syscalls and allow/deny according to policy
How are these used to to build secure (least-privileged and privilege separated) systems?
➤ A process may access files, network sockets, ….
➤ Grants permissions to users according to UIDs and
roles (owner, group, other)
➤ Everything is a file!
➤ same as the user ID of parent (unless changed) ➤ used to determine which user started the process
➤ from setuid bit on the file being executed, or syscall ➤ determines the permissions for process
➤ Used to save and restore EUID
➤ ID=0 for superuser root; can access any file
➤ Typically inherit three IDs of parent ➤ Exec of program with setuid bit: use owner of file
➤ setuid - set EUID of process to ID of file owner ➤ setgid - set EGroupID 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
drwxrwxrwt 16 root root 700 Feb 6 17:38 /tmp/
➤ Memory + file system isolation
➤ User grants access at install time + runtime
➤ Memory + file system
isolation
➤ Handles the privileged parts of browser (e.g.,
network requests, address bar, bookmarks, etc.)
➤ Handles untrusted, attacker
content: JS engine, DOM, etc.
➤ Communication restricted
to RPC to browser/GPU process
https://developers.google.com/web/updates/2018/09/inside-browser-part1
➤ VM that manages the GUI and other VMs
➤ Isolated domains that
handle untrusted data
➤ Communicates with other
VMs via firewall domain
➤ Apps run in isolation, in different VMs
Lecture objectives:
➤ Understand basic principles for building secure systems ➤ Understand mechanisms used in building secure
systems
➤ Understand a key limitation of these principles: side-
channels
(based on UID) can access files (and how)
resources (e.g., mnt, pid, net) between processes
➤ Core part of Docker and other’s containers
system calls and filter on their arguments
isolation all rely on memory isolation
isolation all rely on memory isolation
➤ If attacker can break memory isolation, they can often
hijack control flow!
➤ Each process gets its own virtual address
space, managed by the operating system
➤ When and how do we do the translation?
https://en.wikipedia.org/wiki/Virtual_memory#/media/File:Virtual_memory.svg
➤ Load, store, instruction fetch
➤ Load, store, instruction fetch
➤ The CPU’s memory management unit (MMU)
➤ We can’t map at the individual address granularity! ➤ 64 bits * 264 (128 exabytes) to store any possible
mapping
➤ Usually 4KB = 212
➤ Still too big! ➤ 52 bits * 252 (208 petabytes)
… … … … …
00…00 FF…FF
➤ Sparse tree of page mappings ➤ Use VA as path through tree ➤ Leaf nodes store PAs ➤ Root is kept in register so
MMU can walk the tree
… … … …
00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF
…
00…00 FF…FF
➤ 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
➤ Read, Write, eXecute permissions ➤ Who sets these bits? (The OS!)
*This changed due to Meltdown.
➤ Makes context switching fast!
*This changed due to Meltdown.
47 11 Table[Page] address Byte index
➤ Working assumption: 48bit addresses
… … … … … … …
Translation Table Base Register Invalid Descriptor Table Descriptor
address of next-level table
Page Descriptor
address of page
11..0 63..48
47 11
4KB 512 (29) entries 64 bits
… … …
Level 0
9
… … … …
Translation Table Base Register Invalid Descriptor Table Descriptor
address of next-level table
Page Descriptor
address of page
11..0 63..48 47..39
47 11
4KB 512 (29) entries 64 bits
Level 1 Level 0
9 9
Invalid Descriptor Table Descriptor
address of next-level table
Page Descriptor
address of page
11..0 63..48 38..30 47..39
47 11
4KB 512 (29) entries 64 bits
… … … … … … …
Translation Table Base Register
Level 1 Level 0
9 9
Invalid Descriptor Table Descriptor
address of next-level table
Page Descriptor
address of page
11..0 63..48 38..30 47..39
47 11
4KB 512 (29) entries 64 bits
… … … … … … …
Translation Table Base Register
Level 2
9
29..21
Level 1 Level 0
9 9
Invalid Descriptor Table Descriptor
address of next-level table
Page Descriptor
address of page
11..0 63..48 38..30 47..39
47 11
4KB 512 (29) entries 64 bits
… … … … … … …
Translation Table Base Register
Level 2
9
29..21
Level 3
9
20..12
➤ Before translating a referenced address, the
processor checks the TLB
➤ Before translating a referenced address, the
processor checks the TLB
➤ Physical page corresponding to virtual page
(or that page isn’t present)
➤ Before translating a referenced address, the
processor checks the TLB
➤ Physical page corresponding to virtual page
(or that page isn’t present)
➤ If page mapping allows the mode of access
(access control)
➤ VM/Guest VA to VM PA translation is not enough ➤ Why not?
➤ Allows VM OS to map guest PA to machine/host PA
without calling into VMM
➤ Allows VM OS to map guest PA to machine/host PA
without calling into VMM
➤ Allows VM OS to map guest PA to machine/host PA
without calling into VMM
➤ TLB entries are also tagged with VM ID (VPID)
➤ Allows VM OS to map guest PA to machine/host PA
without calling into VMM
➤ TLB entries are also tagged with VM ID (VPID)
➤ Allows VM OS to map guest PA to machine/host PA
without calling into VMM
➤ TLB entries are also tagged with VM ID (VPID)
➤ Similar to kernel: VMM is assigned VPID 0
Lecture objectives:
➤ Understand basic principles for building secure systems ➤ Understand mechanisms used in building secure
systems
➤ Understand a key limitation of these principles: side-
channels
➤ Kernels are huge and have a huge attack surface: syscalls ➤ Developers make mistakes—from forgetting to check and
sanitize values that come from user space to classical memory safety bugs.
➤ Kernels are huge and have a huge attack surface: syscalls ➤ Developers make mistakes—from forgetting to check and
sanitize values that come from user space to classical memory safety bugs.
➤ E.g., Meltdown breaks process isolation
➤ Kernels are huge and have a huge attack surface: syscalls ➤ Developers make mistakes—from forgetting to check and
sanitize values that come from user space to classical memory safety bugs.
➤ E.g., Meltdown breaks process isolation
➤ Cache-based side channels are the easiest/most popular
➤ Faster ➤ Smaller
https://en.wikipedia.org/wiki/Cache_hierarchy
➤ E.g., 64 bytes
➤ Each memory address is mapped
to a set of cache lines
➤ Evict!
https://en.wikipedia.org/wiki/CPU_cache
➤ “Just a performance optimization” ➤ Not isolated by process, VM, or privilege level
➤ What’s an example of this?
… VM1 VM2
➤ What are some examples of this?
➤ Not all rely on this but can often infer this
➤ Run the victim code several times and time it ➤ Evict cache line(s) ➤ Run the victim code again and time it
➤ We now know something about the addresses
accessed by victim code
➤ In some cases addresses are secret (e.g., AES)
➤ Access many memory locations so that previous
cache contents are replaced
➤ We now know something about the addresses
accessed by victim code
➤ We now know something about the addresses
accessed by victim code
(Only for shared memory)
➤ Hello from the Other Side: SSH over Robust Cache
Covert Channels in the Cloud by Clementine Maurice, Manuel Weber, Michael Schwarz, Lukas Giner, Daniel Gruss, Carlo Alberto Boano, Kay Romer, Stefan Mangard