Isolation: The Confinement Principle
Isolation: The Confinement Principle
Isolation: The Confinement Principle
Isolation
The confinement
principle
Dan Boneh
Running untrusted code
We often need to run buggy/unstrusted code:
– programs from untrusted Internet sites:
• apps, extensions, plug-ins, codecs for media player
– honeypots
app 1 app 2
⇒ difficult to manage
Dan Boneh
Approach: confinement
Confinement: ensure misbehaving app cannot harm rest of system
Can be implemented at many levels:
– Virtual machines: isolate OS’s on a single machine
app1 app2
OS1 OS2
process 1
process 2
Operating System
Dan Boneh
Approach: confinement
Confinement: ensure misbehaving app cannot harm rest of system
Can be implemented at many levels:
– Threads: Software Fault Isolation (SFI)
• Isolating threads sharing same address space
Dan Boneh
Implementing confinement
Key component: reference monitor
– Mediates requests from applications
• Implements protection policy
• Enforces isolation and confinement
– Must always be invoked:
• Every application request must be mediated
– Tamperproof:
• Reference monitor cannot be killed
• … or if killed, then monitored process is killed too
– Small enough to be analyzed and validated
Dan Boneh
A old example: chroot
Often used for “guest” accounts on ftp sites
• jailkit project: auto builds files, libs, and dirs needed in jail env
• jk_init: creates jail environment
• jk_check: checks jail env for security problems
• checks for any modified programs,
• checks for world writable directories, etc.
• jk_lsh: restricted shell to be used inside jail
• Reboot system
Dan Boneh
Freebsd jail
Stronger mechanism than simple chroot
Dan Boneh
Problems with chroot and jail
Coarse policies:
– All or nothing access to parts of file system
– Inappropriate for apps like a web browser
• Needs read access to files outside jail
(e.g. for sending attachments in Gmail)
System Call
Interposition
Dan Boneh
System call interposition
Observation: to damage host system (e.g. persistent changes)
app must make system calls:
– To delete/overwrite files: unlink, open, write
– To do network attacks: socket, bind, connect, send
Implementation options:
– Completely kernel space (e.g. GSWTK)
– Completely user space (e.g. program shepherding)
– Hybrid (e.g. Systrace)
Dan Boneh
Initial implementation (Janus) [GWTB’96]
open(“/etc/passwd”, “r”)
OS Kernel
Monitor kills application if request is disallowed
Dan Boneh
Complications cd(“/tmp”)
open(“passwd”, “r”)
• If app forks, monitor must also fork
– forked monitor monitors forked app cd(“/etc”)
open(“passwd”, “r”)
sys-call systrace
gateway
permit/deny OS Kernel
• systrace only forwards monitored sys-calls to monitor (efficiency)
A delegation architecture:
user space
monitored
agent
application policy file
open(“etc/passwd”, “r”) for app
• Two sandboxes:
– outer sandbox: restricts capabilities using system call interposition
Isolation via
Virtual Machines
Dan Boneh
Virtual Machines
VM2 VM1
Apps Apps
Guest OS 2 Guest OS 1
Virtual Machine Monitor (VMM)
Host OS
Hardware
Example: NSA NetTop
single HW platform used for both classified and unclassified data
Dan Boneh
Why so popular now?
VMs in the 1960’s:
– Few computers, lots of users
– VMs allow many users to shares a single computer
Classified VM Public VM
secret covert
malware
doc listener
channel
VMM
Dan Boneh
An example covert channel
Both VMs use the same underlying hardware
At 1:00am listener does CPU intensive calc. and measures completion time
b=1 completion-time > threshold
Dan Boneh
VMM Introspection: [GR’03]
Dan Boneh
Intrusion Detection / Anti-virus
Runs as part of OS kernel and user space process
– Kernel root kit can shutdown protection system
– Common practice for modern malware
malware Guest OS
IDS VMM
Hardware
Dan Boneh
Sample checks
Stealth root-kit malware:
– Creates processes that are invisible to “ps”
– Opens sockets that are invisible to “netstat”
Dan Boneh
Isolation
Subvirting VM
Isolation
Dan Boneh
Subvirt [King et al. 2006]
Virus idea:
– Once on victim machine, install a malicious VMM
– Virus hides in VMM
– Invisible to virus detector running inside VM
anti-virus
anti-virus
OS
OS VMM and virus
HW HW
Dan Boneh
The MATRIX
Dan Boneh
Dan Boneh
VM Based Malware (blue pill virus)
• VMBR: a virus that installs a malicious VMM (hypervisor)
Dan Boneh
VMM Detection
Can an OS detect it is running on top of a VMM?
Applications:
– Virus detector can detect VMBR
– Normal virus (non-VMBR) can detect VMM
• refuse to run to avoid reverse engineering
– Software that binds to hardware (e.g. MS Windows) can
refuse to run on top of VMM
– DRM systems may refuse to run on top of VMM
Dan Boneh
VMM detection (red pill techniques)
• VM platforms often emulate simple hardware
– VMWare emulates an ancient i440bx chipset
… but report 8GB RAM, dual CPUs, etc.
Dan Boneh
Isolation
Software Fault
Isolation
Dan Boneh
Software Fault Isolation [Whabe et al., 1993]
Dan Boneh
Software Fault Isolation
SFI approach:
– Partition process memory into segments
app #1 app #2
Solution:
jmp guard must ensure [addr] does not bypass load guard
Dan Boneh
Cross domain calls
caller callee
domain domain
call stub draw:
call draw
return
br addr br addr
br addr ret stub br addr
br addr br addr
• Only stubs allowed to make cross-domain jumps
• Jump table contains allowed exit points
– Addresses are hard coded, read-only segment
Dan Boneh
SFI Summary
• Shared memory: use virtual memory hardware
– map same physical page to two segments in addr space
• Performance
– Usually good: mpeg_play, 4% slowdown
Dan Boneh