Privilege separation

On this page 8

Privilege separation is a design technique in which a program is divided into separate processes with different privilege levels, so that only a small, carefully audited component holds elevated rights while the parts that handle untrusted input run with minimal permissions. In OS security, it is one of the most effective ways to contain the damage of a software flaw, because an attacker who compromises the exposed component inherits only its restricted rights, not those of the whole service.

Privilege separation applies the principle of least privilege to the internal structure of software. Modern operating systems support it through user accounts, process boundaries, sandboxes and capability systems, and it appears in network daemons, web browsers, system services and the boot chain of desktop platforms.

How privilege separation divides a program

A privilege-separated program splits its work between a privileged monitor and one or more unprivileged workers. The monitor performs the few operations that truly require elevated rights, such as binding a low network port, reading a key file or switching user identity. The workers parse protocol messages, decode files and run complex logic, which is where most exploitable bugs live.

The two sides communicate through a narrow, well-defined interface, usually a socket pair, a pipe or a message channel. The monitor treats every request from a worker as potentially hostile and validates it before acting. If a worker is compromised, the attacker can only send requests the monitor is willing to grant, which turns a full system compromise into a limited, contained failure.

The table below lists the typical components of a privilege-separated design and the rights each one holds.

ComponentTypical rightsMain responsibility
Privileged monitorRoot, SYSTEM or specific capabilitiesPerforms sensitive operations on request
Unprivileged workerDedicated low-rights accountParses untrusted input and runs logic
Communication channelNone by itselfCarries validated requests between parts
Sandbox policyRestricts system calls and filesLimits what a worker can reach if compromised
Components of a privilege-separated design

Operating system mechanisms that enable it

Privilege separation depends on kernel-enforced boundaries. Without the operating system guaranteeing that one process cannot read or modify another, splitting a program would offer no protection. Process isolation and memory protection provide that guarantee, while identity and policy mechanisms decide what each separated part may do.

Different desktop operating systems expose different building blocks, summarized in the following table.

MechanismPlatformWhat it restricts
Separate user IDsLinux, BSD, macOSFile, process and signal access
Linux capabilitiesLinuxIndividual root powers such as raw sockets
seccomp filtersLinuxPermitted system calls
pledge and unveilOpenBSDSystem call groups and visible file paths
Integrity levels and AppContainerWindowsWrites to higher-integrity objects and resources
App Sandbox and XPC servicesmacOSFiles, network and inter-process requests
Building blocks for privilege separation by platform

A robust design usually combines several mechanisms: the worker runs under a dedicated account, drops all optional capabilities, is confined to an empty directory and is restricted to a short list of system calls. Each layer covers gaps in the others.

Privilege separation is a design pattern, not a single feature, and it overlaps with several neighboring concepts. Least privilege is the goal; privilege separation is the method of reaching it inside one application; sandboxing and access control are the enforcement tools.

ConceptScopeRelationship to privilege separation
Least privilegeGeneral security principleThe goal that separation implements
Process isolationKernel guaranteeThe boundary that separation relies on
SandboxingConfinement of one processOften applied to the unprivileged worker
Mandatory access controlSystem-wide policyCan enforce limits on each separated part
Privilege droppingSingle process over timeA simpler, weaker form without a separate monitor
How privilege separation relates to neighboring concepts

The difference from privilege dropping deserves attention. A process that starts as root and later switches to an ordinary user reduces its exposure, but it can no longer perform privileged work. A separated design keeps the privileged monitor alive for occasional sensitive tasks, while the exposed code never holds those rights at all.

Well-known implementations

The technique became widely known through OpenSSH, which in the early 2000s split its server so that network parsing and pre-authentication logic ran in an unprivileged child process. Several later vulnerabilities in that code were downgraded from remote root to contained bugs because of this split.

  • Web browsers such as Chromium and Firefox run each site’s renderer in a sandboxed process, while a privileged broker handles files, network and user interface.
  • Windows services commonly run under restricted accounts such as Local Service or Network Service instead of SYSTEM.
  • macOS splits applications into XPC services so that, for example, image decoding runs with no access to user documents.
  • Mail and DNS servers such as Postfix and modern resolvers separate listeners, parsers and delivery agents into distinct processes.

Designing a privilege-separated service

Effective separation starts with an inventory of privileged operations. Each one is moved into the monitor, and the monitor’s interface is kept as small as possible so that it can be reviewed line by line. Everything else, especially parsing of untrusted data, belongs in workers.

The following decision table shows common design questions and the usual answers.

SituationRecommended choiceReason
Service needs a port below 1024Bind in monitor, pass socket to workerWorker never needs root
Worker parses complex formatsApply strict sandbox and seccompParsers are the most exploited code
Monitor must read secret keysExpose only sign or verify requestsKeys never leave the monitor
Many clients served at onceOne worker per sessionLimits cross-session data leaks
Monitor interface grows over timeReview and reduce request typesLarge interfaces erode the boundary
Design decisions for privilege separation

Performance costs are usually modest. Inter-process communication adds latency in the range of microseconds per request, and the extra memory per worker matters mainly when thousands of sessions run in parallel.

Limitations and common mistakes

Privilege separation reduces impact but does not remove vulnerabilities. A bug in the monitor remains critical, and a poorly designed interface can let a compromised worker trick the monitor into acting on its behalf, a problem known as the confused deputy.

  • Overly generous monitor requests, such as a generic “open any file” call, effectively hand the worker full privileges.
  • Shared writable resources between monitor and worker create paths for tampering.
  • Kernel exploits bypass process boundaries entirely, so separation must be combined with exploit mitigation and timely security updates.
  • Leftover privileges, such as open file descriptors or inherited capabilities, survive in the worker when they are not closed explicitly.

A non-technical view

Think of a bank branch. The tellers talk to strangers all day, but they cannot open the vault. Only a manager in a back office has that key, and the manager hands out cash only after checking each request.

Privilege separation does the same thing inside software. The part of a program that deals with the outside world gets almost no power, and a small, trusted part keeps the dangerous abilities. If a criminal fools the teller, the vault stays locked.

A concrete example

A system administrator at a mid-sized engineering firm runs an SSH server on a Linux workstation that accepts remote logins from staff working at home. The server’s privileged monitor runs as root, while every incoming connection is handled by a worker process under an unprivileged account, confined to an empty directory and limited by a seccomp filter.

One month, a security advisory describes a memory corruption flaw in the code that parses key exchange messages before authentication. Because that code runs only in the sandboxed worker, an attacker who exploited it would gain an unprivileged, confined process with no file access, not root on the workstation. The administrator installs the patch during the next maintenance window instead of taking the server offline in an emergency, and the separation turns a critical flaw into a manageable one.