Ossecurity
Ossecurity
CHAPTER 4
Example 4.1. UNIX mode bits are of the form {owner bits, group bits, others bits} where each
element in the tuple consists of a read bit, a write bit, and an execute bit. The mode bits:
rwxr--r--
mean that a process with the same UID as the owner can read, write, or execute the file, a
process with a GID or supplementary group that corresponds to the file’s group can read the file,
and others can also only read the file.
3 A process’s user identity is actually represented by a set of UIDs for effective, real, and file system access.These details are important
to preventing vulnerabilities, see Section 4.2.4, but for clarity we defer their definition until that section.
4.2. UNIX SECURITY 43
Suppose a set of files have the following owners, groups, and others mode bits as described
below:
Then, processes running as alice with the group faculty can read, write, or execute foo and
baz, but only read bar. For bar, Alice does not match the UID (bob), nor have the associated group
(students). The process has the appropriate owner to gain all privileges for foo and the appropriate
group to gain privileges to baz.
As described above, the UNIX protection system is a discretionary access control system.
Specifically, this means that a file’s mode bits, owner UID, or group GID may be changed by any
UNIX processes run by the file’s owner (i.e., that have the same UID as the file owner). If we trust
all user processes to act in the best interests of the user, then the user’s security goals can be enforced.
However, this is no longer a reasonable assumption. Nowadays, users run a variety of processes, some
of which may be supplied by attackers and others may be vulnerable to compromise from attackers,
so the user will have no guarantee that these processes will behave consistently with the user’s security
goals. As a result, a secure operating system cannot use discretionary access control to enforce user
security goals.
Since discretionary access control permits users to change their files owner UID and group
GID in addition to the mode bits, file labeling is also discretionary. A secure protection system
requires a mandatory labeling state, so this is another reason that UNIX systems cannot satisfy the
requirements of a secure operating system.
UNIX processes are labeled by trusted services from a set of labels (i.e., user UIDs and group
GIDs) defined by trusted administrators, and child processes inherit their process identity from
their parent. This mandatory approach to labeling processes with identities would satisfy the secure
protection system requirements, although it is rather inflexible.
Finally, UNIX mode bits also include a specification for protection domain transitions, called
the setuid bit. When this bit is set on a file, any process that executes the file with automatically
perform a protection domain transition to the file’s owner UID and group GID. For example, if a
root process sets the setuid bit on a file that it owns, then any process that executes that file will
run under the root UID. Since the setuid bit is a mode bit, it can be set by the file’s owner, so it
is also managed in a discretionary manner. A secure protection state requires a mandatory transition
state describe all protection domain transitions, so the use of discretionary setuid bits is insufficient.
4There are similar commands, such as setgid and setgroups, to change the GID and supplementary groups, respectively.
4.2. UNIX SECURITY 45
such as login or sshd, can change the identity of a process. For example, when a user logs in, the
login program must change the process identity of the user’s first process, her shell, to the user to
ensure correct access control. In the second case, the use of the setuid bit on a file is typically used
to permit a lower privileged entity to execute a higher privileged program, almost always as root.
For example, when a user wishes to change her password, she uses the passwd program. Since the
passwd program modifies the password file, it must be privileged, so a process running with the
user’s identity could not change the password file. The setuid bit on the root-owned, passwd
executable’s file is set, so when any user executes passwd, the resultant process identity transitions
to root. While the identity transition does not impact the user’s other processes, the writers of the
passwd program must be careful not to allow the program to be tricked into allowing the user to
control how passwd uses its additional privileges.
UNIX also has a couple of mechanisms that enable a user to run a process with a reduced
set of permissions. Unfortunately, these mechanisms are difficult to use correctly, are only available
to root processes, and can only implement modest restrictions. First, UNIX systems have a special
principal nobody that owns no files and belongs to no groups. Therefore, a process’s permissions
can be restricted by running as nobody since it never has owner or group privileges. Unfortunately,
nobody, like all subjects, has others privileges. Also, since only root can do a setuid only a
superuser process can change the process identity to nobody. Second, UNIX chroot can be used
to limit a process to a subtree of the file system [262]. Thus, the process is limited to only its rights
to files within that subtree. Unfortunately, a chroot environment must be setup carefully to prevent
the process from escaping the limited domain. For example, if an attacker can create /etc/passwd
and /etc/shadow files in the subtree, she can add an entry for root, login as this root, and escape
the chroot environment (e.g., using root access to kernel memory). Also, a chroot environment
can only be setup by a root process, so it is not usable to regular system users. In practice, neither
of these approaches has proven to be an effective way to limit process permissions.
1. Complete Mediation: How does the reference monitor interface ensure that all security-
sensitive operations are mediated correctly?
The UNIX reference monitor interface consists of hooks to check access for file or inode
permission on some system calls. The UNIX reference monitor interface authorizes access to
the objects that the kernel will use in its operations.
A problem is that the limited set of UNIX operations (read, write, and execute) is not expressive
enough to control access to information. As we discussed in Section 4.2.2, UNIX permits
modifications to files without the need for write permission (e.g., fcntl).
46 CHAPTER 4. SECURITY IN ORDINARY OPERATING SYSTEMS
2. Complete Mediation: Does the reference monitor interface mediate security-sensitive oper-
ations on all system resources?
UNIX authorization does not provide complete mediation of all system resources. For some
objects, such as network communications, UNIX itself provides no authorization at all.
3. Complete Mediation: How do we verify that the reference monitor interface provides com-
plete mediation?
Since the UNIX reference monitor interface is placed where the security-sensitive operations
are performed, it difficult to know whether all operations have been identified and all paths
have been mediated. No specific approach has been used to verify complete mediation.
4. Tamperproof: How does the system protect the reference monitor, including its protection
system, from modification?
The reference monitor and protection system are stored in the kernel, but this does not guar-
antee tamper-protection. First, the protection system is discretionary, so it may be tampered
by any running process. Untrusted user processes can modify permissions to their user’s data
arbitrarily, so enforcing security goals on user data is not possible.
Second, the UNIX kernel is not as protected from untrusted user processes as the Multics kernel
is. Both use protection rings for isolation, but the Multics system also explicitly specifies gates
for verifying the legality of the ring transition arguments. While UNIX kernels often provide
procedures to verify system call arguments, such procedures are may be misplaced.
Finally, user-level processes have a variety of interfaces to access and modify the kernel itself
above and beyond system calls, ranging from the ability to install kernel modules to special
file systems (e.g., /proc or sysfs) to interfaces through netlink sockets to direct access to
kernel memory (e.g., via the device file/dev/kmem). Ensuring that these interfaces can only
be accessed by trusted code has become impractical.
5. Tamperproof: Does the system’s protection system protect the trusted computing base pro-
grams?
In addition to the kernel, the UNIX TCB consists of all root processes, including all pro-
cesses run by a user logged in as a root user. Since these processes could run any program,
guaranteeing the tamper-protection of the TCB is not possible. Even ignoring root users, the
amount of TCB code is far too large and faces far too many threats to claim a tamperproof
trusting computing base. For example, several root processes have open network ports that
may be used as avenues to compromise these processes. If any of these processes is compro-
mised, the UNIX system is effectively compromised as there is no effective protection among
root processes.
4.2. UNIX SECURITY 47
Also, any root process can modify any aspect of the protection system. As we show below,
UNIX root processes may not be sufficiently trusted or protected, so unauthorized modifi-
cation of the protection system, in general, is possible. As a result, we cannot depend on a
tamperproof protection system in a UNIX system.
7. Verifiable: Does the protection system enforce the system’s security goals?
Verifiability enforcement of security goals is not possible because of the lack of complete
mediation and the lack of tamperproofing. Since we cannot express a policy rich enough to
prevent unauthorized data leakage or modification, we cannot enforce secrecy or integrity
security goals. Since we cannot prove that the TCB is protected from attackers, we cannot
prove that the system will be remain able to enforce our intended security goals, even if they
could be expressed properly.
Network-facing Daemons UNIX has several root (i.e., TCB) processes that maintain network
ports that are open to all remote parties (e.g., sshd, ftpd, sendmail, etc.), called network-facing
daemons. In order to maintain the integrity of the system’s trusted computing base, and hence
achieve the reference monitor guarantees, such process must protect themselves from such input.
However, several vulnerabilities have been reported for such processes, particularly due to buffer
overflows [232, 318], enabling remote attackers to compromise the system TCB. Some of these
daemons have been redesigned to remove many of such vulnerabilities (e.g., Postfix [317, 73] as a
replacement for sendmail and privilege-separated SSH [251]), but a comprehensive justification of
integrity protection for the resulting daemons is not provided. Thus, integrity protection of network-
facing dameons in UNIX is incomplete and ad hoc.
Further, some network-facing daemons, such as remote login daemons (e.g., telnet, rlogin,
etc.) ftpd, and NFS, puts an undo amount of trust in the network. The remote login daemons and
48 CHAPTER 4. SECURITY IN ORDINARY OPERATING SYSTEMS
ftpd are notorious for sending passwords in the clear. Fortunately, such daemons have been obsoleted
or replaced by more secure versions (e.g., vsftpd for ftpd). Also, NFS is notorious for accepting
any response to a remote file system request as being from a legitimate server [38]. Network-facing
daemons must additionally protect the integrity of their secrets and authenticate the sources of
remote data whose integrity is crucial to the process.
Rootkits Modern UNIX systems support extension via kernel modules that may be loaded dy-
namically into the kernel. However, a malicious or buggy module may enable an attacker to execute
code in the kernel, with full system privileges. A variety of malware packages, called rootkits, have
been created for taking advantage of kernel module loading or other interfaces to the kernel avail-
able to root processes. Such rootkits enable the implementation of attacker function and provide
measures to evade from detection. Despite efforts to detect malware in the kernel [244, 245], such
rootkits are difficult to detect, in general, [17].
Environment Variables UNIX systems support environment variables, system variables that are
available to processes to convey state across applications. One such variable is LIBPATH whose value
determines the search order for dynamic libraries. A common vulnerability is that an attacker can
change LIBPATH to load an attacker-provided file as a dynamic library. Since environment variables
are inherited when a child process is created, an untrusted process can invoke a TCB program
(e.g., a program file which setuid’s to root on invocation, see Section 4.2.2) under an untrusted
environment. If the TCB process depends on dynamic libraries and does not set the LIBPATH itself,
it may be vulnerable to running malicious code. As many TCB programs can be invoked via setuid,
this is a widespread issue.
Further,TCB programs may be vulnerable to any input value supplied by an untrusted process,
such as malicious input arguments. For example, a variety of program permit the caller to define
the configuration file of the process. A configuration file typically describes all the other places that
the program should look for inputs to describe how it should function, sometimes including the
location of libraries that it should use and the location of hosts that provide network information. If
the attack can control the choice of a program’s configuration file, she often has a variety of ways to
compromise the running process. Any TCB program must ensure their integrity regardless of how
they are invoked.
Shared Resources If TCB processes share resources with untrusted processes, then they may be
vulnerable to attack. A common problem is the sharing of the /tmp directory. Since any process can
create files in this directory, an untrusted process is able to create files in this directory and grant
other processes, in particular a TCB process, access to such files as well. If the untrusted process
can guess the name of TCB process’s /tmp file, it can create this file in advance, grant access to the
TCB process, and then have access itself to a TCB file. TCB processes can prevent this problem
4.3. WINDOWS SECURITY 49
by checking for the existence of such files upon creation (e.g., using the O_CREAT flag). However,
programmers have been prone to forget such safeguards. TCB process must take care when using
any objects shared by untrusted processes.
5 We simply refer to this as the Windows protection system for the rest of the chapter.
6 Remember that access control lists are stored with the object, and state which subjects can access that object.
4.3. WINDOWS SECURITY 51
Thus, Windows uses negative access rights, whereas UNIX does not, generating some differences
in their authorization mechanisms.
Example 4.2. Figure 4.1 shows an example ACL for an object foo. foo’s ACL contains three
ACEs. The field principal SID specifies the SID to which the ACE applies. These ACE apply to
Privileges None
Privileges None
Access Control Entry 3
Figure 4.1: Windows Access Control Lists (ACLs) and process tokens for Examples 4.2 and 4.3
the SIDs Alice, Bob, and Group1. The other two important fields in an ACE are its type (grant
or deny) and the access rights (a bitmask). The Alice and Bob ACEs grant rights, and the Group1
ACE denies access to certain rights. The access rights bitmask is interpreted based on the object type
field in the ACE. We describe how the ACL is used in authorization in the next section.
Example 4.3. Returning to Example 4.2 above, the ACEs of the object’s ACL are ordered as shown
in Figure 4.1. Note that the ACE field for access rights is really a bitmap, but we list the operations to
simplify understanding. Further, we specify the process tokens for two processes, P1 and P2. Below,
we show the authorization results for a set of queries by these processes for the target object.
P1, read: ok
P1, read, write: no
P2: read: ok
P2: read, write: no
Both P1 and P2 can read the target object, but neither can write the object. P1 cannot write
the object because the P1 token include Group1 which matches the deny ACE for writing. P2
cannot write the object because the ACE for Bob does not permit writing.
Mediation in Windows is determined by a set of object managers. Rather than a monolithic set
of system calls to access homogeneous objects (i.e., files) in UNIX, each object type in Windows has
an object manager that implements the functions of that type. While the Windows object managers
all run in the kernel, the object managers are independent entities. This can be advantageous from
a modularity perspective, but the fact that object managers may extend the system presents some
challenges for mediation. We need to know that each new object manager mediates all operations
and determines the rights for those operations correctly. There is no process for ensuring this in
Windows.
In Windows, the trusted computing base consists of all system services and processing running
as a trusted user identity, such as Administrator 8 . Windows provides a setuid-like mechanism
for invoking Windows Services that run at a predefined privilege, at least sufficient to support all
clients. Thus, vulnerabilities in such services would lead to system compromise. Further, the ease
of software installation and complexity of the discretionary Windows access control model often
result in users running as Administrator. In this case, any user program would be able to take
control of the system. This is often a problem on Windows systems. With the release of Windows
Vista, the Windows model is extended to prevent programs downloaded from the Internet from
7 It may take multiple ACEs to grant all the requested operations, so this refers to the ACE that grants whatever remaining
operations were requested.
8 In addition, these services and processes may further depend on non-Administrator processes, which would make the system
TCB even less secure.
4.3. WINDOWS SECURITY 53
automatically being able to write Windows applications and the Windows system, regardless of the
user’s process identity [152]. While this does provide some integrity protection, it does not fully
protect the system’s integrity. It prevents low integrity processes from writing to high integrity files,
but does not prevent invocation, malicious requests, or spoofing the high integrity code into using
a low integrity file. See Chapter 5 for the integrity requirements of a secure operating system.
Windows also provides a means for restricting the permissions available to a process flexibly,
called restricted contexts. By defining a restricted context for a process, the permissions necessary to
perform an operation must be available to both the process using its token and to the restricted
context. That is, the permissions of a process running in a restricted context are the intersection of the
restricted context and the process’s normal permissions. Since a restricted context may be assigned an
arbitrary set of permissions, this mechanism is much more flexible than the UNIX option of running
as nobody. Also, since restricted contexts are built into the access control system, it less error-prone
than and chroot. Nonetheless, restricted contexts are difficult for administrators to define correctly,
so they are not used commonly, and not at all by the user community.
In Windows, mediation is provided by object managers. Without the source code, it is difficult
to know where mediation is performed, but we would presume that object managers would
authorize the actual objects used in the security-sensitive operations, similarly to UNIX.
2. Complete Mediation: Does the reference monitor interface mediate security-sensitive oper-
ations on all system resources?
Object managers provide an opportunity for complete mediation, but provide no guarantee of
mediation. Further, the set of managers may be extended, resulting in the addition of potentially
insecure object managers. Without a formal approach that defines what each manager does
and how it is to be secured, it will not be possible to provide a guarantee of complete mediation.
3. Complete Mediation: How do we verify that the reference monitor interface provides com-
plete mediation?
As for UNIX, no specific approach has been used to verify complete mediation.
54 CHAPTER 4. SECURITY IN ORDINARY OPERATING SYSTEMS
4. Tamperproof: How does the system protect the reference monitor, including its protection
system, for modification?
Windows suffers from the same problems as UNIX when it comes to tampering. First, the
protection system is discretionary, so it may be tampered by any running process. Untrusted
user processes can modify permissions to their user’s data arbitrarily, so enforcing security goals
on user data is not possible. Since users have often run as Administrator to enable ease of
system administration, any aspect of the protection system may be modified.
Second, there are limited protections for the kernel itself. Like UNIX, a Windows kernel can
be modified through kernel modules. In Microsoft Vista, a code signing process can be used
to determine the certifier of a kernel module (i.e., the signer, not necessarily the writer of
the module). Of course, the administrator (typically an end user) must be able to determine
the trustworthiness of the signer. Security procedures that depend on the decision-making of
users are often prone to failure, as users are often ignorant of the security implications of such
decisions. Also, like UNIX, the Windows kernel also does not define protections for system
calls (e.g., Multics gates).
5. Tamperproof: Does the system’s protection system protect the trusted computing base pro-
grams?
The TCB of Windows system is no better than that of UNIX. Nearly any program may be
part of the Windows TCB, and any process running these programs can modify other TCB
programs invalidating the TCB.
Like UNIX, any compromised TCB process can modify the protection system invalidating
the enforcement of system security goals, and modify the Windows kernel itself through the
variety of interfaces provided to TCB processes to access kernel state.
Unlike UNIX, Windows provides APIs to tamper with other processes in ways that UNIX
does not. For example, Windows provides the CreateRemoteThread function, which enables
a process to initiate a thread in another process [207]. Windows also provides functions for
writing a processes memory via OpenProcess and WriteProcessMemory, so one process can
also write the desired code into that process prior to initiating a thread in that process. While
all of these operations require the necessary access rights to the other process, usually requiring
a change in privileges necessary for debugging a process (via the AdjustTokenPrivileges).
While such privileges are typically only available to processes under the same SID, we must
verify that these privileges cannot be misused in order to ensure tamper-protection of our
TCB.
6. Verifiable: What is basis for the correctness of the system’s trusted computing base?
As for UNIX, any basis for correctness is informal. Windows also has an unbounded TCB
and extensible kernel system that prevent any effective formal verification.
4.3. WINDOWS SECURITY 55
7. Verifiable: Does the protection system enforce the system’s security goals?
The general Windows model enables any permission combination to be specified, but no
particular security goals are defined in the system. Thus, it is not possible to tell whether a
system is secure. Since the model is more complex than the UNIX model and can be extended
arbitrarily, this makes verifying security even more difficult.
The Windows Registry The Windows Registry is a global, hierarchical database to store data for
all programs [206]. When a new application is loaded it may update the registry with application-
specific, such as security-sensitive information such as the paths to libraries and executables to
be loaded for the application. While each registry entry can be associated with a security context
that limits access, such limitations are generally not effectively used. For example, the standard
configuration of AOL adds a registry entry that specifies the name of a Windows library file (i.e.,
DLL) to be loaded with AOL software [120]. However, the permissions were set such that any user
could write the entry.
This use of the registry is not uncommon, as vendors have to ensure that their software will
execute when it is downloaded. Naturally, a user will be upset if she downloads some newly-purchased
software, and it does not execute correctly because it could not access its necessary libraries. Since the
application vendors cannot know the ad hoc ways that a Windows system is administered, they must
turn on permissions to ensure that whatever the user does the software runs. If the registry entry
is later used by an attacker to compromise the Windows system, that is not really the application
vendor’s problem—selling applications is.
Administrator Users We mentioned in the Windows security evaluation that traditionally users
ran under the identity Administrator or at least with administrative privileges enabled. The reason
for this is similar to the reason that broad access is granted to registry entries: the user also wants to be
sure that they can use what function is necessary to enable the system to run. If the user downloads
some computer game, the user would need special privileges to install the game, and likely need
special privileges to run the device-intensive game program. The last thing the user wants is to have
to figure out why the game will not run, so enabling all privileges works around this issue.
UNIX systems are generally used by more experienced computer users who understand the
difference between installing software (e.g., run sudo) and the normal operation of the computer. As
56 CHAPTER 4. SECURITY IN ORDINARY OPERATING SYSTEMS
a result, the distinction between root users and sudo operations has been utilized more effectively
in UNIX.
Enabled By Default Like users and software vendors, Windows deployments also came with full
permissions and functionality enabled. This resulted in the famous Code Red worms [88] which
attacked the SQL server component of the Microsoft IIS web server. Many people who ran IIS did
not have an SQL server running or even knew that the SQL server was enabled by default in their
IIS system. But in these halcyon times, IIS web servers ran with all software enabled, so attackers
could send malicious requests to SQL servers on any system, triggering a buffer overflow that was
the basis for this worm’s launch. Subsequent versions of IIS are now “locked down” 9 , such that
software has to be manually enabled to be accessible.
4.4 SUMMARY
This investigation of the UNIX and Windows protection systems shows that it is not enough just to
design an operating system to enforce security policies. Security enforcement must be comprehensive
(i.e., mediate completely), mandatory (i.e., tamperproof ), and verifiable. Both UNIX and Windows
originated in an environment in which security requirements were very limited. For UNIX, the only
security requirement was protection from other users, and for Windows, users were assumed to be
mutually-trusted on early home computers. The connection of these systems to untrusted users and
malware on the Internet changed the security requirements for such systems, but the systems did
not evolve.
Security enforcement requires that a system’s security mechanisms can enforce system secu-
rity goals even when any of the software outside the trusted computing base may be malicious. This
assumption is required in today’s world where any network request may be malicious or any user
process may be compromised. A system that enforces security goals must implement a mandatory
protection system, whereas these system’s implement discretionary protection that can be modi-
fied and invalidated by untrusted processes. A system that enforces security goals must identify
and mediate all security-sensitive operations, whereas these systems have incomplete and informal
mediation of access. Finally, a system that enforces security goals must be tamperproof, and these
systems have unbounded TCBs that provide many unchecked opportunities for untrusted processes
to tamper with the kernel and other TCB software. When we consider secure commercial systems
in Chapters 7 and 9, we will see that significant changes are necessary, but it is still difficult to undo
fully the legacy of insecurity in these systems.
9 Features that are not required are disabled by default. Bastille Linux performs a similar role to lock down all services in Linux
systems [20].