5 Isolation Notes
5 Isolation Notes
5 Isolation Notes
These scribe notes were written by students in CSE 127 Winter 2021. They
have been lightly edited but may still contain some errors.
1 Intro
Today, we often need to run buggy or untrusted code. This code can be the
foundation for a number of things you use throughout any given day. This
includes applications and systems such as:
Because these issues can occur almost anywhere, systems have to be resilient
in the face of vulnerabilities and malicious users. If not, systems could shut down
or leak sensitive information to attackers.
There are several general principles of secure system design that can help
mitigate the effects of vulnerabilities from buggy and untrusted code. We will
go more in depth in each of these soon, but below is a basic overview of each
principle.
• Least Privilege
Ensure that components in a system run with the minimal privileges
required to complete a given task.
• Privilege Separation
Separate the levels of privilege between system components in order to
limit access.
1
• Complete Mediation
All communication across a security boundary should be controlled.
• Fail Safe/Closed
If part of the system fails, it should do so in such a way that the sys-
tem remains secure. (Stopping execution if there is an error is an
example).
• Defense In Depth
Deploy multiple countermeasures to make it more difficult for an attacker
to fully compromise a system.
• Keep It Simple
Build systems and trusted components that are simple enough to under-
stand and audit.
Each of these principles can be used together. Now, let’s dive up deeper into
each one.
2 Least Privilege
The core idea behind the Principle of Least Privilege is that users should only
have access to the data and resources that they need to perform their intended
tasks. Some examples of this are teaching faculty only being able to change
grades for classes they teach, or only letting employees with background checks
have access to classified documents.
3 Privilege Separation
To implement least privilege, we must be able to divide a system into separate
components with different access levels. A real life example of this would be the
security clearance system in the United States government, where documents
are classified at different security levels, and only those with the proper clear-
ance and need are able to access documents with a given clearance level. At the
operating system level, two common ideas are memory and resource isolation,
where processes should not be able to access each others memory, and should
only be able to access certain resources instead of the entire system’s available
resources. In Unix, processes are given their own virtual address space that is
managed by the operating system, and is unavailable to other processes with-
out the operating system’s assistance. This ensures memory isolation across
processes.
2
4 Principle of Complete Mediation
Privileges are the key to a resource, but the principle of complete mediation
requires the key to be checked before the keyholder can access the resource.
In other words, complete mediation necessitates a security checkpoint for all
accesses to scan through.
3
Lecture Example: CSE 127 Access Control Matrix [?]
4
The RUID is the user who started that process. A program retains the
User ID of the parent process. This can otherwise be known as the
UID of the process owner.
• 2. Effective User ID (EUID)
EUID specifies the permissions that the process runs under. The default
is that it is the same as the Real User ID, but it can be changed if
the setuid bit is set.
• 3. Saved User ID (SUID)
SUID is the EUID prior to any changes.
• setuidbit
If this bit is set, the EUID is the UID of the file owner rather than the
UID of the user who launched the program.
An example: -rwsr-xr-x 1 root root 54256 Mar 26 2019 /usr/bin/passwd
Users can run the passwd program to update their system passwords.
User passwords are stored together in the file /etc/passwd which
lists user information together with users’ hashed passwords. This
file needs to be protected from malicious users by only root having
read or write access to the file, so the owner of this file is root. In the
ls example above, you can see the “s” modifier which sets the setuid
bit on the /usr/bin/passwd executable. This means that when a
non-root user runs the passwd program to update their password,
the program runs with the permissions of the file owner (root), which
gives the program the necessary permissions to edit the /etc/passwd
file even though the non-root user does not.
In other scenarios, this bit might be set is when you want to lower
privileges. Applications such as web servers might need root privi-
leges for accessing port 80, but might want to run other programs
with lower privileges. Setting the bit and the program file owner
means that these programs can be run by the root server with re-
stricted privileges.
• 1. setuid bit
Sets the EUID of process to the owner UID of executed file.
5
• 2. setgid bit
Sets the group EUID of process to the group UID of executed file.
• 3. Sticky Bit
A. IF ON, only a file owner or root can rename or remove files in a
directory.
B. IF OFF, as long as user has write permission in the directory, they
can rename/remove files in directory even if not root/owner.
An example: drwxrwxrwt 10 root root 12288 Jan 18 20:55 tmp
Notice the ”t” permission set on the last bit. This allows only the owner
of a file in tmp to rename/remove the file. If Alice creates a file in
tmp called test, then Bob will not be able to create another file with
the same name. The test file has user owner and group owner for
Alice, therefore Bob does not have permissions to rename or remove
that file within /tmp.
10 Kernel Isolation
One example of privilege separation and complete mediation is the CPU/hardware
enforced isolation of the kernel. The kernel is isolated from user processes and
has separate page tables. This isolation is to ensure that the user space cannot
use privileged instructions. In addition, user programs who require kernel op-
erations are checked when they enter the kernel protection domain (i.e. system
calls). In some operating systems, even the user processes are isolated from each
other, only allowing verified message channels to communicate (e.g. Software
Isolated Processes in the Singularity operating system).
6
delete or overwrite files, one can use the commands: unlink, open, or write.
In order to communicate over the network, the application must use system
calls like socket, bind, connect, or send. System call interposition is an extra
layer of protection around a program that monitors system calls and prevents
a program from making unauthorized system calls. Even if a program behaves
maliciously, this would make it more difficult for the program to act maliciously
on the system.
14 Smartphone OS Design
How does the threat model for a smartphone differ from a desktop? Here are a
few possible threats that a smartphone designer might take into account:
In the smartphone context, assets to be protected could include user data, the
camera(s) and microphone(s) built into the device, and network communica-
tions. For the security properties that need to be preserved, these might include
preserving isolation across apps, protecting user privacy, giving users control
over permissions, and others.
Here are some additional orthogonal security facts about phones that we
discussed in class:
7
• Cell phones continuously broadcast unique identifiers associated with a
phone that are recorded by nearby cell towers or other entities with ap-
propriate antennas. This cell tower data can be used to track a phone’s
location to varying levels of granularity, and can be accessed by law en-
forcement with a search warrant.
• Cell phone applications can track user location at a very fine granular-
ity using a combination of cell tower location, GPS, wifi networks, and
other information. By default, Google keeps an extremely detailed record
of location data for all users.
8
What security properties do we want to preserve?
• That one corrupt component does not affect others.
• That one site cannot read the data from others.
• Web pages and tabs need to be isolated from each other.
Browser process
• The browser process handles the privileged parts of browser (e.g. network
requests, address bar, bookmarks)
Renderer process
• The renderer process handles untrusted attacker content: JS engine, DOM,
etc.
• Communication with the renderer process is restricted to remote proce-
dure calls, in order to prevent attackers to access privileged code, like in
the browser process.
9
There are many other processes like GPU, plugin, UI, and Storage. These
processes are also isolated in their sandboxes to prevent attacks on them or
other processes.
• Cloud compute customers (AWS, Azure, Google Cloud) are on the same
server and they need to seperate customers and their data
• Processes prevent malicous interactions in interprocess communication by
running every process in a virtual machine (Qubes OS: A desktop OS
where everything is a VM)
The hypervisor is the software interface that VMs use to communicate with
the host OS. Since it controls access to host OS resources, the hypervisor en-
forces isolation by mediating these requests. Additionally, there is hardware
support for virtualization. Intel has hardware support for x86 virtualization by
implementing Virtual Machine Manager (VMM) support in hardware so that
the operating system can be run in ring 0 of the kernel without requiring VMM
intervention for syscalls.
20 Hardware Isolation
Modern computer systems also contain hardware security mechanisms to enforce
different isolation properties. For example, Intel Software Guard eXtensons
(SGX) can run code in an enclave, an encrypted region of memory that is
only accessible to the CPU. This can protect program execution and memory
even from a malicous OS. Examples of when a program needs protection from
a malicous OS include:
10
of trust wherein code and code-verifying keys are baked into the boot ROM,
a read-only section of memory. Each step of the boot process verifies that the
bootloader and kernel are signed by Apple. This prevents a malicous user from
executing malicous code during the boot sequence of an Apple device, that is,
it prevents rooting/jailbreaking.
It is unreasonable to expect that any one of our defenses is flawless. The swiss
cheese model of pandemic measures shown in lecture gives us a good analogy.
You can think of each cheese as a layer of securing the system, the person as the
11
system, and the many viruses as the attacker’s toolbox. Any single defense may
be imperfect, but using multiple defenses together is likely to be more effective
against attacks.
26 Conclusion
In conclusion, there are a range of software and hardware isolation techniques to
secure systems. We covered sandboxing, access control, containers, virtualiza-
tion, secure enclaves, and physical isolation. There are a variety of approaches
and techniques, which are chosen based on the threat model, costs, and system
usage. Overall, the lesson to take away from all of this is that complete isolation
is often inappropriate and in real systems it is often sufficient for applications
to communicate through regulated interfaces.
References
[1] Nadia Heninger. Isolation and secure design. http://cseweb.ucsd.edu/
classes/wi21/cse127-a/slides/5-isolation.pdf. Accessed: 2021-02-
13.
[2] Mariko Kosaka. Inside look at modern web browser (part 1). https://
developers.google.com/web/updates/2018/09/inside-browser-part1.
Accessed: 2021-02-13.
[3] Wikipedia. Swiss cheese model. https://en.wikipedia.org/wiki/Swiss_
cheese_model. Accessed: 2021-02-13.
12