Operating Systems

In this chapter:

  • Operating system structure and design

  • Object protection: virtualization, sharing

  • Memory protection: registers, paging, segmentation

  • Design qualities: modularity, layering, kernelization

  • Trusted systems: TCB, reference monitor, trusted path, object reuse, evaluation criteria

  • Rootkits: power, design

In this chapter we explore the role of the operating system in security. Although operating systems are crucial for implementing separation and access control, they are not invulnerable, and therefore compromise of an operating system can lead to security failure. Furthermore, users’ objects can be commingled with code and data for applications and support routines, and operating systems are limited in their ability to separate and protect these resources.

We begin this chapter with a brief overview, which for many readers will be a review, of operating system design. We continue by examining aspects of operating system design that enhance security. We end by looking at rootkits, the most serious compromise of an operating system; with such an exploit, the attacker undermines the entire operating system and thus all the security protections it is expected to provide.

5.1 Security in Operating Systems

Many attacks are silent and invisible. What good is an attack if the victim can see and perhaps counter it? As we describe in Chapter 3 , viruses, Trojan horses, and similar forms of malicious code may masquerade as harmless programs or attach themselves to other legitimate programs. Nevertheless, the malicious code files are stored somewhere, usually on a disk or in memory, and their structure can be detected with programs that recognize patterns or behavior. A powerful defense against such malicious code is prevention to block the malware before it can be stored in memory or on disk.

The operating system is the first line of defense against all sorts of unwanted behavior. It protects one user from another, ensures that critical areas of memory or storage are not overwritten by unauthorized processes, performs identification and authentication of people and remote operations, and ensures fair sharing of critical hardware resources. As the powerful traffic cop of a computing system, it is also a tempting target for attack because the prize for successfully compromising the operating system is complete control over the machine and all its components.

When the operating system initializes at system boot time, it initiates tasks in an orderly sequence: primitive functions and device drivers first, then process controllers, followed by file and memory management routines, and finally the user interface. To establish security, early tasks establish a firm defense to constrain later tasks. Primitive operating system functions, such as interprocess communication and basic input and output, must precede more complex structures such as files, directories, and memory segments, in part because these primitive functions are necessary to implement the latter constructs and also because basic communication is necessary so that different operating system functions can communicate with each other. Antivirus applications are usually initiated late because they are add-ons to the operating system; still, antivirus code must be in control before the operating system allows access to new objects that might contain viruses. Clearly, prevention software can protect only if it is active before the malicious code.

The operating system is the fundamental controller of all system resources—which makes it a primary target of attack as well.

But what if the malware embeds itself in the operating system, such that it is active before operating system components that might detect or block it? Or what if the malware can circumvent or take over other parts of the operating system? This sequencing leads to an important vulnerability: Gaining control before the protector means that the protector’s power is limited. In that case, the attacker has near-complete control of the system: The malicious code is undetectable and unstoppable. Because the malware operates with the privileges of the root of the operating system, it is called a rootkit. Although embedding a rootkit within the operating system is difficult, a successful effort is certainly worth it. We examine rootkits later in this chapter. Before we can study that class of malware, we must first consider the components from which operating systems are composed.

Background: Operating System Structure

An operating system is an executive or supervisor for a piece of computing machinery. Operating systems are not just for conventional computers. Some form of operating system can be found on any of the following objects:

  • a dedicated device such as a home thermostat or a heart pacemaker (explored in Chapter 8 )

  • an automobile (especially the engine performance sensors and the automated control functions such as antilock brakes); similarly, the avionics components of an airplane or the control system of a streetcar or mass transit system

  • a smartphone, tablet, or other web appliance (described in Chapter 4 )

  • a network appliance, such as a firewall or intrusion detection and prevention system (all covered in Chapter 6 )

  • a controller for a bank of web servers

  • a (computer) network traffic management device

In addition to this list, of course, computers—from microcomputers to laptops to handheld devices to so-called server farms with densely packed clusters of computers to huge mainframes and supercomputers—have operating systems. The nature of an operating system varies according to the complexity of the device on which it is installed, the degree of control it exercises, and the amount of interaction it supports, both with humans and other devices. Thus, there is no one simple model of an operating system, and security functions and features vary considerably.

From a security standpoint, we are most interested in an operating system’s control of resources: which users are allowed which accesses to which objects, as we explore in the next section.

Security Features of Ordinary Operating Systems

A multiprogramming operating system performs several functions that relate to security. To see how, examine Figure 5-1 , which illustrates how an operating system interacts with users, provides services, and allocates resources.

An illustration shows the different functions of an operating system.

FIGURE 5-1 Operating System Functions

The illustration shows a rectangle at the center labeled, operating system. It is linked to the following components. User interface (Three computers, representing users), services (Synchronization, concurrency, control, ceadlock, management, communication, and accounting), and resource allocation (data, program libraries, C P U, memory, and a range of input and output devices.

We can see that the system addresses several particular functions that involve computer security:

  • Enforced sharing. Resources should be made available to users as appropriate. Sharing brings about the need to guarantee integrity and consistency. Table lookup, combined with integrity controls such as monitors or transaction processors, often supports controlled sharing.

  • Interprocess communication and synchronization. Executing processes sometimes need to communicate with other processes or to synchronize their accesses to shared resources. Operating systems provide these services by acting as a bridge between processes, responding to process requests for asynchronous communication with other processes or synchronization. Interprocess communication is mediated by access control tables.

  • Protection of critical operating system data. The operating system must maintain data by which it can enforce security. Obviously, if these data are not protected against unauthorized access (read, modify, and delete), the operating system cannot do the enforcement. Various techniques (including encryption, hardware control, and isolation) support protection of operating system security data.

  • Guaranteed fair service. All users expect processor usage and other service to be provided so that no user is indefinitely starved from receiving service. Hardware clocks combine with scheduling disciplines to provide fairness. Hardware facilities and data tables combine to provide control.

  • Interface to hardware. All users access hardware functionality. Fair access and controlled sharing are hallmarks of multitasking operating systems (those running more than one task concurrently), but a more elementary need is that users require access to devices, communications lines, hardware clocks, and processors. Few users access these hardware resources directly, but all users employ such things through programs and utility functions. Hardware interface used to be more tightly bound into an operating system’s design; now, however, operating systems are designed to run on a range of hardware platforms, both to maximize the size of the potential market and to position the operating system for hardware design enhancements. Hardware is designed to be plug and play, meaning that if it detects a new device, the operating system installs appropriate device driver software to control and access the device appropriately.

  • User authentication. The operating system must identify each user who requests access and must ascertain that the user is actually who he or she purports to be. The most common authentication mechanism is password comparison.

  • Memory protection. Each user’s program must run in a portion of memory protected against unauthorized accesses. The protection will certainly prevent outsiders’ accesses, and it may also control a user’s own access to restricted parts of the program space. Differential security, such as read, write, or execute, may be applied to parts of a user’s memory space. Memory protection is usually performed by hardware mechanisms, such as paging or segmentation.

  • File and I/O device access control. The operating system must protect user and system files from access by unauthorized users. Similarly, I/O device use must be protected. Data protection is usually achieved by table lookup, as with an access control matrix.

  • Allocation and access control to general objects. Users need general objects, such as constructs to permit concurrency and allow synchronization. These general objects vary across devices but might include position and movement sensors, fingerprint readers, microphones and speakers, displays, and timing features. However, access to these objects must be controlled so that one user does not have a negative effect on other users and other applications. Again, table lookup is the common means by which this protection is provided.

You can probably see security implications in many of these primitive operating systems functions. Operating systems show several faces: traffic director, police agent, preschool teacher, accountant, umpire, timekeeper, clerk, and housekeeper, to name a few. These fundamental, primitive functions of an operating system are called kernel functions because they are basic to enforcing security as well as the other higher-level operations an operating system provides. Indeed, the operating system kernel, which we describe shortly, is the basic block that supports all higher-level operating system functions.

Operating systems did not sprout fully formed with the rich feature set we know today. Instead, they evolved from simple support utilities, as we explain next. The history of operating systems is helpful to explain why and how operating systems acquired the security functionality they have today.

A Bit of History

To understand operating systems and their security, it can help to know how modern operating systems evolved. Unlike the evolutions of many other things, operating systems did not progress in a straight line from simplest to most complex but instead had a more jagged progression.

Single Users

Once upon a time, there were no operating systems: Users entered their programs directly into the machine in binary. In early cases, program entry was done by physical manipulation of a toggle switch; in other cases, the entry was performed with a more complex electronic method by means of an input device such as a keyboard or a punched card or paper tape reader. Because each user had exclusive use of the computing system, users were required to schedule blocks of time for running the machine. These users were responsible for loading their own libraries of support routines—assemblers, compilers, shared subprograms—and “cleaning up” after use by removing any sensitive code or data.

For the most part, there was only one thread of execution. A user loaded a program and any utility support functions, ran that one program, and waited for it to halt at the conclusion of its computation. The only security issue was physical protection of the computer, its programs, and data.

The first operating systems were simple utilities, called executives , designed to assist individual programmers and smooth the transition from one user to another. The early executives provided linkers and loaders for relocation, easy access to compilers and assemblers, and automatic loading of subprograms from libraries. The executives handled the tedious aspects of programmer support, focusing on a single programmer during execution.

Multiprogramming and Shared Use

Factors such as faster processors, increased uses and demand, larger capacity, and higher cost led to shared computing. The time for a single user to set up a computer, load a program, and unload or shut down at the end was an inefficient waste of expensive machines and labor.

Operating systems took on a much broader role (and a different name) as the notion of multiprogramming was implemented. Realizing that two users could interleave access to the resources of a single computing system, researchers developed concepts such as scheduling, sharing, and concurrent use. Multiprogrammed operating systems , also known as monitors , oversaw each program’s execution. Monitors took an active role, whereas executives were passive. That is, an executive stayed in the background, waiting to be called into service by a requesting user. But a monitor actively asserted control of the computing system and gave resources to the user only when the request was consistent with general good use of the system. Similarly, the executive waited for a request and provided service on demand; the monitor maintained control over all resources, permitting or denying all computing and loaning resources as users needed them.

The transition of operating system from executive to monitor was also a shift from supporting to controlling the user.

Multiprogramming brought another important change to computing. When a single person was using a system, the only force to be protected against was that user. Making an error may have made the user feel foolish, but that user could not adversely affect the computation of any other user. However, multiple concurrent users introduced more complexity and risk. User A might rightly be angry if User B’s program or data had a negative effect on the execution of A’s program. Thus, protecting one user’s programs and data from other users’ programs became an important issue in multiprogrammed operating systems.

Paradoxically, the next major shift in operating system capabilities involved not growth and complexity but shrinkage and simplicity. The 1980s saw the changeover from multiuser mainframes to personal computers: one computer for one person. With that shift, operating system design went backward by two decades, forsaking many aspects of controlled sharing and other security features. Those concepts were not lost, however, as the same notions ultimately reappeared, not between two users but between independent activities for the single user.

Controlled sharing also implied security, much of which became irrelevant when the personal computer became dominant.

Multitasking

A user runs a program that generally consists of one process. 1 A process is assigned system resources: files, access to devices and communications, memory, and execution time. The resources of a process are called its domain . The operating system switches control back and forth between processes, allocating, deallocating, and reallocating resources each time the system activates a different process. As you can well imagine, significant bookkeeping accompanies each process switch.

  1. Alas, terminology for programs, processes, threads, and tasks is not standardized. The concepts of process and thread presented here are rather widely accepted because they are directly implemented in modern languages, such as C#, and modern operating systems, such as Linux and Windows .NET. But some systems use the term task where others use process. Fortunately, inconsistent terminology is not a serious problem once you grasp how a particular system refers to concepts.

A process consists of one or more threads , separate streams of execution. A thread executes in the same domain as all other threads of the process. That is, threads of one process share a global memory space, files, and so forth. Because resources are shared, the operating system performs far less overhead in switching from one thread to another. Thus, the operating system may change rapidly from one thread to another, giving an effect similar to simultaneous, parallel execution. A thread executes serially (that is, from beginning to end), although execution of one thread may be suspended when a thread of higher priority becomes ready to execute.

Processes have different resources, implying controlled access; threads share resources with less access control.

A server, such as a print server, spawns a new thread for each work package to do. Thus, one print job may be in progress on the printer when the print server receives another print request (perhaps for another user). The server creates a new thread for this second request; the thread prepares the print package to go to the printer and waits for the printer to become ready. In this way, each print server thread is responsible for one print activity, and these separate threads execute the same code to prepare, submit, and monitor one print job.

Finally, a thread may spawn one or more tasks , which is the smallest executable unit of code. Tasks can be interrupted or they can voluntarily relinquish control when they must wait for completion of a parallel task. If there is more than one processor, separate tasks can execute on individual processors, thus giving true parallelism.

Protected Objects

The rise of multiprogramming meant that several aspects of a computing system required protection:

  • memory

  • sharable I/O devices, such as disks

  • serially reusable I/O devices, such as printers and tape drives

  • sharable programs and subprocedures

  • networks

  • sharable data

As it assumed responsibility for controlled sharing, the operating system had to protect these objects. In the following sections we look at some of the mechanisms with which operating systems have enforced these objects’ protection. Many operating system protection mechanisms have been supported by hardware.

We want to provide sharing for some of those objects. For example, two users with different security levels may want to invoke the same pattern-matching algorithm or call the same function. We would like the users to be able to share the algorithms and functions without compromising their individual security needs.

When we think about data, we realize that access can be controlled at various levels: the bit, the byte, the element or word, the field, the record, the file, or the volume. Thus, the granularity , or increasing order of fineness, of control concerns us. The larger the level of object controlled, the easier it is to implement access control. However, sometimes the operating system must allow access to more than the user needs. For example, with large objects, a user needing access only to part of an object (such as a single record in a file) must be given access to the entire object (the whole file).

Operating System Design to Protect Objects

Operating systems are not monolithic but are instead composed of many individual routines. A well-structured operating system also implements several levels of function and protection, from critical to cosmetic. This ordering is fine conceptually, but in practice, specific functions span these layers. One way to visualize an operating system is in layers, as shown in Figure 5-2 . This figure shows functions arranged from most critical (at the bottom) to least critical (at the top). When we say “critical,” we mean important to security. So, in this figure, the functions are grouped in three categories: security kernel (to enforce security), operating system kernel (to allocate primitive resources such as time or access to hardware devices), and other operating system functions (to implement the user’s interface to hardware). Above the operating system come system utility functions and then the user’s applications. In this figure the layering is vertical; other designers think of layering as concentric circles. The critical functions of controlling hardware and enforcing security are said to be in lower or inner layers, and the less critical functions in the upper or outer layers.

An illustration shows the components of a layered operating system.

FIGURE 5-2 Layered Operating System

The illustration shows a vertical rectangle with nine segments. The segments are labeled in the following order starting from the top to the bottom. Sub-processes of User Processes, User Processes, Compilers, Data base Managers, Utility functions, File systems, Device allocation, Scheduling, Sharing, Memory Management, Synchronization, Allocation, Security Functions, and Hardware. Security Kernel corresponds to security functions and hardware. Operating system kernel corresponds to security functions, hardware, and synchronization, Allocation. Operating system corresponds to the following: Utility functions, file systems, Device allocation, Scheduling, Sharing, Memory Management, Synchronization, Allocation, Security Functions, and Hardware

Consider password authentication as an example of a security-relevant operating system activity. In fact, that activity includes several different operations, including (in no particular order) displaying the box in which the user enters a password, receiving password characters but echoing a character such as * on the display, comparing what the user enters to the stored password, checking that a user’s identity has been authenticated, or modifying a user’s password in the system table. Changing the system password table is certainly more critical to security than displaying a box for password entry because changing the table could allow an unauthorized user access but displaying the box is merely an interface task. The functions listed would occur at different levels of the operating system. Thus, the user authentication functions are implemented in several places, as shown in Figure 5-3 .

An illustration shows a set of four concentric circles that represent the layers in an operating system.

FIGURE 5-3 Authentication Functions Spanning Layers in an Operating System

A bidirectional arrow extends between the center of the innermost circle and the circumference of the outermost circle. A point between the two outermost circles is labeled, least trusted code. Another point within the innermost circle is labeled, most trusted code. A unit labeled, user authentication module extends between the innermost and the outermost circles. It has four points within. The labels corresponding to these points read as follows, starting from the innermost to the outermost. Authentication data updates, authentication data comparison, user I D lookup, and user interface.

A modern operating system has many different modules, as depicted in Figure 5-4 . Not all this code comes from one source. Hardware device drivers may come from the device manufacturer or a third party, and users can install add-ons to implement a different file system or user interface, for example. As you can guess, replacing the file system or user interface requires integration with several levels of the operating system. System tools, such as antivirus code, are said to “hook” or be incorporated into the operating system; those tools are loaded along with the operating system so as to be active by the time user programs execute. Even though they come from different sources, all these modules, drivers, and add-ons may be collectively thought of as the operating system because they perform critical functions and run with enhanced privileges.

An illustration shows the different modules of an operating system.

FIGURE 5-4 Operating System Modules

The information presented is as follows. A horizontal rectangle shows the components of privileged mode. User mode corresponds to the different users. A set of three bidirectional arrows link the users to a user interface within the privileged mode. The layer below the following modules. Sec, file, object, A slash V, Net, backup, and shell. The module that follows is labeled, system services interface. The modules below are: I slash O, time, synch, memory, comm, and sec. The module that follows is labeled, primitive services. Two modules below primitive services are labeled, microkernel and kernel mode drivers. These two modules are followed by a hardware interface and abstraction module. The last module is labeled, hardware.

From a security standpoint these modules come from different sources, not all trustworthy, and must all integrate successfully. Operating system designers and testers have a nightmarish job to ensure correct functioning with all combinations of hundreds of different add-ons from different sources. All these pieces are maintained separately, so any module can change at any time, but such changes risk incompatibility.

Operating System Design for Self-Protection

An operating system must protect itself against compromise to be able to enforce security. Think of the children’s game “king of the hill.” One player, the king, stands on top of a mound while the other players scramble up the mound and try to dislodge the king. The king has the natural advantage of being at the top and therefore able to see anyone coming, plus gravity and height work in the king’s favor. If someone does force the king off the mound, that person becomes the new king and must defend against attackers. In a computing system, the operating system arrives first and is well positioned by privilege and direct hardware interaction to protect against code that would usurp the operating system’s power.

The king of the hill game is simple because only one king at a time rules. Imagine the chaos if several kings had to repel invaders and also protect against attacks from other kings. One king might even try to dig the mound out from under another king, so attacks on a king could truly come from all directions. Knowing whom to trust and to what degree would become challenges in a multiple-king game. (This political situation can deteriorate into anarchy, which is good neither for nations nor computing systems.)

The operating system is in a similar situation: It must protect itself not just from errant or malicious user programs but also from harm from incorporated modules, drivers, and add-ons, and with limited knowledge of which ones to trust and for what capabilities. Sidebar 5-1 describes the additional difficulty of an operating system’s needing to run on different kinds of hardware platforms.

The operating system must protect itself in order to protect its users and resources.

Sidebar 5-1 Hardware-Enforced Protection

From the 1960s to the 1980s, vendors produced both hardware and the software to run on it. The major mainframe operating systems were designed to run on one family of hardware. The VAX family, for example, used a hardware design that implemented four distinct protection levels: Two were reserved for the operating system, a third for system utilities, and the last for users’ applications. This structure put essentially three distinct walls around the most critical functions, including those that implemented security. Anything that allowed the user to compromise the wall between user state and utility state still did not give the user access to the most sensitive protection features. A BiiN operating system from the late 1980s offered an amazing 64,000 different levels of protection (or separation) enforced by the hardware.

Two factors changed this situation. First, the U.S. government sued IBM in 1969, claiming that IBM had exercised unlawful monopolistic practices. As a consequence, during the late 1970s and 1980s IBM made its hardware and software available to run with other vendors’ products (thereby opening its specifications to competitors). This relaxation encouraged more openness in operating system selection: Users were finally able to buy hardware from one manufacturer and go elsewhere for some or all of the operating system. Second, the Unix operating system, begun in the early 1970s, was designed to be largely independent of the hardware on which it ran. A small kernel had to be recoded for each different kind of hardware platform, but the bulk of the operating system, running on top of that kernel, could be ported without change.

These two situations together meant that the operating system could no longer depend on hardware support for all its critical functionality, especially its self-protection. Some machines might have a particular nature of protection that other hardware lacked. So, although an operating system might still be structured to reach several states, the underlying hardware might be able to enforce separation between only two of those states, with the remainder being enforced in software.

Today, of the four most prevalent families of operating systems, three—the Windows series, Unix, and Linux and its offshoot Google Android—run on many different kinds of hardware. Only Apple’s Mac OS and iOS are strongly integrated with their hardware base. The default expectation is one level of hardware-enforced separation (two states). This situation means that an attacker is only one step away from complete system compromise through a “get_root” exploit.

But, as we depict in the previous figures, the operating system is not a monolith, nor is it plopped straight into memory as one object. An operating system is loaded in stages, as shown in Figure 5-5 . The process starts with basic I/O support for access to the boot device, the hardware device from which the next stages are loaded. Next the operating system loads something called a bootstrap loader, software to fetch and install the next pieces of the operating system, pulling itself in by its bootstraps, so to speak. The loader instantiates a primitive kernel, which builds support for low-level functions of the operating system, such as support for synchronization, interprocess communication, access control and security, and process dispatching. Those functions in turn help develop advanced functions, such as a file system, directory structure, and third-party add-ons to the operating system. At the end, support for users, such as a graphical user interface, is activated.

An illustration on Operating System Loaded in Stages.

FIGURE 5-5 Operating System Loaded in Stages

The illustration shows from early to late starting from the top as follows: BIOS, Bootstrap Loader, Primitive Kernel, Primitive Functions, Advanced Functions, and Add-Ons.

The complexity of timing, coordination, and hand-offs in operating system design and activation is enormous. Further complicating this situation is the fact that operating systems and add-ons change all the time. A flaw in one module causes its replacement, a new way to implement a function leads to new code, and support for different devices requires updated software. Compatibility and consistency are especially important for operating system functions.

Next we consider some of the tools and techniques that operating systems use to enforce protection.

Operating System Tools to Implement Security Functions

In this section we consider how an operating system actually implements the security functions for general objects of unspecified types, such as files, devices, memory objects, databases, or sharable tables. To make the explanations easier to understand, we sometimes use an example of a specific object, such as a file. Note, however, that a general mechanism can be used to protect any type of object for which access must be limited.

Remember the basic access control paradigm articulated by Scott Graham and Peter Denning [ GRA72 ] and explained in Chapter 2 : A subject is permitted to access an object in a particular mode, and only such authorized accesses are allowed. In Chapter 2 we presented several access control techniques: the access control list (ACL), the privilege list, and capabilities. Operating systems implement both the underlying tables supporting access control and the mechanisms that check for acceptable uses.

Another important operating system function related to the access control function is audit: a log of which subject accessed which object when and in what manner. Auditing is a tool for reacting after a security breach, not for preventing one. If critical information is leaked, an audit log may help to determine exactly what information has been compromised and perhaps by whom and when. Such knowledge can help limit the damage of the breach and also help prevent future incidents by illuminating what went wrong this time.

Audit logs show what happened in an incident; analysis of logs can guide prevention of future successful strikes.

An operating system cannot log every action because of the volume of such data. The act of writing to the audit record is also an action, which would generate another record, which generates another record, leading to an infinite chain of records from just the first access. But even if we put aside the problem of auditing the audit, little purpose is served by recording every time a memory location is changed or a file directory is searched; there would be far too many entries, almost all of which would be for legitimate accesses. Furthermore, the audit trail is useful only if it is analyzed. Too much data impedes timely and critical analysis.

Virtualization

Another important operating system security technique is virtualization, providing the appearance of one set of resources by using different resources. If you present a plate of cookies to a group of children, the cookies will likely all disappear. If you hide the cookies and put them out a few at a time you limit the children’s accesses. Operating systems can do the same thing.

Virtual Machine

Suppose one set of users, call it the A set, is to be allowed to access only A data, and different users, the B set, can access only B data. We can implement this separation easily and reliably with two unconnected machines. But for performance, economic, or efficiency reasons, separate machines may not be desirable. If the A and B sets overlap, strict separation is impossible.

Another approach is virtualization , in which the operating system presents each user with just the resources that class of user should see. To an A user, the machine, called a virtual machine , contains only the A resources. It could seem to the A user as if there is a file system, for example, with only the A data. The A user is unable to get to—or even know of the existence of—B resources because the A user has no way to formulate a command that would expose those resources, just as if they were on a separate machine.

Virtualization: presenting a user the appearance of a system with only the resources the user is entitled to use

Virtualization has advantages other than for security. With virtual machines, an operating system can simulate the effect of one device by using another. So, for example, if an installation decides to replace local disk devices with cloud-based storage, neither the users nor their programs need make any change; the operating system virtualizes the disk drives by covertly modifying each disk access command so the new commands retrieve and pass along the right data. You execute the command meaning “give me the next byte in this file.” But the operating system has to determine where the file is stored physically on a disk and convert the command to read from sector s block b byte y + 1 , unless byte y was the end of a block, in which case the next byte may come from a completely different disk location. Or the command might convert to cloud space c file f byte z . You are oblivious to such transformations because the operating system shields you from such detail.

Hypervisor

A hypervisor , or virtual machine monitor , is the software that implements a virtual machine. It receives all user access requests, directly passes along those that apply to real resources the user is allowed to access, and redirects other requests to the virtualized resources.

Virtualization can apply to operating systems as well as to other resources. Thus, for example, one virtual machine could run the operating system of an earlier, outdated machine. Instead of maintaining compatibility with an old operating system, developers would like people to transition to a new system. However, installations with a large investment in the old system might prefer to make the transition gradually; to be sure the new system works, system managers may choose to run both old and new systems in parallel, so that if the new system fails for any reason, the old system provides uninterrupted use. In fact, for a large enough investment, some installations might prefer to never switch. With a hypervisor to run the old system, all legacy applications and systems work properly on the new system.

A hypervisor can also support two or more operating systems simultaneously. Suppose you are developing an operating system for a new hardware platform; the hardware will not be ready for some time, but when it is available, at the same time you want to have an operating system that can run on it. Alas, you have no machine on which to develop and test your new system. The solution is a virtual machine monitor that simulates the entire effect of the new hardware. It receives system calls from your new operating system and responds just as would the real hardware. Your operating system cannot detect that it is running in a software-controlled environment.

This controlled environment has obvious security advantages: Consider a law firm working on both defense and prosecution of the same case. To install two separate computing networks and computing systems for the two teams is infeasible, especially considering that the teams could legitimately share common resources (access to a library or use of common billing and scheduling functions, for example). Two virtual machines with both separation and controlled sharing support these two sides effectively and securely.

The original justification for virtual machine monitors—shared use of large, expensive mainframe computers—has been diminished with the rise of smaller, cheaper servers and personal computers. However, virtualization has become very helpful for developing support for more specialized machine clusters, such as massively parallel processors. These powerful niche machines are relatively scarce, so there is little motivation to write operating systems that can take advantage of their hardware. But hypervisors can support use of conventional operating systems and applications in a parallel environment. Another use of hypervisors is for implementing a protected virtual network in a larger, shared network, such as the internet.

A team of IBM researchers [ CHR09 ] has investigated how virtualization affects the problem of determining the integrity of code loaded as part of an operating system. The researchers showed that the problem is closely related to the problem of determining the integrity of any piece of code, for example, something downloaded from a website.

Sandbox

A concept similar to virtualization is that of a sandbox. As its name implies, a sandbox is a protected environment in which a program can run and not endanger anything else on the system.

Sandbox: an environment from which a process can have only limited, controlled impact on outside resources

The original design of the Java system was based on the sandbox concept, skillfully led by Li Gong [ GON97 ]. The designers of Java intended the system to run code, called applets, downloaded from untrusted sources such as the internet. Java trusts locally derived code with full access to sensitive system resources (such as files). It does not, however, trust downloaded remote code; for that code, Java provides a sandbox, limited resources that cannot cause negative effects outside the sandbox. The idea behind this design was that websites could have code execute remotely (on local machines) to display complex content on web browsers.

Java compilers and a tool called a bytecode verifier ensure that the system executes only well-formed Java commands. A class loader utility is part of the virtual machine monitor to constrain untrusted applets to the safe sandbox space. Finally, the Java Virtual Machine serves as a reference monitor to mediate all access requests. The Java run-time environment is a kind of virtual machine that presents untrusted applets with an unescapable bounded subset of system resources.

Unfortunately, the original Java design proved too restrictive [ GON09 ]; people wanted applets to be able to access some resource outside the sandbox. Opening the sandbox became a weak spot, as you can well appreciate. A subsequent release of the Java system allowed signed applets to have access to most other system resources, which became a potential—and soon actual—security vulnerability. Still, the original concept showed the security strength of a sandbox as a virtual machine.

Honeypot

A final example of a virtual machine for security is the honeypot. A honeypot is a faux environment intended to lure an attacker. Usually employed in a network, a honeypot shows a limited (safe) set of resources for the attacker; meanwhile, administrators monitor the attacker’s activities in real time to learn more about the attacker’s objectives, tools, techniques, and weaknesses; they then use this knowledge to defend systems effectively.

Honeypot: system to lure an attacker into an environment that can be both controlled and monitored

Cliff Stoll [ STO88 ] and Bill Cheswick [ CHE90 ] both employed this form of honeypot to engage with their separate attackers. The attackers were interested in sensitive data, especially to identify vulnerabilities (presumably to exploit later). In these cases, the researchers engaged with the attacker, supplying real or false results in real time. Stoll, for example, decided to simulate the effect of a slow-speed, unreliable connection. This gave Stoll the time to analyze the attacker’s commands and make certain files visible to the attacker; if the attacker performed an action that Stoll was not ready for or did not want to simulate, Stoll simply broke off the communication, as if the unreliable line had failed yet again. Obviously, this kind of honeypot requires a great investment of the administrator’s time and mental energy.

Some security researchers operate honeypots as a way of seeing what the opposition is capable of doing. Virus detection companies put out attractive, poorly protected systems and then check how the systems have been infected: by what means, with what result. This research helps inform further product development.

In all these cases, a honeypot is an attractive target that turns out to be a virtual machine: What the attacker can see is a chosen, controlled view of the actual system.

These examples of types of virtual machines show how they can be used to implement a controlled security environment. Next we consider how an operating system can control sharing by separating classes of subjects and objects.

Separation and Sharing

The basis of protection is separation: keeping each user’s objects separate from all other users. John Rushby and Brian Randell [ RUS83 ] explain that separation in an operating system can occur in several ways:

  • physical separation , by which different processes use different physical objects, such as separate printers for output requiring different levels of security

  • temporal separation , by which processes having different security requirements are executed at different times

  • logical separation , by which users operate under the illusion that no other processes exist, as when an operating system constrains a program’s accesses so that the program cannot access objects outside its permitted domain

  • cryptographic separation , by which processes conceal their data and computations in such a way that they are unintelligible to outside processes

Of course, combinations of two or more of these forms of separation are also possible.

Separation occurs by space, time, access control, or cryptography.

The categories of separation are listed roughly in increasing order of complexity to implement and, for the first three, in decreasing order of the security provided. However, the first two approaches are so stringent they can lead to poor resource utilization. Therefore, we want to shift the burden of protection to the operating system to allow concurrent execution of processes having different security needs.

But separation is only half the answer. We generally want to separate one user from another user’s objects, but we also want to be able to provide sharing for some of those objects. For example, two users with two bodies of sensitive data may want to invoke the same search algorithm or function call. We would like the users to be able to share the algorithms and functions without compromising their individual data. An operating system can support separation and sharing in several ways, offering protection at any of several levels.

  • Do not protect . Operating systems with no protection are appropriate when sensitive procedures are being run at separate times.

  • Isolate . When an operating system provides isolation, different processes running concurrently are unaware of the presence of each other. Each process has its own address space, files, and other objects. The operating system must confine each process somehow so that the objects of the other processes are completely concealed.

  • Share all or share nothing . With this form of protection, the owner of an object declares it to be public or private. A public object is available to all users, whereas a private object is available only to its owner.

  • Share but limit access . With protection by access limitation, the operating system checks the allowability of each user’s potential access to an object. That is, access control is implemented for a specific user and a specific object. Lists of acceptable actions guide the operating system in determining whether a particular user should have access to a particular object. In some sense, the operating system acts as a guard between users and objects, ensuring that only authorized accesses occur.

  • Limit use of an object . This form of protection limits not just the access to an object but the use made of that object after it has been accessed. For example, a user may be allowed to view a sensitive document but not to print a copy of it. More powerfully, a user may be allowed access to data in a database to derive statistical summaries (such as average salary at a particular grade level), but not to determine specific data values (salaries of individuals).

Again, these modes of sharing are arranged in increasing order of difficulty to implement, but also in increasing order of fineness (which is also called granularity) of protection they provide. A given operating system may provide different levels of protection for different objects, users, or situations. As we describe earlier in this chapter, the granularity of control an operating system implements may not be ideal for the kinds of objects a user needs.

Hardware Protection of Memory

In this section we describe several ways of protecting a memory space. We want a program to share selected parts of memory with other programs and even other users, and especially we want the operating system and a user to coexist in memory without the user’s being able to interfere with the operating system. Even in single-user systems, as you have seen, it may be desirable to protect a user from potentially compromisable system utilities and applications. Although the mechanisms for achieving this kind of sharing are somewhat complicated, much of the implementation can be reduced to hardware, thus making sharing efficient and highly resistant to tampering.

Memory protection implements both separation and sharing.

Fence

The simplest form of memory protection was introduced in single-user operating systems to prevent a faulty user program from destroying part of the resident portion of the oerating system. As its name implies, a fence is a method to confine users to one side of a boundary.

In one implementation, the fence was a predefined memory address, enabling the operating system to reside on one side and the user to stay on the other. An example of this situation is shown in Figure 5-6 . Unfortunately, this kind of implementation was very restrictive because a predefined amount of space was always reserved for the operating system, whether the space was needed or not. If less than the predefined space was required, the excess space was wasted. Conversely, if the operating system needed more space, it could not grow beyond the fence boundary. The second problem was a severe limitation.

An illustration on Fence Protection.

FIGURE 5-6 Fence Protection

The illustration shows the following details: Addresses range between n and 0, and Addressing Range, ranging between n +1 and High. A Hardware Address Limitation runs horizontally. The memory shows Operating System on top and User Program Space at the bottom.

Another implementation used a hardware register, often called a fence register , containing the address of the end of the operating system. In contrast to a fixed fence, in this scheme the location of the fence could be changed. Each time a user program generated an address for data modification, the address was automatically compared with the fence address. If the address was greater than the fence address (that is, in the user area), the instruction was executed; if it was less than the fence address (that is, in the operating system area), an error condition was raised. The use of fence registers is shown in Figure 5-7 .

An illustration on Fence Registers.

FIGURE 5-7 Fence Registers

The first part of the illustration shows the following details: Address Limit Register (n +1) leads to Addresses ranging between n and 0, and Addressing Range, ranging between n +1 and High. A Hardware Address Limitation runs horizontally. The memory shows Operating System Version 1 on top and User Program Space at the bottom. The second part of the illustration shows the following details: Address Limit Register (p +1) leads to Addresses ranging between p and 0, and Addressing Range, ranging between p +1 and High. The memory shows Operating System Version 2 on top and User Program Space at the bottom.

A fence register protects in only one direction. In other words, an operating system can be protected from a single user, but the fence cannot protect one user from another user. Similarly, a user cannot identify certain areas of the program as inviolable (such as the code of the program itself or a read-only data area) while allowing write access to other memory.

Base/Bounds Registers

A major advantage of an operating system with fence registers is the ability to relocate; this characteristic is especially important in a multiuser environment, although it is also useful with multiple concurrent processes, for example, functions of the operating system or threads of a user’s program, loaded dynamically (that is, only when called). With two or more users, no one can know in advance where a program will be loaded for execution. The relocation register solves the problem by providing a base or starting address. All addresses inside a program are offsets from that base address. A variable fence register is generally known as a base register .

Fence registers designate a lower bound (a starting address) but not an upper one. An upper bound can be useful in knowing how much space is allotted and in checking for overflows into “forbidden” areas. To overcome this difficulty, a second register is often added, as shown in Figure 5-8 . The second register, called a bounds register, is an upper address limit, in the same way that a base or fence register is a lower address limit. Each program address is forced to be above the base address because the contents of the base register are added to the address; each address is also checked to ensure that it is below the bounds address. In this way, a program’s addresses are neatly confined to the space between the base and the bounds registers . This protection feature is especially suited for preventing buffer overflows, described in Chapter 3 .

An illustration on Base and Bounds Registers.

FIGURE 5-8 Base and Bounds Registers

The illustration shows the following details: Base Register n + 1 passes between Addresses ranging between n and 0, and Addressing Range. Bound Register p passes between p and n + 1, and p + 1 and q. q + 1 and High lie below q. A Hardware Address Limitation runs horizontally. The Memory shows the Operating System on top, followed by User Program Space which includes User A Program Space, User B Program Space, and User C Program Space.

This technique protects a program’s addresses from modification by another user. When execution changes from one user’s program to another’s, the operating system must change the contents of the base and bounds registers to reflect the true address space for that user. This change is part of the general preparation, called a context switch, that the operating system must perform when transferring control from one user to another.

With a pair of base/bounds registers, each user is perfectly protected from outside users, or, more correctly, outside users are protected from errors in any other user’s program. Erroneous addresses inside a user’s address space can still affect that program because the base/bounds checking guarantees only that each address is inside the user’s address space. For example, a user error might occur when a subscript is out of range or an undefined variable generates an address reference within the user’s space but, unfortunately, landing in the executable instructions of the user’s program. In this manner, a user can accidentally store data on top of instructions, as in a buffer overflow. Such an error can let a user inadvertently destroy executable code, but (fortunately) only that user’s own program.

Base/bounds registers surround a program, data area, or domain.

We can solve this overwriting problem by using another pair of base/bounds registers, one for the instructions (code) of the program and a second for the data space. Then, only instruction fetches (instructions to be executed) are relocated and checked with the first register pair, and only data accesses (operands of instructions) are relocated and checked with the second register pair. The use of two pairs of base/bounds registers is shown in Figure 5-9 . Although two pairs of registers do not prevent all program errors, they limit the effect of data-manipulating instructions to the data space. The pairs of registers offer another more important advantage: the ability to split a program into two pieces that can be relocated separately.

An illustration on Two Pairs of Base and Bounds Registers.

FIGURE 5-9 Two Pairs of Base and Bounds Registers

A memory shows Operating System on top followed by User Program and Data Space which includes User A Program Space, User B Data Space, User A Data Space, User C Program Space, User C Data Space, and User B Program Space. Data Base lies between User A Program Space, and User B Data Space. Data Bounds lies between User B Data Space, and User A Data Space. Program Base lies between User C Data Space, and User B Program Space. Program Bounds lies below User B Program Space.

These two features seem to lead to three or more pairs of registers: one for code, one for read-only data, and one for modifiable data values. Although in theory this concept can be extended, two pairs of registers have been the limit for practical computer design. For each additional pair of registers (beyond two), something in the machine code or state of each instruction must indicate which relocation pair is to be used to address the instruction’s operands. That is, with more than two pairs, each instruction specifies one of two or more data spaces. But with only two pairs, the decision can be automatic: data operations (add, bit shift, compare) with the data pair, execution operations (jump) with the code area pair.

Tagged Architecture

Another problem with using base/bounds registers for protection or relocation is their contiguous nature. Each pair of registers confines accesses to a consecutive range of addresses. A compiler or loader can easily rearrange a program so that all code sections are adjacent and all data sections are adjacent.

However, in some cases you may want to protect some data values but not all. For example, a personnel record may require protecting the field for salary but not office location and phone number. Moreover, a programmer may want to ensure the integrity of certain data values by allowing them to be written when the program is initialized but prohibiting the program from modifying them later. This scheme protects against errors in the programmer’s own code. A programmer may also want to invoke a shared subprocedure from a common library. We can address some of these issues by using good design, both in the operating system and in the other programs being run. Recall that in Chapter 3 we studied good design characteristics such as information hiding and modularity in program design. These characteristics dictate that one program module must share with another module only the minimum amount of data necessary for both of them to do their work.

Additional, operating-system-specific design features can help, too. Base/bounds registers create an all-or-nothing situation for sharing: Either a program makes all its data available to be accessed and modified or it prohibits access to all. Even if there were a third set of registers for shared data, all shared data would need to be located together. A procedure could not effectively share data items A, B, and C with one module; A, C, and D with a second; and A, B, and D with a third. The only way to accomplish the kind of sharing we want would be to move each appropriate set of data values to some contiguous space. However, this solution would not be acceptable if the data items were large records, arrays, or structures.

An alternative is tagged architecture , in which every portion of machine memory has one or more extra bits to identify the access rights to that word. The portion could be as small as a byte or a word, or a larger block of, for example, 256 or 1024 bytes. These access bits can be set only by privileged (operating system) instructions. The bits are tested every time an instruction accesses that location.

For example, as shown in Figure 5-10 , one memory location may be protected as execute-only (for example, the object code of instructions), whereas another is protected for fetch-only (for example, read) data access, and another accessible for modification (for example, write). In this way, two adjacent locations can have different access rights. Furthermore, with a few extra tag bits, different classes of data (numeric, character, address, or pointer, and undefined) can be separated, and data fields can be protected for privileged (operating system) access only.

A table shows the Tagged Architecture.

FIGURE 5-10 Tagged Architecture

The column headers read, Tag, and Memory Word and shows the following data: R - 0001, RW - 0137, R - 0099, six X's show different types of wavy lines, R - 4091, and RW - 0002. The bottom of the table reads, Code: R = Read-only, RW = Read/Write, and X = Execute-only.

This protection technique has been used on a few systems, although the number of tag bits has been rather small. The Burroughs B6500-7500 system used three tag bits to separate data words (three types), descriptors (pointers), and control words (stack pointers and addressing control words). The IBM System/38 used a tag to control both integrity and access.

A machine architecture called BiiN, referred to in Sidebar 5-1 , was designed by Siemens and Intel together. BiiN used one tag that applied to a modest-sized group of consecutive locations, such as 128 or 256 bytes. With one tag for a block of addresses, the added cost for implementing tags was not as high as with one tag per location. The Intel I960 extended-architecture processor used a tagged architecture with a bit on each memory word that marked the word as a “capability,” not as an ordinary location for data or instructions. A capability controlled the access to a variable-sized memory block or segment. This large number of possible tag values supported memory segments that ranged in size from 64 to 4 billion bytes, with a potential 2 256 different protection domains.

Compatibility of code presented a problem with the acceptance of a tagged architecture. A tagged architecture may not be as useful as more modern approaches, as we will see shortly. Some of the major computer vendors are still working with operating systems that were designed and implemented many years ago for architectures of that era: Unix dates to the 1970s; Mach, the heart of Apple’s iOS, was a 1980s derivative of Unix; and parts of modern Windows are from the 1980s DOS, early 1990s Windows, and late 1990s NT. Even Google’s Android operating system runs on a Linux (derivative of Unix) kernel. Indeed, most manufacturers are locked into a more conventional memory architecture because of the wide availability of components and a desire to maintain compatibility among operating systems and machine families. A tagged architecture would require fundamental changes to substantially all the operating system code, a requirement that can be prohibitively expensive. But as the price of memory continues to fall, the implementation of a tagged architecture becomes more feasible.

Virtual Memory

We present two more approaches to memory protection, each of which can be implemented on top of a conventional machine structure, suggesting a better chance of acceptance. Although these approaches are ancient by computing standards—they were designed between 1965 and 1975—they have been widely implemented since then. Furthermore, they offer important advantages in addressing, with memory protection being a delightful bonus.

Segmentation

The first of these two approaches, segmentation , involves the simple notion of dividing a program into separate pieces. Each piece has a logical unity, exhibiting a relationship among all its code or data values. For example, a segment may be the code of a single procedure, the data of an array, or the collection of all local data values used by a particular module. Segmentation was developed as a feasible means to produce the effect of an unlimited number of base/bounds registers. In other words, segmentation allows a program to be divided into many pieces having different access rights.

Each segment has a unique name. A code or data item within a segment is addressed as the pair 〈name , offset〉 , where name is the name of the segment containing the data item and offset is its location within the segment (that is, its distance from the start of the segment).

Logically, the programmer envisions a program as a long collection of segments. Segments can be separately relocated, allowing any segment to be placed in any available memory locations. The relationship between a logical segment and its true memory position is shown in Figure 5-11 .

An illustration shows Segmentation.

FIGURE 5-11 Segmentation

The left side of the illustration represents the Logical Arrangement of Program and shows a box divided into four horizontal segments, labeled, MAIN, SEG_A, SUB, and DATA_SEG. The right side of the illustration represents the Physical Placement of Program's Segments and shows a box divided into ten segments and labeled as follows: A shaded box, SUB, a shaded box, MAIN, three shaded boxes, SEG_A, DATA_SEG, and a shaded box. The last five shaded boxes are segments for Other Users and others are Operating System Segments. Arrows from MAIN, SEG_A, SUB, and DATA_SEG of Logical Arrangement of Program link to MAIN, SEG_A, SUB, and DATA_SEG of Physical Placement of Program's Segments.

The operating system must maintain a table of segment names and their true addresses in memory. When a program generates an address of the form 〈name , offset〉 , the operating system looks up name in the segment directory and determines its real beginning memory address. To that address the operating system adds offset , giving the true memory address of the code or data item. This translation is shown in Figure 5-12 . For efficiency, there is usually one operating system segment address table for each process in execution. Two processes that need to share access to a single segment would have the same segment name and address in their segment tables.

An illustration shows Segment Address Translation.

FIGURE 5-12 Segment Address Translation

The Logical Program includes MAIN, SEG_A, SUB, and DATA_SEG. The Segment Translation Table includes MAIN - c, SEG_A - g, SUB - a, and DATA_SEG - h. Address includes 0 - a shaded box, a - a blank box, b - shaded box, c - blank box, d, e, f - shaded boxes, g, h - blank boxes, and i - shaded boxes. FETCH less than DATA_SEG, 20 greater than points at DATA_SEG, h, and a positive sign. DATA_SEG, h also points at the positive sign. The positive sign points at a small blank box under h in Address.

Thus, a user’s program does not know what true memory addresses it uses. It has no way—and no need—to determine the actual address associated with a particular 〈name , offset〉 . The 〈name , offset〉 pair is adequate to access any data or instruction to which a program should have access.

This hiding of addresses has three advantages for the operating system.

  • The operating system can place any segment at any location or move any segment to any location, even after the program begins to execute. Because the operating system translates all address references by a segment address table, the operating system need only update the address in that one table when a segment is moved.

  • A segment can be removed from main memory (and stored on an auxiliary device) if it is not being used currently. (These first two advantages explain why this technique is called virtual memory, with the same basis as the virtualization described earlier in this chapter. The appearance of memory to the user is not necessarily what actually exists.)

  • Every address reference passes through the operating system, so there is an opportunity to check each one for protection.

Because of this last characteristic, a process can access a segment only if that segment appears in that process’s segment translation table. The operating system controls which programs have entries for a particular segment in their segment address tables. This control provides strong protection of segments from access by unpermitted processes. For example, program A might have access to segments BLUE and GREEN of user X but not to other segments of that user or of any other user. In a straightforward way, we can allow a user to have different protection classes for different segments of a program. For example, one segment might be read-only data, a second might be execute-only code, and a third might be writeable data. In a situation like this one, segmentation can approximate the goal of separate protection of different pieces of a program, as outlined in the previous section on tagged architecture.

Segmentation allows hardware-supported controlled access to different memory sections in different access modes.

Segmentation offers these security benefits:

  • Each address reference is checked—strictly within the size of the segment—for protection.

  • Many different classes of data items can be assigned different levels of protection.

  • Two or more users can share access to a segment, with potentially different access rights.

  • A user cannot generate an address or access to an unpermitted segment.

One protection difficulty inherent in segmentation concerns segment size. Each segment has a particular size. However, a program can generate a reference to a valid segment name, but with an offset beyond the end of the segment. For example, reference 〈 A,9999 〉 looks perfectly valid, but in reality, segment A may be only 200 bytes long. If left unplugged, this security hole could allow a program to access any memory address beyond the end of a segment just by using large values of offset in an address.

This problem cannot be stopped during compilation or even when a program is loaded because effective use of segments requires that they be allowed to grow in size during execution. For example, a segment might contain a dynamic data structure such as a stack. Therefore, secure implementation of segmentation requires the checking of a generated address to verify that it is not beyond the current end of the segment referenced. Although this checking results in extra expense (in terms of time and resources), segmentation systems must perform this check; the segmentation process must maintain the current segment length in the translation table and compare every address generated.

Thus, we need to balance protection with efficiency, finding ways to keep segmentation as efficient as possible. However, efficient implementation of segmentation presents two problems: Segment names are inconvenient to encode in instructions, and the operating system’s lookup of the name in a table can be slow. To overcome these difficulties, segment names are often converted to numbers by the compiler when a program is translated; the compiler also appends a linkage table that matches numbers to true segment names. Unfortunately, this scheme presents an implementation difficulty when two procedures need to share the same segment because the assigned segment numbers of data accessed by that segment must be the same.

Paging

An alternative to segmentation is paging . The program is divided into equal-sized pieces called pages, and memory is divided into equal-sized units called page frames. (For implementation reasons, the page size is usually chosen to be a power of 2 between 512 and 4096 bytes.) As with segmentation, each address in a paging scheme is a two-part object, this time consisting of 〈 page , offset〉 .

Each address is again translated by a process similar to that of segmentation: The operating system maintains a table of user page numbers and their true addresses in memory. The page portion of every 〈 page , offset〉 reference is converted to a page frame address by a table lookup; the offset portion is added to the page frame address to produce the real memory address of the object referred to as 〈 page , offset〉 . This process is illustrated in Figure 5-13 .

An illustration shows the Page Address Translation.

FIGURE 5-13 Page Address Translation

The Logical Program includes Page 0, Page 1, Page 2, Page 3, Page 4, Page 5, Page 6, and Page 7. Page Translation Table shows column headers, Page, and Address and shows the following data: 0, b; 1, f; 2, i; 3, l; 4, c; 5, g; 6, n; and 7, e. The next table shows the column headers, Address, and memory, and shows the following data: 0, a - shaded boxes, b - page 0, c - page 4, d - shaded box, e - page 7, f - page 1, g - page 5, h - shaded box, i - page 2, j, k - shaded boxes, l - page 3, m - shaded box, n - page 6, and o - shaded box. Logical Program Fetch less than 4, 37 greater than in which points at 4 under column page, and 37 points at c under column a positive sign. The Page Translation Table's c under Address points at the positive sign. The positive sign points at a small box under memory showing page 4 (Location 37, Page 4)

Unlike segmentation, all pages in the paging approach are of the same fixed size, so fragmentation is not a problem. Each page can fit in any available page frame in memory, thus obviating the problem of addressing beyond the end of a page. The binary form of a 〈 page , offset〉 address is designed so that the offset values fill a range of bits in the address. Therefore, an offset beyond the end of a particular page results in a carry into the page portion of the address, which changes the address.

Paging allows the security advantages of segmentation with more efficient memory management.

To see how this idea works, consider a page size of 1024 bytes 1024 \= 2 10 , where 10 bits are allocated for the offset portion of each address. A program cannot generate an offset value larger than 1023 in 10 bits. Moving to the next location after 〈 x,1023 〉 causes a carry into the page portion, thereby moving translation to the next page. During the translation, the paging process checks to verify that a 〈 page , offset〉 reference does not exceed the maximum number of pages the process has defined.

With a segmentation approach, a programmer must be conscious of segments. However, a programmer is oblivious to page boundaries when using a paging-based operating system. Moreover, with paging there is no logical unity to a page; a page is simply the next 2 n bytes of the program. Thus, a change to a program, such as the addition of one instruction, pushes all subsequent instructions to lower addresses and moves a few bytes from the end of each page to the start of the next. This shift is not something about which the programmer need be concerned, because the entire mechanism of paging and address translation is hidden from the programmer.

However, when we consider protection, this shift is a serious problem. Because segments are logical units, we can associate different segments with individual protection rights, such as read-only or execute-only. The shifting can be handled efficiently during address translation. But with paging, there is no necessary unity to the items on a page, so there is no way to establish that all values on a page should be protected at the same level, such as read-only or execute-only.

Combined Paging with Segmentation

We have seen how paging offers implementation efficiency, while segmentation offers logical protection characteristics. Since each approach has drawbacks as well as desirable features, the two approaches have been combined.

The IBM 390 family of mainframe systems used a form of paged segmentation. Similarly, the Multics operating system (implemented on a GE-645 machine) applied paging on top of segmentation. In both cases, the programmer could divide a program into logical segments. Each segment was then broken into fixed-size pages. In Multics, the segment name portion of an address was an 18-bit number with a 16-bit offset. The addresses were then broken into 1024-byte pages. The translation process is shown in Figure 5-14 . This approach retained the logical unity of a segment and permitted differentiated protection for the segments, but it added an additional layer of translation for each address. Additional hardware improved the efficiency of the implementation.

An illustration shows Address Translation with Paged Segmentation.

FIGURE 5-14 Address Translation with Paged Segmentation

The Logical Program includes MAIN, SEG_A, SUB, and DATA_SEG. The Segment Translation Table shows column headers, SEGMENT, and PAGE TABLE, and shows the following data under the Segment column: MAIN, SEG_A, SUB, and DATA_SEG and the table column shows shaded ovals for each Segment. Page Translation Tables For Segment MAIN shows columns, Page, and Address: 0 - c; 1, f. For Segment SEG_A shows columns, Page, and Address: 0, n; 1, e; 2, g. For Segment SUB shows columns Page, and Address: 0, i. For Segment DATA_SEG shows columns, Page, and Address: 0, 1; 1, b. The address and memory are as follows: 0 - shaded box, a - shaded box, b - DATA_SEG Page 1, c - MAIN Page 0, d - shaded box, e - SEG_A Page 1, f - MAIN Page1 g - SEG_A Page 2, h - shaded box, i - SUB Page 0, j - shaded box, k - shaded box, l - DATA_SEG Page 0, m - shaded box, n - SEG_A Page 0, and o - shaded box. FETCH<DATA_SEG,20> points at DATA_SEG of Segment Translation Table. The first shaded oval of Segment Translation Table points at page 0 of For Segment MAIN. The second shaded oval of Segment Translation Table points at page 0 of For Segment SEG_A. The third shaded oval of Segment Translation Table points at page 0 of For Segment SUB. The fourth shaded oval of Segment Translation Table points at page 0 of For Segment DATA_SEG through a dashed line. The Address 1 of For Segment DATA_SEG points through a dashed line at a positive sign which points through a dashed line at DATA_SEG Page 0 of Memory. A dashed line from positive sign points to Page 0 under For Segment DATA_SEG through 20 = Page 0.

These hardware mechanisms provide good memory protection, even though their original purpose was something else indeed: efficient memory allocation and data relocation, with security a fortuitous side effect. In operating systems, security has been a central requirement and design element since the beginning, as we explore in the next section.

5.2 Security in the Design of Operating Systems

As we just discussed, operating systems are complex pieces of software. The components come from many sources, some pieces are legacy code to support old functions; other pieces date back literally decades, with long-forgotten design characteristics. And some pieces were written just yesterday. Old and new pieces must interact and interface successfully, and new designers must ensure that their code works correctly with all existing previous versions, not to mention the numerous applications that exist.

Exploit authors capitalize on this complexity by experimenting to locate interface mismatches: a function no longer called, an empty position in the table of interrupts handled, a forgotten device driver. The operating system opens many points to which code can later attach as pieces are loaded during the boot process; if one of these pieces is not present, the malicious code can attach instead.

Obviously, not all complex software is vulnerable to attack. The point we are making is that the more complex the software, the more possibilities for unwanted software introduction. A house with no windows leaves no chance for someone to break in through a window, but each additional window in a house design increases the potential for this harm and requires the homeowner to apply more security. Now extend this metaphor to modern operating systems that typically include millions of lines of code: What is the likelihood that every line is perfect for its use and fits perfectly with every other line?

The principles of secure program design we introduced in Chapter 3 apply equally well to operating systems. Simple, modular, loosely coupled designs present fewer opportunities to the attacker.

Simplicity of Design

Operating systems by themselves (regardless of their security constraints) are difficult to design. They handle many duties, are subject to interruptions and context switches, and must minimize overhead so as not to slow user computations and interactions. Adding the responsibility for security enforcement to the operating system increases the difficulty of design.

Nevertheless, the need for effective security is pervasive, and good software engineering principles tell us how important it is to design in security at the beginning than to shoehorn it in at the end. (See Sidebar 5-2 for more about good design principles.) Thus, this section focuses on the design of operating systems for a high degree of security. We look in particular at the design of an operating system’s kernel; how the kernel is designed suggests whether security will be provided effectively. We study two different interpretations of the kernel, and then we consider layered or ring-structured designs.

Sidebar 5-2 The Importance of Good Design Principles

Every design, whether it be for hardware or software, must begin with a design philosophy and guiding principles. These principles suffuse the design, are built in from the beginning, and are preserved (according to the design philosophy) as the design evolves.

The design philosophy expresses the overall intentions of the designers, not only in terms of how the system will look and act but also in terms of how it will be tested and maintained. Most systems are not built for short-term use. They grow and evolve as the world and technology change over time. Features are enhanced, added, or deleted. Supporting or communicating hardware and software change. The system is fixed as problems are discovered and their causes rooted out. The design philosophy explains how the system will “hang together,” maintaining its integrity through all these changes. A good design philosophy will facilitate testing and modification.

The philosophy suggests a set of good design principles. Modularity, information hiding, and other notions discussed in Chapter 3 form guidelines that enable designers to meet their goals for software quality. Since security is one of these goals, it is essential that security policy be consistent with the design philosophy and that the design principles enable appropriate protections to be built into the system.

When the quality of the design is not considered up-front and embedded in the development process, the result can be a sort of software anarchy. The system may run properly at first, but as changes are made, the software degrades quickly and in a way that makes future changes more difficult and time consuming. The software becomes brittle, failing more often and sometimes making it impossible for features, including security, to be added or changed. Equally important, brittle and poorly designed software can easily hide vulnerabilities because the software is so difficult to understand and the execution states so hard to follow, reproduce, and test. Thus, good design is in fact a security issue, and secure software must be designed well.

Layered Design

As described previously, a nontrivial operating system consists of at least four levels: hardware, kernel, executive, and user. Each of these layers can include sublayers. For example, in [ SCH83 ], the kernel has five distinct layers. The user level may also have quasi-system programs, such as database managers or graphical user interface shells, that constitute separate layers of security themselves.

Layered Trust

As we discuss earlier in this chapter, the layered structure of a secure operating system can be thought of as a series of concentric circles, with the most sensitive operations in the innermost layers. An equivalent view is as a building, with the most sensitive tasks assigned to lower floors. Then, the trustworthiness and access rights of a process can be judged by the process’s proximity to the center: The more trusted processes are closer to the center or bottom.

Implicit in the use of layering as a countermeasure is separation. Earlier in this chapter we describe ways to implement separation: physical, temporal, logical, and cryptographic. Of these four, logical (software-based) separation is most applicable to layered design, which means a fundamental (inner or lower) part of the operating system must control the accesses of all outer or higher layers to enforce separation.

Peter Neumann [ NEU86 ] describes the layered structure used for the Provably Secure Operating System (PSOS). Some lower-level layers present some or all of their functionality to higher levels, but each layer properly encapsulates those things below itself.

A layered approach is another way to achieve encapsulation, presented in Chapter 3 . Layering is recognized as a good operating system design. Each layer uses the more central layers as services, and each layer provides a certain level of functionality to the layers farther out. In this way, we can “peel off” each layer and still have a logically complete system with less functionality. Layering presents a good example of how to trade off and balance design characteristics.

Another justification for layering is damage control. To see why, consider Neumann’s two examples of risk. In a conventional, nonhierarchically designed system (shown in Table 5-1 ), the most critical functions exist in all layers. Any problem—hardware failure, software flaw, or unexpected condition, even in a supposedly irrelevant nonsecurity portion—can cause disaster because the effect of the problem is unbounded and because the system’s design means that we cannot be confident that any given function has no (indirect) security effect.

Table 5-1 Conventional (Nonhierarchical) Design

Level/Layer Functions Risk
all Noncritical functions Disaster possible
all Less critical functions Disaster possible
all More critical functions Disaster possible

By contrast, as shown in Table 5-2 , hierarchical structuring has two benefits.

  • Hierarchical structuring permits identification of the most critical parts, which can then be analyzed intensely for correctness, so the number of problems should be smaller.

  • Isolation limits effects of problems to the hierarchical levels at and above the point of the problem, so the harmful effects of many problems should be confined.

Table 5-2 Hierarchically Designed System

Level Functions Risk
2 Noncritical functions Few disasters likely from noncritical software
1 Less critical functions Some failures possible from less critical functions, but because of separation, impact limited
0 More critical functions Disasters possible, but unlikely if system simple enough for more critical functions to be analyzed extensively to ensure their correctness

These design properties—the kernel, separation, isolation, and hierarchical structure—have been the basis for many trustworthy system prototypes. They have stood the test of time as best design and implementation practices.

Layering ensures that a security problem affects only less sensitive layers.

Kernelized Design

A kernel is the part of an operating system that performs the lowest-level functions. In standard operating system design, the kernel implements operations such as synchronization, interprocess communication, message passing, and interrupt handling. The kernel is also called a nucleus or core . The notion of designing an operating system around a kernel is described by Butler Lampson and Howard Sturgis [ LAM76 ] and by Gerald Popek and Charles Kline [ POP78 ].

A security kernel is responsible for enforcing the security mechanisms of the entire operating system. The security kernel provides the security interfaces among the hardware, operating system, and other parts of the computing system. Typically, the operating system is designed so that the security kernel is contained within the operating system kernel. Security kernels are discussed in detail by Stan Ames [ AME83 ].

Security kernel: locus of all security enforcement

There are several good design reasons why security functions may be isolated in a security kernel.

  • Coverage . Every access to a protected object must pass through the security kernel. In a system designed in this way, the operating system can use the security kernel to ensure that every access is checked.

  • Separation . Isolating security mechanisms both from the rest of the operating system and from the user space makes it easier to protect those mechanisms from penetration by the operating system or the users.

  • Unity . All security functions are performed by a single set of code, so it is easier to trace the cause of any problems that arise with these functions.

  • Modifiability . Changes to the security mechanisms are easier to make and easier to test. And because of unity, the effects of changes are localized so interfaces are easier to understand and control.

  • Compactness . Because it performs only security functions, the security kernel is likely to be relatively small.

  • Verifiability . Being relatively small, the security kernel can be analyzed rigorously. For example, formal methods can be used to ensure that all security situations (such as states and state changes) have been covered by the design.

Notice the similarity between these advantages and the design goals of operating systems that we described earlier. These characteristics also depend in many ways on modularity, as described in Chapter 3 .

On the other hand, implementing a security kernel may degrade system performance because the kernel adds yet another layer of interface between user programs and operating system resources. Moreover, the presence of a kernel does not guarantee that it contains all security functions or that it has been implemented correctly. And in some cases a security kernel can be quite large.

How do we balance these positive and negative aspects of using a security kernel? The design and usefulness of a security kernel depend somewhat on the overall approach to the operating system’s design. There are many design choices, each of which falls into one of two types: Either the security kernel is designed as an addition to the operating system or it is the basis of the entire operating system. Let us look more closely at each design choice.

Reference Monitor

The most important part of a security kernel is the reference monitor [ AND72 , LAM71 ], the portion that controls accesses to objects. We introduced reference monitors in Chapter 2 . The reference monitor separates subjects and objects, enforcing that a subject can access only those objects expressly allowed by security policy. A reference monitor is not necessarily a single piece of code; rather, it is the collection of access controls for devices, files, memory, interprocess communication, and other kinds of objects. As shown in Figure 5-15 , a reference monitor acts like a brick wall around the operating system or trusted software to mediate accesses by subjects (S) to objects (O).

An illustration shows the Reference Monitor.

FIGURE 5-15 Reference Monitor

Two bricked walls are placed left and right with the text, Operating System or Trusted Software. There is a Reference Monitor in between the walls, showing the gate closed as well as open. The left wall shows an outward arrow and a double-head arrow, alternatively, and the end of the arrows there is an O inside a circle. The other side of the wall shows a double-head arrow and two inward arrows with the letter S inside a circle on the outer side of the arrows.

As stated in Chapter 2 , a reference monitor must be

  • tamperproof , that is, impossible to weaken or disable

  • unbypassable , that is, always invoked when access to any object is required

  • analyzable , that is, small enough to be subjected to analysis and testing, the completeness of which can be ensured

The reference monitor is not the only security mechanism of a trusted operating system. Other parts of the security suite include auditing and identification and authentication processing, as well as setting enforcement parameters, such as who are allowable subjects and what objects they are allowed to access. These other security parts interact with the reference monitor, receiving data from the reference monitor or providing it with the data it needs to operate.

The reference monitor concept has been used for many trusted operating systems and also for smaller pieces of trusted software. The validity of this concept is well supported both in research and in practice. Paul Karger [ KAR90 , KAR91 ] and Morrie Gasser [ GAS88 ] describe the design and construction of the kernelized DEC VAX operating system that adhered strictly to use of a reference monitor to control access.

Correctness and Completeness

That security considerations pervade the design and structure of operating systems requires correctness and completeness. Correctness implies that because an operating system controls the interaction between subjects and objects, security must be considered in every aspect of its design. That is, the operating system design must include definitions of which objects will be protected in what ways, what subjects will have access and at what levels, and so on. There must be a clear mapping from the security requirements to the design so that all developers can see how the two relate.

Moreover, after designers have structured a section of the operating system, they must check to see that the design actually implements the degree of security that it is supposed to enforce. This checking can be done in many ways, including formal reviews or simulations. Again, a mapping is necessary, this time from the requirements to design to tests, so that developers can affirm that each aspect of operating system security has been tested and shown to work correctly. Because security appears in every part of an operating system, security design and implementation cannot be left fuzzy or vague until the rest of the system is working and being tested.

Completeness requires that security functionality be included in all places necessary. Although this requirement seems self-evident, not all developers are necessarily thinking of security as they design and write code, so security completeness is challenging. It is extremely hard to retrofit security features to an operating system designed with inadequate security. Leaving an operating system’s security to the last minute is much like trying to install plumbing or electrical wiring in a house whose foundation is set, floors laid, and walls already up and painted; not only must you destroy much of what you have built, but you may also find that the general structure can no longer accommodate all that is needed (and so some has to be left out or compromised). And last-minute additions are often done hastily under time pressure, which does not encourage complete and careful production.

Security enforcement must be correct and complete.

Thus, security must be an essential part of the initial design of a trusted operating system. Indeed, the security considerations may shape many of the other design decisions, especially for a system with complex and constraining security requirements. For the same reasons, the security and other design principles must be carried throughout implementation, testing, and maintenance. Phrased differently, as explained in Sidebar 5-3 , security emphatically cannot be added on at the end.

Security seldom succeeds as an add-on; it must be part of the initial philosophy, requirements, design, and implementation.

Sidebar 5-3 Security as an Add-On

In the 1980s, the U.S. State Department handled its diplomatic office functions with a network of Wang computers. Each U.S. embassy had at least one Wang system, with specialized word processing software to create documents, modify them, store and retrieve them, and send them from one location to another. Supplementing Wang’s office automation software was the State Department’s own Foreign Affairs Information System (FAIS).

In the mid-1980s, the State Department commissioned a private contractor to add security to FAIS. Diplomatic and other correspondence was to be protected by a secure “envelope” surrounding sensitive materials. The added protection was intended to prevent unauthorized parties from “opening” an envelope and reading the contents.

To design and implement the security features, the contractor had to supplement features offered by Wang’s operating system and utilities. The security design depended on the current Wang VS operating system design, including the use of unused space in operating system code files. As designed and implemented, the new security features worked properly and met the State Department requirements. But the system was bound for failure because the evolutionary goals of VS were different from those of the State Department. Wang could not guarantee that future modifications to VS would preserve the functions and structure required by the contractor’s security software. In other words, Wang might need to appropriate some of the unused space in operating system files for new system functions, regardless of whether FAIS was using that storage. Eventually, there were fatal clashes of intent and practice, and the added-on security functions failed.

Secure Design Principles

Good design principles are always good for security, as we have noted previously. But several important design principles are particular to security and essential for building a solid, trusted operating system. These principles, articulated well by Jerome Saltzer and Michael Schroeder [ SAL74 , SAL75 ], were raised in Chapter 3 ; we repeat them here because of their importance in the design of secure operating systems.

  • least privilege

  • economy of mechanism

  • open design

  • complete mediation

  • permission based

  • separation of privilege

  • least common mechanism

  • ease of use

Although these design principles were suggested several decades ago, they are as accurate now as they were when originally written. The principles have been used repeatedly and successfully in the design and implementation of numerous trusted systems. More importantly, when security problems have been found in operating systems in the past, they almost always derive from failure to abide by one or more of these principles. These design principles led to the development of “trusted” computer systems or “trusted” operating systems.

Trusted Systems

Trusted systems can also help counter the malicious software problem. A trusted system is one that has been shown to warrant some degree of trust that it will perform certain activities faithfully, that is, in accordance with users’ expectations. Contrary to popular usage, “trusted” in this context does not mean hope, in the sense of “gee, I hope this system protects me from malicious code.” Hope is trust with little justification; trusted systems have convincing evidence to justify users’ trust. See Sidebar 5-4 for further discussion of the meaning of the word.

Trusted system: one with evidence to substantiate the claim it implements some function or policy

Sidebar 5-4 What Does “Trust” Mean for a System?

Before we begin to examine a trusted operating system in detail, let us look more carefully at the terminology involved in understanding and describing trust. What would it take for us to consider something to be secure?

The word “secure” reflects a dichotomy: Something is either secure or not secure. If secure, it should withstand all attacks, today, tomorrow, and a century from now. And if we claim that it is secure, you either accept our assertion (and buy and use it) or reject it (and either do not use it or use it but do not expect much from it).

How does security differ from quality? If we claim that something is good, you are less interested in our claims and more interested in an objective appraisal of whether the thing meets your performance and functionality needs. From this perspective, security is only one facet of goodness or quality; you may choose to balance security with other characteristics (such as speed or user friendliness) to select a system that is best, given the choices you have. In particular, the system you build or select may be pretty good, even though it may not be as secure as you would like it to be.

Security professionals prefer to speak of trusted instead of secure operating systems. A trusted system connotes one that meets the intended security requirements, is of high enough quality, and justifies the user’s confidence in that quality. That is, trust is perceived by the system’s receiver or user, not by its developer, designer, or manufacturer. As a user, you may not be able to evaluate that trust directly. You may trust the design, a professional evaluation, or the opinion of a valued colleague. But in the end, it is your responsibility to sanction the degree of trust you require.

We say that software is trusted software if we know that the code has been rigorously developed and analyzed, giving us reason to trust that the code does what it is expected to do and nothing more. Typically, trusted code can be a foundation on which other, untrusted, code runs. That is, the untrusted system’s quality depends, in part, on the trusted code; the trusted code establishes the baseline for security of the overall system. In particular, an operating system can be trusted software when there is a rational or objective basis for trusting that it correctly controls the accesses of components or systems run from it.

To trust any program, we base our trust on rigorous analysis and testing, looking for certain key characteristics:

  • Functional correctness . The program does what it is supposed to, and it works correctly.

  • Enforcement of integrity . Even if presented erroneous commands or commands from unauthorized users, the program maintains the correctness of the data with which it has contact.

  • Limited privilege . The program is allowed to access secure data, but the access is minimized and neither the access rights nor the data are passed along to other untrusted programs or back to an untrusted caller.

  • Appropriate confidence level . The program has been examined and rated at a degree of trust appropriate for the kind of data and environment in which it is to be used.

Trusted software is often used as a safe way for general users to access sensitive data. Trusted programs are used to perform limited (safe) operations for users without allowing the users to have direct access to sensitive data.

There can be degrees of trust; unlike security, trust is not a dichotomy. For example, you trust certain friends with deep secrets, but you trust others only to give you the time of day. Trust is a characteristic that often grows over time, in accordance with evidence and experience. For instance, banks increase their trust in borrowers as the borrowers repay loans as expected; borrowers with good trust (credit) records can borrow larger amounts. Finally, trust is earned, not claimed or conferred.

The adjective “trusted” appears many times in this chapter, as in

  • trusted process (a process that can affect system security, or a process whose incorrect or unsecure execution could violate system security policy)

  • trusted software (the software portion of a system that can be relied upon to enforce security policy)

  • trusted product (an evaluated and approved product)

  • trusted computing base (the set of all protection mechanisms within a computing system, including hardware, firmware, and software, that together enforce a unified security policy over a product or system)

  • trusted system (a system that employs sufficient hardware and software integrity measures to allow its use for processing sensitive information)

These definitions are paraphrased from [ NIS91 ]. Common to these definitions are the concepts of

  • enforcement of security policy

  • sufficiency of measures and mechanisms

  • objective evaluation

Thus, the adjective “trusted” has a precise meaning in computer security.

A trusted system has three characteristics:

  • a defined policy that details what security qualities it enforces

  • appropriate measures and mechanisms by which it can enforce that security adequately

  • independent scrutiny or evaluation to ensure that the mechanisms have been selected and implemented properly so that the security policy is in fact enforced.

History of Trusted Systems

Trusted systems have had a long and fitful history in computer security. The need for secure systems became apparent early in the days of multiuser, shared computing, in the 1960s. Willis Ware [ WAR70 ] chaired a committee expressing the need for stronger security enforcement in systems. During the 1970s, research and actual systems demonstrated the capability of and need for such systems, culminating in the report from James Anderson’s committee [ AND72 ] that called for development of a process for obtaining more trustworthy systems.

Starting with drafts in the late 1970s, the U.S. Department of Defense wrote the Trusted Computer System Evaluation Criteria (called the TCSEC or Orange Book , because of the color of its cover), a document that specified functionality, design principles, and an evaluation methodology for trusted computer systems. Over time, the same approach was extended to network components and database management systems. For reasons we explain shortly, this scheme did not reach its intended degree of acceptance. Nevertheless, the TCSEC laid the groundwork for a progression of advancements on that foundation. Also important is that this progression started in the United States, but rapidly expanded to involve Canada, Germany, England, the Netherlands, and France (as well as work in other countries), engendering a truly international approach to trusted computer systems, depicted in the timeline of Figure 5-16 .

An illustration shows the Trusted Systems Design and Evaluation Criteria.

FIGURE 5-16 Trusted Systems Design and Evaluation Criteria

A timeline arrow shows the following data: 1970 - Security Controls for Computer Systems; 1972 - Security Technology Planning Study; 1983 - Trusted Computer System Evaluation Criteria; 1988 - British, German, French Criteria; 1991 - E.C. Information Technology Security Evaluation Criteria; 1992 - Combined Federal Criteria; and 1994 - Common Criteria.

Orange Book (TCSEC): first attempt to codify principles and requirements for secure computing systems.

The 1980s and 1990s saw several candidates for evaluating the degree of a system’s trustedness, and these approaches converged between 1995 and 2003 in an international process for evaluation, called the Common Criteria for Information Technology Security Evaluation , or just the Common Criteria. Today, thanks to that standard, the market has many products whose trustworthiness has been independently confirmed.

In the next section we examine the functions important to a trusted system. Then, in the following section, we briefly describe the current trusted system evaluation and certification process.

Trusted Computing Base (TCB)

The trusted computing base , or TCB , is the name we give to everything in the trusted operating system that is necessary to enforce the security policy. Alternatively, we say that the TCB consists of the parts of the trusted operating system on which we depend for correct enforcement of policy.

Trusted computing base (TCB): everything necessary for a system to enforce its security policy

We can think of the TCB as a coherent whole in the following way. Suppose you divide a trusted operating system into the parts that are in the TCB and those that are not, and you allow the most skillful malicious programmers to write all the non-TCB parts. Since the TCB implements all the security, (including protecting itself), if the TCB has been implemented properly and according to the principles just laid out, nothing the malicious non-TCB parts do can impair the correct security policy enforcement of the TCB.

This definition gives you a sense that the TCB forms the fortress-like shell that protects whatever in the system needs protection. But the analogy also clarifies the meaning of trusted in trusted operating system: Our trust in the security of the whole system depends on the TCB.

Obviously, the TCB must be both correct and complete. Thus, to understand how to design a good TCB, we focus on the division between the TCB and non-TCB elements of the operating system and concentrate our effort on ensuring the correctness of the TCB.

TCB Functions

Just what constitutes the TCB? We can answer this question by listing system elements on which security enforcement could depend:

  • hardware , including processors, memory, registers, a clock, and I/O devices

  • some notion of processes , so that we can separate and protect security-critical processes

  • primitive files , such as the security access control database and identification and authentication data

  • protected memory , so that the reference monitor can be protected against tampering

  • some interprocess communication , so that different parts of the TCB can pass data to and activate other parts; for example, the reference monitor can invoke and pass data securely to the audit routine

It may seem as if this list encompasses most of the operating system, but in fact the TCB is only a small subset. For example, although the TCB requires access to files of enforcement data, it does not need an entire file structure of hierarchical directories, virtual devices, indexed files, and multidevice files. Thus, the TCB might contain a primitive file manager to handle only the small, simple security data files needed for the TCB. The more complex file manager to provide externally visible files could be outside the TCB. Figure 5-17 shows a typical division into TCB and non-TCB sections.

An illustration shows the System Separated into TCB and Non hyphen TCB Sections.

FIGURE 5-17 System Separated into TCB and Non-TCB Sections

A System shows TCB and Non-TCB Sections. TCB includes the following: Primitive I/O; Basic operations; Clocks, timing; Interrupt handling; Hardware: registers, memory; Capabilities. Non-TCB (shaded) includes the following: User applications; Utilities; User request interpreter; User process coordination, synchronization; User environment: objects, names (e.g., files); User I/O; Procedures, user processes; Creation and deletion of user objects; Directories; Extended types; and Segmentation, paging, memory management.

The TCB, which must maintain the secrecy and integrity of each domain, monitors four basic interactions.

  • Process activation . In a multiprogramming environment, activation and deactivation of processes occur frequently. Changing from one process to another requires a complete change of registers, relocation maps, file access lists, process status information, and other pointers, much of which is security-sensitive information.

  • Execution domain switching . Processes running in one domain often invoke processes in other domains to obtain more or less sensitive data or services.

  • Memory protection . Because each domain includes code and data stored in memory, the TCB must monitor memory references to ensure secrecy and integrity for each domain.

  • I/O operation . In some systems, software is involved with each character transferred in an I/O operation. This software connects a user program in the outermost domain to an I/O device in the innermost (hardware) domain. Thus, I/O operations can cross all domains.

TCB Design

The division of the operating system into TCB and non-TCB aspects is convenient for designers and developers because it means that all security-relevant code is located in one (logical) part. But the distinction is more than just logical. To ensure that the security enforcement cannot be affected by non-TCB code, TCB code must run in some protected state that distinguishes it and protects it from interference or compromise by any code outside the TCB. Thus, the structuring into TCB and non-TCB must be done consciously.

However, once this structuring has been done, code outside the TCB can be changed at will, without affecting the TCB’s ability to enforce security. This ability to change helps developers because it means that major sections of the operating system—utilities, device drivers, user interface managers, and the like—can be revised or replaced any time; only the TCB code must be controlled more carefully. Finally, for anyone evaluating the security of a trusted operating system, a division into TCB and non-TCB simplifies evaluation substantially because non-TCB code need not be considered.

The TCB is separated to achieve self-protection and independence.

TCB Implementation

Security-related activities are likely to be performed in different places. Security is potentially related to every memory access, every I/O operation, every file or program access, every activation or termination of a user, every creation of a new execution thread, and every interprocess communication. In modular operating systems, these separate activities can be handled in independent modules. Each of these separate modules, then, has both security-related and other functions.

Collecting all security functions into the TCB may destroy the modularity of an existing operating system. A unified TCB may also be too large to be analyzed easily. Nevertheless, a designer may decide to separate the security functions of an existing operating system, creating a security kernel. This form of kernel is depicted in Figure 5-18 .

An illustration shows the Security Kernel.

FIGURE 5-18 Security Kernel

Four concentric circles represent the Security Kernel. Small shaded circles represent Security activities. The first/inner circle shows no shaded circles and is labeled, Level 1: Hardware. The second circle shows five shaded circles and is labeled, Level 2: Operating System Kernel: Hardware interactions; and Access control. The third circle shows thirteen shaded circles and is labeled, Level 3: Operating System: Resource allocation; Sharing; Access control; and Authentication functions. The fourth circle shows no shaded circles and is labeled, Level 4: User Tasks.

A more sensible approach is to design the security kernel first and then design the operating system around it. This technique was used by Les Fraim and his team at Honeywell [ FRA83 ] in the design of a prototype for its secure operating system, Scomp. That system contained only twenty modules to perform the primitive security functions, and these modules consisted of fewer than 1,000 lines of higher-level-language source code. Once the actual security kernel of Scomp was built, its functions grew to contain approximately 10,000 lines of code.

In a security-based design, the security kernel forms an interface layer, just atop system hardware. The security kernel monitors all operating system hardware accesses and performs all protection functions. The security kernel, which relies on support from hardware, allows the operating system itself to handle most functions not related to security. In this way, the security kernel can be small and efficient. As a byproduct of this partitioning, computing systems have at least three execution domains: security kernel, operating system, and user. This situation is depicted in Figure 5-1 at the start of this chapter.

Secure Startup

Startup is a known weak point in system design. Before the operating system is fully functional, its protection capabilities are limited. As more pieces become operational, they exercise more complete control over resources. During startup, the nature of the threats is also lowered because users are not yet active and network connections have not yet been established.

Secure startup ensures no malicious code can block or interfere with security enforcement.

Designers of trusted systems recognized the vulnerability at system startup, especially if it was a restart from a previous failure. Thus, trusted system design documents such as the Orange Book [ DOD85 ] require developers to demonstrate that when the system starts, all security functions are working properly and no effects remain from any previous system session.

Trusted Path

Critical to security is the association of a human user to an operating system’s internal construct of a subject. In Chapter 2 we detail authentication techniques by which a user could prove an identity to the operating system.

But what about the other direction: A user cannot be expected to expose unique validating data to any software that requests it. (You would not—or at least should not—enter your password on any screen that prompts you.) As you well know, any moderately competent programmer can write code to pop up a box with fields for user name and password. How can you be assured the box comes from and passes entered data to the password manager?

How do you know that box is legitimate? This question is really just the other side of authentication: The application wants to ensure that you are who you say you are, but you also need to know that the application is what it says it is.

This problem is difficult to solve at the application level, but at the operating system level it is a little easier to solve. A trusted path is an unforgeable connection by which the user can be confident of communicating directly with the operating system, not with any fraudulent intermediate application. In the early days of Microsoft Windows, the user had to press the control, alt, and delete keys simultaneously to activate the login prompt. The keyboard device driver trapped that one sequence and immediately transferred control to the operating system’s authentication routine. Thus, even if an application could forge a convincing-looking login screen, the user knew the only safe way to log in was to press control–alt–delete.

A trusted path precludes interference between a user and the security enforcement mechanisms of the operating system.

Trusted systems required a trusted path for all security-critical authentication operations, such as changing a password. The Orange Book [ DOD85 ] requires “a trusted communication path between itself and user for initial login and authentication. Communications via this path shall be initiated exclusively by a user.”

Object Reuse

One way that a multiuser computing system maintains its efficiency is to reuse objects. The operating system controls resource allocation, and as a resource is freed for use by one user or program, the operating system permits the next user or program to access the resource. But reusable objects must be carefully controlled, lest they create a serious vulnerability.

To see why, consider what happens when a new file is created. Usually, space for the file comes from a pool of freed, previously used space on a disk, in memory, on a flash memory stick, or on another storage device. Released space is returned to the pool “dirty,” that is, still containing the data from the previous user. Because most users would write to a file before trying to read from it, the new user’s data obliterate the previous owner’s data, so there is no inappropriate disclosure of the previous user’s information. However, a malicious user may claim a large amount of space and then scavenge for sensitive data by reading before writing. This kind of attack is called an object reuse failure.

Object sanitization ensures no leakage of data if a subject uses a memory object released by another subject.

To prevent object reuse leakage, operating systems clear (that is, overwrite) all space to be reassigned before allowing the next user to access it. Magnetic media are particularly vulnerable to this threat. Very precise and expensive equipment can sometimes separate the most recent data from the data previously recorded, from the data before that, and so forth. This threat, called magnetic remanence , is beyond the scope of this book; for more information, see [ NCS91b ]. In any case, the operating system must take responsibility for “cleaning” the resource before permitting access to it.

Audit

Trusted systems must also track any security relevant changes, such as installation of new programs or modification to the operating system. The audit log must be protected against tampering, modification, or deletion other than by an authenticated security administrator. Furthermore, the audit log must be active throughout system operation. If the audit medium fills to capacity (for example, if audit records written to a disk use all space on the disk), the system is to shut down.

The Results of Trusted Systems Research

The original purpose of the Orange Book was to ensure a range of trustworthy, security-enforcing products, primarily for use to protect military sensitive information for the United States. The Orange Book became a U.S. Department of Defense standard, and a regulation called for “C2 by 92,” mandating a modest level of trustworthiness for all new Defense Department computers by 1992. That mandate was never enforced, and for a while it seemed as though the effort had achieved nothing.

Trusted Systems Today

Significant thought and money was invested during the 1980s and 1990s on design and implementation of trusted systems. Research and development projects such as PSOS [ NEU80 ], KSOS [ MCC79 ], KVM [ GOL77 ], Scomp [ FRA83 ], Multics [ SAL74 ], Trusted Xenix, Trusted Mach [ BRA88 ], GEMSOS [ NCS95 ], and Vax VMM [ KAR90 ] helped establish the principles of high-assurance, security-enforcing trusted systems.

Today, however, few security people have ever heard of these systems, let alone know what they involve. These projects have disappeared from the security scene for at least two reasons: First, the market for high-assurance, security-enforcing operating systems is quite limited. Even users dealing with sensitive data, such as highly classified military or diplomatic information, found they preferred or even needed functionality, performance, and usability more than security. Second, these systems were sidelines to manufacturers’ major system offerings, and maintaining such separate product lines became untenable. By now, as Sidebar 5-5 describes, even the word “trust” has lost some of its value.

Fortunately, however, the lessons of trusted systems design endure. Design principles such as least privilege and separation; features such as trusted path, secure startup, and object reuse; and concepts such as the security kernel and reference monitor live on today. For example, today’s firewall, the widely used network security product (which we cover in the next chapter), is an instantiation of the reference monitor concept, and Microsoft’s Trustworthy Computing (described in Chapter 3 ) is heavily based on trusted systems principles. Thus, we encourage you to adopt the historian’s philosophy that understanding the past can help you appreciate the present and prepare for the future.

Sidebar 5-5 Can Trust Be Certified?

Is it possible to rely on a service or search engine to verify that an online site is trustworthy? TRUSTe was founded as a nonprofit organization in 1997 by privacy advocates to implement a certification to assure users that a website will protect the user’s privacy. In 2006, TRUSTe also introduced a “trusted download program,” designed to confirm to users that software downloaded from a site is neither adware nor spyware. The TRUSTe designation, called a trustmark, is now administered by a subsidiary of the TrustArc corporation.

Edelman [ EDE06 ] investigated the trustworthiness of sites holding a TRUSTe certification. Dismayingly, he found that TRUSTe-certified sites were twice as untrustworthy as uncertified sites. Similarly, he found that relying on well-known and trusted search engines also increases the likelihood of being directed to an untrustworthy site.

In 2008, Edelman found that the website coupons.com stored data in deceptive file names and registry entries designed to look like part of Windows. The files had names such as c:\windows\WindowsShellOld.Manifest.1 and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Controls Folder\Presentation Style. Moreover, coupons.com failed to remove these files when specifically requested to do so. In February 2008, Edelman reported the practice to TRUSTe since coupons.com displayed a TRUSTe certificate; shortly thereafter, TRUSTe claimed that the problem had been resolved with new software and that coupons.com was again trustworthy. But Edelman’s further analysis showed that the deceptive file names and registry entries were still there, even after a user ran an uninstall program ( benedelman.org/ ).

In 2014, the U.S. Federal Trade Commission (FTC) charged that TRUSTe misrepresented its privacy certification program. The FTC complaint alleged that from 2006 to 2013, TRUSTe failed, in over 1,000 instances, to recertify privacy checks on the companies it certified, as promised. Furthermore, the FTC stated that TRUSTe perpetuated its misrepresentation as a nonprofit entity. (In 2008 TRUSTe began operating as a for-profit entity.) TRUSTe agreed to pay a US$200,000 penalty in 2014 to settle the complaint.

The Orange Book—Overview

In the late 1970s, when the Orange Book was originally developed, the only model for computing was the mainframe computer with access and data shared by multiple users. Although in settings such as universities and laboratories, loosely controlled sharing matched a relatively free exchange of information, military and major commercial users needed assurance that unauthorized users could not access sensitive data. The military was concerned for the protection of classified information, and corporate users needed to protect trade secrets, business plans, and accounting and personnel records. Thus, the goal of the Orange Book was to spur development of multiuser systems that were highly resistant to unacceptable information flows.

That focus led to a two-part scale for rating trusted systems. There were six rankings, in order: C1 (lowest), C2, B1, B2, B3, and A1 (highest). At each step, both the security features and the necessary assurance of correct functioning increased, with a major feature jump between C2 and B1, and major assurance upgrades in the steps to B2, B3, and A1. Features and assurance were tied as a package at each of these six rankings.

Bundling features and assurance was critical to the objective of the Orange Book because its authors thought critical features (for example, being able to protect classified data on a system that also allowed uncleared users) needed to be coupled with high assurance. However, strict association also severely limited the book’s applicability: Commercial users wanted high assurance but had little need for the rigid structure of classified data. Thus, after some straw-man structures and much discussion, representatives from a group of nations settled on the more flexible structure now known as the Common Criteria.

Common Criteria

The Common Criteria writers made two crucial advances over the Orange Book. First, they agreed to a separation between functions and assurance. Each user and each developer had the option of selecting an appropriate set of features and, independently , a level of assurance at which those features would be implemented. Although a critical-functionality, low-assurance product might be of dubious value, if a developer perceived a market, the scheme should not block the invention. More likely, the writers assumed, a developer might enter the process with a moderate-functionality moderate-assurance product and improve both functionality and assurance with subsequent offerings.

The Common Criteria defined seven assurance levels , EAL1 (lowest) through EAL7 (highest). At the lowest level a developer asserts to having followed a practice, with rigor rising until at the higher levels the practices are more stringent and compliance is verified by an independent testing laboratory.

The second breakthrough of the Common Criteria was to leave functionality unlimited. With hindsight, the Orange Book writers would have realized that building a design framework around multiuser, stand-alone mainframe computing was doomed if ever the computing paradigm shifted. That shift occurred almost as soon as the Orange Book was adopted as a Defense Department standard in 1985, unfortunately coinciding with the rise of the personal computer and networking.

Authors of the Common Criteria accepted that they could not foresee the kinds of products to be created in the future. Thus, they allowed for an open-ended set of protection profiles that could specify security features for particular new product types, such as firewalls or intrusion detection devices, neither of which was commercially available when the Orange Book was written.

As this book is written, the Common Criteria has only a single protection profile for operating systems (those have remained relatively stable over time), but there are 50 profiles for integrated circuits and smartcard devices, showing the blossoming of such products. Some figures on Common Criteria–certified products as of mid-2022 are shown in Tables 5-3 and 5-4 .

Common Criteria: multinational standard for security evaluation; separates criteria into functionality and effectiveness

Table 5-3 Evaluated Products by Year

Year Number of Certified Products
2010 1
2014 28
2017 190
2020 347
2021 397
2022 (partial year) * 239
All years 1,660

* Current data on products certified under the Common Criteria scheme are available at commoncriteriaportal.org .

Table 5-4 Evaluated Products by Type (partial list)

Product Type Number of Certified Products
Access control 26
Data protection 62
ICs, smartcards, and related devices 578
Multifunction devices 270
Network and network devices 236
Operating systems 55

This brief overview of trusted systems has explored qualities of an operating system that let it enforce security reliably. As you have learned, operating systems are essential to secure computing because they (and physical hardware) control access to all resources. The reference monitor must be unbypassable: If someone can evade the access control mechanism, there is no control.

Next we turn to a fatal attack on operating systems, the rootkit. Figuratively, a rootkit is malicious code that gets beneath an operating system, in a layer between it and hardware. So positioned, the rootkit can circumvent, disable, or alter the work of the operating system; in essence, the rootkit controls the operating system. As you can well imagine, rootkits are a pernicious threat for computer system security.

5.3 Rootkits

In the Unix operating system, root is the identity of the most powerful user, owning sensitive system resources such as memory and performing powerful actions such as creating users and killing processes. The identity root is not normally a user with login credentials; instead it is the name of the entity (subject) established to own and run all fundamental (critical) system tasks (and these tasks create the remaining user identities such as admin and ordinary users). Thus, becoming a task with root privilege is a hacker’s ultimate goal because from that position the hacker has complete and unrestricted system control.

Root (in a Unix system): identity of the most privileged subject

As you have seen, there are two types of attackers: those who craft new attacks and those who merely execute someone else’s brainchild. The latter far outnumber the former, but the new attacks are especially troublesome because they are unknown to protection tools and response teams. As we explain in Chapter 3 , people who execute attack code from someone else are sometimes pejoratively called “script kiddies” because they simply execute someone else’s attack script or package. An attack package that attains root status is called a rootkit . In this section we look at rootkits to see how the power of root can be used to cause serious and hard-to-eradicate harm.

Rootkit: tool or script that obtains privileges of root

Example: Phone Rootkits

Researchers at Rutgers University [ BIC10 ] demonstrated an ability to load a rootkit onto a mobile phone. The operating system of a mobile phone is rather simple, although smartphones with their rich functionality demand a more complex operating system to support a graphical user interface, downloadable applications, and files of associated data. The complexity of the operating system led to more opportunities for attack and, ultimately, a rootkit. Rootkits can exist on any operating system; the Rutgers researchers chose to investigate this platform because it is relatively simple, and many users forget—or are unaware—it is an operating system that can be compromised. The points in this research apply equally to operating systems for more traditional computers.

In one test, the researchers demonstrated a rootkit that could turn on a phone’s microphone without the owner’s knowing it happened. In such a case, the attacker would send an invisible text message to the infected phone, telling it to place a call and turn on the microphone; imagine the impact of such an attack when the phone’s owner is in a meeting on which the attacker wants to eavesdrop.

In another demonstration, these same researchers displayed a rootkit that responds to a text message query by relaying the phone’s location as furnished by its GPS receiver. This would enable an attacker to track the owner’s whereabouts.

In a third test, the researchers showed a rootkit that could turn on power-hungry capabilities—such as the Bluetooth radio and GPS receiver—to quickly drain the battery. People depend on cell phones for emergencies. Imagine a scenario in which the attacker wants to prevent the victim from calling for help, for example, when the attacker is chasing the victim in a car. If the phone’s battery is dead, the cell phone cannot summon help.

The worst part of these three attacks is that they are effectively undetectable: The cell phone’s interface seems no different to the user who is unaware of danger. The rootkit can thus perform actions normally reserved for the operating system but does so without the user’s knowledge.

Rootkit Characteristics

A rootkit is a variation on the virus theme. A rootkit is a piece of malicious code that goes to great lengths not to be discovered or, if discovered and removed, to reestablish itself whenever possible. The name rootkit refers to the code’s attempt to operate as root, the ultra-privileged user of a Unix system.

Put yourself in the mind of an attacker. If you want persistency, you want an attack that is really difficult to detect so your victim cannot find and try to eradicate your code. Two conditions can help you remain undiscovered: your code executing before other programs that might block your execution and your not being detected as a file or process. You can achieve these two goals together. Being in control early in the system boot cycle would allow you to control the other system defenses instead of their controlling you. If your code is introduced early enough, it can override other normal system functions that would detect its presence.

Rootkits Evade Detection

Malicious code consists of executable files, just like all other code. To be able to execute, malicious code must locate and invoke its pieces, which usually implies that some of these pieces are predictable: They are of a certain name, size, location, or form; but, as we explain in Chapter 3 , that same predictability makes them targets for tools that search for malicious code (such as virus checkers). An attack might involve the file mal_code.exe stored in c:/winnt/apps . When you run a file explorer program on that directory, mal_code.exe will appear in the listing, and you might recognize and eradicate the file.

Antivirus tools (and most programs) do not contain code to query the disk, determine the disk format, identify files and where they are stored, find the file names and properties from an index table, or structure the results for use and display. Instead, the tools call built-in functions through an application programming interface (API) to get this information. For example, as shown in Figure 5-19 , the Windows API functions FindFirstFile() and FindNextFile() return the file name of the first or next file that matches certain criteria. The criteria may be null, implying to select all files. These functions in turn call NT Kernel “native mode” system functions, such as NTQueryDirectoryObject. At the end of this call chain is a simple function call: Load a number into a register to represent the specific system function to perform, and execute a call instruction to the operating system kernel. The operating system returns descriptive information, and the higher-level functions format and present that information. These steps reflect the layered functioning of the operating system depicted in the figures earlier in this chapter.

An illustration shows the Using APIs and Function Calls to Inspect Files.

FIGURE 5-19 Using APIs and Function Calls to Inspect Files

Inspect all files: FindFirstFile(); check file; FindNextFile(); repeat. This leads to Windows API. A double-head arrow points between Windows AP and NTQueryDirectoryObject. Another double-head arrow points between NTQueryDirectoryObject and Kernel Native Interface. Another double-head arrow points between Kernel Native Interface and Device driver functions. Another double-head arrow points between the Device driver functions and the device.

What if malicious code intruded on that sequence of calls? For example, consider the directory listing shown in Figure 5-20 , which depicts the true contents of a subdirectory. An attacker could intercept that listing to change it to the one shown in Figure 5-21 , in which the file mal_code.exe does not appear.

A sample Unmodified Directory Listing.

FIGURE 5-20 Unmodified Directory Listing

The Unmodified Directory Listing reads as follows: Volume in drive C has no label. Volume Serial Number is E 4C5 - A911. Directory of C : \ WINNT \ APPS. 01-09-14 13:34 < DIR >. 01-09-14 13:34 < DIR >.. 07-12 15:00 82,944 CLOCK . AVI 24-07-12 15:00 17,062 Coffee Bean. b m p 24-07-12 15:00 80 EXPLORER . S C F 06-08-14 15:00 256,192 mal _ code . exe 22-08-08 01:00 373,744 PTDOS . EXE 21-02-08 01:00 766 PTDOS . ICO 19-06-10 15:05 73,488 regedit . exe 24-07-12 15:00 35,600 TASKMAN . EXE 9 File(s) 966,852 bytes 2 Dir(s) 13,853,132,800 bytes free 14-10-12 17:23 126,976 UNINST32 . EXE 9 File(s) 966,852 bytes 2 Dir(s) 13,853,132,800 bytes free.

A sample Modified Directory Listing.

FIGURE 5-21 Modified Directory Listing

The Modified Directory Listing reads as follows: Volume in drive C has no label. Volume Serial Number is E 4C5 - A 911. Directory of C : \ WINNT \ APPS. 01-09-14 13:34 < DIR > . 01-09-14 13:34 < DIR > .. 24-07-12 15:00 82,944 CLOCK . AVI 24-07-12 15:00 17,062 Coffee Bean . b m p 24-07-12 15:00 80 EXPLORER . S C F 22-08-08 01:00 373,744 PTDOS . EXE 21-02-08 01:00 766 PTDOS . ICO 19-06-10 15:05 73,488 regedit . exe 24-07-12 15:00 35,600 TASKMAN . EXE 14-10-12 17:23 126,976 UNINST32 . EXE 8 File(s) 710,660 bytes 2 Dir(s) 13,853,472,768 bytes free.

What happened? Remember that the operating system functions are implemented by tasks placed throughout the operating system. The utility to present a file listing uses primitives such as FindNextFile() and NTQueryDirectoryObject. To remain invisible, the rootkit intercepts these calls so that if the result from FindNextFile() points to mal_code.exe , the rootkit skips that file and executes FindNextFile() again to find the next file after mal_code.exe . The higher-level utility to produce the listing keeps the running sum of file sizes for the files of which it receives information, so the total in the listing correctly reports all files except mal_code.exe . The stealthy operation of this rootkit is shown in Figure 5-22 .

An illustration shows the Rootkit Filtering File Description Result.

FIGURE 5-22 Rootkit Filtering File Description Result

The Intercepted function call leads to Will call's result reveal rootkit? If yes, Execute call but monitor result and adjust as necessary. If no, Pass call to operating system function.

These listings were produced with the simple, low-level dir command to represent the kind of output produced by these system APIs. If the attacker intercepts and modifies either the input going into the API or the output coming from the API, the effect is to make the file mal_code.exe invisible to higher-level callers. Thus, if an antivirus tool is scanning by obtaining a list of files and inspecting each one, the tool will miss the malicious file.

A rootkit effectively becomes part of the operating system kernel. In this example, the rootkit interferes with enumerating files on a disk, so it does not pass its own files’ names to a virus checker for examination. But, because a rootkit is integrated with the operating system, it can perform any function the operating system can, usually without being detectable. For example, it can replace other parts of the operating system, rewrite pointers to routines that handle interrupts, or remove programs (such as malicious code checkers) from the list of code to be invoked at system startup. These actions are in addition to more familiar malicious effects, such as deleting files, sending sensitive data to remote systems, and forwarding harmful code to email contacts.

A rootkit runs with privileges and position of an operating system component. It is loaded automatically as part of operating system startup, and because of its position, it can intercept and modify operating system calls and return values, as shown in Figure 5-23 . The operating system performs audit logging, but the rootkit can fail to pass on its own activities to be logged. A rootkit is in prime position to remain undiscovered and undiscoverable and to perform any action unconstrained.

An illustration shows the Rootkit Intercepts and Modifies Basic Operating System Functions.

FIGURE 5-23 Rootkit Intercepts and Modifies Basic Operating System Functions

Inspect all files: FindFirstFile(); check file; FindNextFile(); repeat. This leads to Windows API. A double-head arrow points between Windows AP and NTQueryDirectoryObject. Another double-head arrow points between NTQueryDirectoryObject and Kernel Native Interface. Another double-head arrow points between Kernel Native Interface and Rootkit filters call and result. Another double-head arrow points between Rootkit filters call and Device driver functions. Another double-head arrow points between the Device driver functions and the device.

Rootkits Operate Unchecked

In Chapter 3 we introduced the concept of malicious code, such as a virus or Trojan horse that is propagated from system to system and that operates under the authority of the current user. As we said in that chapter, one objective of malicious code authors is to escalate privilege, that is, to run with the greater privileges of an administrator or more powerful user; obviously, the more privileges code has, the more harm it can cause. The ultimate privilege level is the operating system, so to replace some or all operating system functions amounts to achieving the highest power.

Because they want to remain undiscovered, rootkits can be difficult to detect and eradicate, or even to count. By one estimate, rootkits comprise 7% of all malicious code [ TRE10 ]. As Sidebar 5-6 describes, rootkits can also interfere with computer maintenance because their functionality can become intertwined with other operating system functions being modified.

Sidebar 5-6 Rootkit Kills Kernel Modification

In February 2010, Microsoft issued its usual monthly set of operating system updates, including one patch called MS10-015, rated “important.” The patch was to fix one previously publicized vulnerability and one unpublicized one. Microsoft advises users to install patches as soon as possible.

Unfortunately, this patch apparently interfered with the operation of a malicious rootkit in a rather dramatic way. After releasing the patch, Microsoft was inundated with complaints from users who installed the patch and suddenly found that their computers went into an unending loop of rebooting. Microsoft issued this advice: “After you install this update on a 32-bit version of Microsoft Windows, you may receive a Stop error message on a blue screen that causes the computer to restart repeatedly. This problem may be caused by a conflict between the security update and malware that is resident on the system. This problem is not a quality issue with the security update, and the issue is not specific to any OEM” [ MIC10b ]. Anyone whose machine was already stuck continually rebooting could not, of course, read the message Microsoft posted.

Apparently on system startup, the TDL3 or Alureon rootkit built a table, using the fixed addresses of specific Windows kernel functions. In the Microsoft patch, these addresses were changed, so when TDL3 received control and tried to invoke a (real) kernel function, it transferred to the wrong address, and the system shut down with what is known as the “blue screen of death” (the monitor displays a text error message against a blue background and reboots).

It is impossible to know the prevalence of Alureon or any rootkit in the computer population at large. Microsoft receives reports of the infections its Malicious Software Removal Tool removes from users’ machines. During April 2010, the tool removed 262,969 instances of one Alureon variant, so the interaction with MS10-015 was likely to be serious.

Rootkits interfere with normal system functions to remain hidden. As we describe, a common rootkit trick is to intercept file directory enumeration functions to conceal the rootkit’s presence. Ah, two can play that game. Suppose you suspect code is interfering with your file display program. You then write a program that displays files, examines the disk and file system directly to enumerate files, and compares these two results. A rootkit revealer, which we discuss later in this chapter, is just such a program.

Rootkits Exploit Permissions

As we have seen, an operating system is a collection of programs that implement functions of varying levels of security or criticality. We present a model of operating system protection rings in Figure 5-18 . Rootkits fit into that same kind of sensitivity scheme. The level at which the rootkit lives determines what it can do. Here are five positions for a rootkit.

  • User mode . The rootkit runs with only the permissions of the ordinary user. A user can cause significant self-harm, by deleting files, halting processes, or transferring stored sensitive data, for example.

  • Kernel mode . The rootkit has permissions to modify other parts of the operating system or to halt executing processes.

  • Bootkit . The rootkit places itself in a place so that it is activated the next time (and usually each succeeding time) the system is booted; it effectively becomes embedded within (hence, a part of) the operating system.

  • Hypervisor or virtual machine . The rootkit runs under the operating system, intercepting ordinary operating system functions and passing to the real operating system only those functions the rootkit wants to be executed.

  • Hardware or firmware . The rootkit is embedded in the hardware or the writable microcode that executes individual machine instructions.

The permissions or strength of a rootkit derive from what control it has over the stream of execution. A user rootkit can control only what the user does. A kernel rootkit can control any less-privileged operating system task.

Eradicating a rootkit becomes increasingly difficult as we move from top to bottom of this list. To understand why, think of commands that would detect and erase a rootkit’s code. A rootkit in user mode is easily detected and obliterated by the operating system. By contrast, a rootkit in the virtual machine that manages the operating system can counter any attempts by the operating system to control the rootkit, so it is far more difficult to erase.

Rootkits Usurp Control

Rootkits gain control in the same ways as any other malicious code. Sometimes they are planted by a Trojan horse; other times they are inadvertently distributed by manufacturers as part of the installation code of an application or an operating system component. (We describe such an example in the next section.) A rootkit can also replace a known piece of the operating system, such as a library service (a DLL) or a subcomponent; replacing the stored code of that piece means that the next time the operating system calls for the function of that piece, the rootkit acts instead of the regular operating system component. Another way malicious actors plant rootkits is by exploiting a security vulnerability.

Rootkits are a potent type of malicious code that will not be squelched soon. They are stealthy and powerful—the ultimate silent but deadly type of malicious code.

Rootkit Case Studies

We conclude this section with case studies of two other rootkits, again from history, but useful examples because they display many of the rootkit traits just described.

Sony XCP Rootkit

A computer security expert named Mark Russinovich developed a rootkit revealer , which he ran on one of his systems. Instead of using a high-level utility program like the file manager to inventory all files, Russinovich wrote code that called the NTQueryDirectoryObject function directly. Summing the file sizes in his program, he compared the directory size against what the file manager reported; a discrepancy led him to look further. He was surprised to find a rootkit [ RUS05 ]. On further investigation, he determined the rootkit had been installed when he loaded and played a Sony music CD on his computer. Princeton University researchers Edward Felten and Alex Halderman [ FEL06 ] extensively examined this rootkit, named XCP (short for extended copy protection). Although this example is old, it is a good example of the steps a malware author takes to write a rootkit and of the missteps a developer makes to allow the rootkit to seize control.

What XCP Does

Sony music created the XCP rootkit that was installed (automatically and without the user’s knowledge) from the Sony music CD to prevent a user from copying the tunes, while allowing the user to play the CD as audio. To do this, Sony includes its own special music player that is allowed to play the CD. But XCP interferes with any other access to the protected music CD by garbling the result any other process would obtain in trying to read from the CD. That is, it intercepts any functional call to read from the CD drive. If the call originated from a music player for a Sony CD, XCP redirects the result to Sony’s special music player. If the call is from any other application for a Sony CD, the rootkit scrambles the result so that it is meaningless as music and passes that uninterpretable result back to the calling application.

The rootkit has to install itself when the CD is first inserted in the PC’s drive. To do this, XCP depends on a “helpful” feature of Windows: With the “autorun” feature, Windows looks on each newly inserted CD for a file with a specific name, and if it finds that, it opens and executes the file without the user’s involvement. (The file name can be configured in Windows, although it is autorun.exe by default.) You can disable the autorun feature; see [ FEL06 ] for details.

XCP has to hide from the user so that the user cannot just remove or disable it. So the rootkit does as we just described: It blocks display of any program whose name begins with $sys$ (which is how it is named). Unfortunately for Sony, this feature concealed not just XCP but any program beginning with $sys$ from any source, malicious or not. So any virus writer could conceal a virus just by naming it $sys$virus-1, for example.

Sony did two things wrong: First, as we just observed, it distributed code that inadvertently opens an unsuspecting user’s system to possible infection by other writers of malicious code. Second, Sony installed that code without the user’s knowledge, much less consent, and it employed strategies to prevent the code’s removal.

Patching the Penetration

The story of XCP became widely known in November 2005 when Russinovich described what he found, and several news services picked up the story. Faced with serious negative publicity, Sony decided to release an uninstaller for the XCP rootkit. However, do you remember from Chapter 3 why “penetrate and patch” was abandoned as a security strategy? Among other reasons, the pressure for a quick repair sometimes leads to shortsighted solutions that address the immediate situation and not the underlying cause: Fixing one fault often causes a failure somewhere else.

Sony’s uninstaller itself opened serious security holes. It was presented as a webpage that downloaded and executed the uninstaller. But the programmers did not check what code they were executing, and so the webpage would run any code from any source, not just the intended uninstaller. And worse, the code to perform downloads and installations remained on the system even after XCP was uninstalled, meaning that the vulnerability persisted. (In fact, Sony used two different rootkits from two different sources and, remarkably, the uninstallers for both rootkits had this same vulnerability.)

Impact

How many computers were infected by this rootkit? Nobody knows for sure. Security researcher Dan Kaminsky [ KAM06 ] found 500,000 references in DNS tables to the site the rootkit contacts, but some of those DNS entries could support accesses by hundreds or thousands of computers. How many users of computers on which the rootkit was installed are aware of it? Again, nobody knows, nor does anybody know how many of those installations might not yet have been removed.

Felten and Halderman [ FEL06 ] present an interesting analysis of this situation, examining how digital rights management (copy protection for digital media such as music CDs) leads to requirements similar to those for a malicious code developer. Levine et al. [ LEV06 ] consider the full potential range of rootkit behavior as a way of determining how to defend against them.

Automatic software updates, antivirus tools, spyware, even applications all do things without the user’s express permission or even knowledge. They also sometimes conspire against the user: Sony worked with major antivirus vendors so its rootkit would not be detected because keeping the user uninformed was better for all of them, or so Sony and the vendors thought.

TDSS Rootkits

TDSS is the name of a family of rootkits, TDL-1 through (currently) TDL-4, based on the Alureon rootkit, code discovered by Symantec in September 2008. You may remember Alureon from Sidebar 5-6 earlier in this chapter describing how a rootkit prevented a legitimate Microsoft patch from being installed. The TDSS group originated in 2008 with TDL-1, a relatively basic rootkit whose main function seemed to be collecting and exfiltrating personal data.

TDL-1 seemed to have stealth as its major objective, which it accomplished by several changes to the Windows operating system. First, it installed filter code in the stack of drivers associated with access to each disk device. These filters drop all references to files whose names begin with “tdl,” the file name prefix TDL uses for all its files. With these filters, TDL-1 can install as many files as it requires, anywhere on any disk volume. Furthermore, the filters block direct access to any disk volume, and other filters limit access to network ports, all by installation of malicious drivers, the operating system routines that handle communication with devices.

The Windows registry, the database of critical system information, is loaded with entries to cause these malicious drivers to reload on every system startup. The TDL-1 rootkit hides these registry values by modifying the NTEnumerateKey system function, used to list data items (keys) in the registry. The modification replaces the first few bytes of the system function with a jump instruction to transfer to the rootkit function, which skips over any rootkit keys before returning control to the normal system function. Modifying code by inserting a jump to an extension is called splicing , and a driver infected this way is said to have been hooked .

Splicing: a technique allowing third-party code to be invoked to service interrupts and device driver calls

In early 2009, the second version, TDL-2 appeared. Functionality and operation were similar to those of TDL-1, the principal difference being that the code itself was obscured by scrambling, encrypted, and padded with nonsense data such as words from Hamlet .

Later that year, the TDSS developers unleashed TDL-3. Becoming even more sophisticated, TDL-3 implemented its own file system so that it could be completely independent of the regular Windows functions for managing files using FAT (file allocation table) or NTFS (NT file system) technology [ DRW09 ]. The rootkit hooked to a convenient driver, typically atapi.sys, the driver for IDE hard disk drives, although it could also hook to the kernel, according to Microsoft’s Johnson [ JOH10 ]. At this point, TDSS developers introduced command and control servers with which the rootkit communicates to receive work assignments and to return data collected or other results. (We explore in detail distributed denial of service, another application of command and control servers, in Chapter 6 .)

TDL-3 also began to communicate by using an encrypted communications stream, effectively preventing analysts from interpreting the data stream. All these changes made the TDSS family increasingly difficult to detect. NetworkWorld estimated that in 2009, 3 million computers were controlled by TDSS, more than half of which were located in the United States. These controlled computers are sold or rented for various tasks, such as sending spam, stealing data, or defrauding users with fake antivirus tools.

But TDL-3 is not the end of the line. A fourth generation, TDL-4, appeared in Autumn 2010. This version circumvented the latest Microsoft security techniques.

TDL-4 follows the path of other TDSS rootkits by hooking system drivers to install itself and remain undetected. But during this time, Microsoft’s 64-bit Windows software implemented a cryptographic technique by which a portion of each driver is encrypted, using a digital signature, as we explain in Chapter 2 . Basically, Microsoft’s digital signatures let it verify the source and integrity of kernel-level code each time the code is to be loaded (ordinarily at system boot time). TDL-4 changes a system configuration value LoadIntegrityCheckPolicy so that the unsigned rootkit is loaded without checking [ FIS10b ]. TDL-4 infects the master boot record (MBR) and replaces the kernel debugger (kdcom.dll) that would ordinarily be available to debug kernel-level activity. The replaced debugger returns only safe values (meaning those that do not reveal TDL-4), making it difficult for analysts to investigate the form and function of this rootkit.

The sophistication of the TDSS family is amazing, as is its ability to adapt to system changes such as code integrity checking. The authors have invested a great amount of time in maintaining and extending this rootkit family, and they are likely to continue to do so to preserve the value of their investment.

Nonmalicious Rootkits

Not every rootkit is malicious. Suppose you are a manager of a company that handles very sensitive information: It may be intellectual property, in the form of the design and implementation of new programs, or perhaps it is the medical records of some high-profile patients who would not want their medical conditions to appear on the front page of a newspaper. Your employees need this information internally for ordinary business functions, but there is almost no reason such information should ever leave your company.

Because the value of this information is so high, you want to be sure nothing sensitive is included in email sent by your employees or by a malicious process acting under the name of an employee. Several products, with names like eBlaster and Spector, are rootkits that parents can install on children’s computers, to monitor the nature of email, messaging, and web searches. As rootkits, these products are invisible to the children and, even if detected, the products are difficult to disable or remove. Managers worried about illicit or unintentional exfiltration of sensitive information could use similar products.

Law enforcement authorities also install rootkits on machines of suspects so that agents can trace and even control what users of the affected machines do, but the suspects remain oblivious.

Thus, not every rootkit is malicious. In fact, security tools, such as antivirus software and intrusion detection and prevention systems, sometimes operate in a stealthy and hard-to-disable manner, just like rootkits. However, because this is a book about computer security, we now close by reiterating the system vulnerabilities that permit introduction of rootkits. The two vulnerabilities that contribute to installation of rootkits are that the operating system is complex and not transparent.

5.4 Conclusion

In this chapter we have surveyed the field of operating systems to develop several important security concepts. Operating systems are the first place we have seen detailed analysis of access control, and the first use of the reference monitor.

Because of its fundamental position in a computing system, an operating system cannot be weak. We have discussed the concept of trust and confidence in an operating system’s correctness. The strength of an operating system comes from its tight integration with hardware, its simple design, and its focus—intentionally or not—on security. Of course, an operating system has the advantage of being self-contained on a distinct platform.

In the next chapter we consider a critical part of modern computing: networks. Few computing activities these days do not involve networking. But the self-contained, tightly integrated character of an operating system definitely does not apply in networks. As we show, authentication and access control are harder to achieve in networks than in operating systems, and the degree of self-protection a network user can have is decidedly less than an operating system user. Securing networks is more of a challenge.

5.5 Exercises

1. Give an example of the use of physical separation for security in a computing environment.

2. Give an example of the use of temporal separation for security in a computing environment.

3. Give an example of an object whose sensitivity may change during execution. Describe the difficulties of an operating system handling such a change in sensitivity. For example, how does it deal with a subject who, having originally qualified for access to an object, now should lose that access right?

4. Respond to the allegation “An operating system requires no protection for its executable code (in memory) because that code is a duplicate of code maintained on persistent storage, such as a disk.”

5. Explain how a fence register is used for relocating a user’s program.

6. Can any number of concurrent processes be protected from one another by just one pair of base/bounds registers?

7. The discussion of base/bounds registers implies that program code is execute-only and that data areas are read-write-only. Is this ever not the case? Explain your answer.

8. A design using tag bits presupposes that adjacent memory locations hold dissimilar things: a line of code, a piece of data, a line of code, two pieces of data, and so forth. Most programs do not look like that. How can tag bits be appropriate in a situation in which programs have the more conventional arrangement of code and data?

9. What are some other modes of access that users might want to apply to code or data, in addition to the common read , write , and execute permission?

10. The BiiN model described in this chapter would support as many as 64,000 degrees of protection (16 bits of modes). Discuss how a system administrator could use this many states effectively. With only a few bits, read, write , and execute permissions are straightforward. What security applications could use such fine granularity?

11. If two users share access to a segment, they must do so by the same name. Must their protection rights to it be the same? Why or why not?

12. A problem with either segmented or paged address translation is timing. Suppose a user wants to read some data from an input device into memory. For efficiency during data transfer, often the actual memory address at which the data are to be placed is provided to an I/O device. The real address is passed so that time-consuming address translation does not have to be performed during a very fast data transfer. What security problems does this approach bring?

13. A directory is also an object to which access should be controlled. Why is it not appropriate to allow users to modify their own directories?

14. Why should the directory of one user not be generally accessible to other users (not even for read-only access)?

15. File access control relates largely to the secrecy dimension of security. What is the relationship between an access control matrix and the integrity of the objects to which access is being controlled?

16. One feature of a capability-based protection system (described in Chapter 2 ) is the ability of one process to transfer a copy of a capability to another process. Describe a situation in which one process should be able to transfer a capability to another.

17. Describe a mechanism by which an operating system can enforce limited transfer of capabilities. That is, process A might transfer a capability to process B, but A wants to prevent B from transferring the capability to any other processes.

Your design should include a description of the activities to be performed by A and B, as well as the activities performed by and the information maintained by the operating system.

18. List two disadvantages of using physical separation in a computing system. List two disadvantages of using temporal separation in a computing system.

19. Explain why asynchronous I/O activity is a problem with many memory protection schemes, including base/bounds and paging. Suggest a solution to the problem.

20. Suggest an efficient scheme for maintaining a per-user protection scheme. That is, the system maintains one directory per user, and that directory lists all the objects to which the user is allowed access. Your design should address the needs of a system with 1,000 users, of whom no more than 20 are active at any time. Each user has an average of 200 permitted objects; there are 50,000 total objects in the system.

21. A flaw in the protection system of many operating systems is argument passing. Often a common shared stack is used by all nested routines for arguments as well as for the remainder of the context of each calling process.

  1. Explain what vulnerabilities this flaw presents.

  2. Explain how the flaw can be controlled. The shared stack is still to be used for passing arguments and storing context.

22. This chapter explores the need for trusted path, for the user to be sure that a communication is going directly to the operating system. Although it would seem that a trusted path is not needed for a single user for a stand-alone device (such as a personal computer or a smartphone), that assumption may be wrong if the device is accessible by a network. Outline an attack by which an attacker could extract sensitive user details (for example, user ID and password) during the startup process for such a device. Trusted path is also an issue for network access, for example to log in to a banking website. (We explore this issue in Chapter 6 .) Outline the points of vulnerability between a user and a remote website.

23. List and describe four factors that would justify trust that an operating system implements security soundly.