Section 1.15

Least privilege

Definition

Least privilege is a security design principle: every program, user and component gets only the privileges its task needs, and holds each one only while the task needs it. A privilege is a right to perform an operation on a resource, such as reading a file, writing a memory region or creating authenticated messages with a key. The principle does not prevent a compromise; it limits what a compromised or faulty component can do. Saltzer and Schroeder stated it in 1975 [233] as a design principle for protecting information in computers.

The idea

A controller sends commands to many devices through a relay, a component whose only job is to carry messages, such as a gateway between a wired network and a radio link. Each command carries an authentication §1.6 tag: a short value computed from the command with a secret key, which the device checks to confirm that the command came from a holder of the key. The relay’s job needs no key. It receives bytes and sends the same bytes on. If the relay holds the key anyway, then whoever takes over the relay can write new commands that the devices accept. The key adds nothing to what the relay does for the system and a great deal to what an attacker can do with the relay.

A courier who carries sealed letters is a fair picture. The courier needs a bag and a route, not the sender’s seal, and a courier who holds the seal can write letters of their own. The picture stops at the seal. A seal shows who sent a letter but does not hide its content, so a courier can still read a letter that is not also encrypted, and any courier can lose a letter, hold it back or deliver it twice. Least privilege removes the courier’s power to forge. It does not remove the courier’s power to interfere with delivery.

How it works

Applying the principle to one component takes six steps.

  1. Describe the task as operations: what the component reads, writes, creates, deletes, signs or approves, and on which objects.

  2. Grant exactly those operations on exactly those objects, and nothing by default. A table with one row per actor and one column per protected object, called an access control §1.7 matrix, makes the grants visible: each cell lists the operations that actor may perform on that object.

  3. Limit privileges in time. A right needed only at start-up is given up after start-up. Traditionally on Unix-like systems, opening a network port numbered below 1024 needs administrator rights. A web server that needs those rights only for that one step opens its port at start-up and then permanently switches to an ordinary user account.

  4. Count indirect privileges. A component that can ask a more privileged component to act for it holds, in effect, that component’s privileges for the request. When the privileged component acts without checking whose request it serves, the result is a confused deputy §1.25.

  5. Enforce the limits with a mechanism the component cannot override: separate processes with operating-system permissions, memory protection hardware such as the memory protection unit §6.8 (MPU) of a microcontroller §6.1, or, for cryptographic rights, simply not giving the component the key.

  6. Review the grants whenever the task changes. Rights added for debugging, or for a feature that no longer exists, tend to stay; this is called privilege creep.

For authenticated messages, the kind of cryptography decides who must hold what. With a message authentication code §5.7 (MAC), one secret key both creates and checks tags, so every component that can check a tag can also forge one. With a digital signature §5.14, a private key creates signatures and a separate public key checks them, so a component that must verify can hold only the public key and gains no power to create.

Worked example

A controller C sends commands through a relay R to 500 devices D1,…,D500D_1, \dots, D_{500}. Each device checks a MAC tag on every command. Each device also accepts a command only if the command’s counter, a number that the controller increases with every command, is higher than the last counter the device accepted. Compare two designs by what an attacker gains from taking over one component.

Design 2 removes the relay’s power to forge, a reduction from 500 devices to 0. It does not remove the relay’s power to interfere. A relay taken over in design 2 can still drop every command, so all 500 devices can be cut off, exactly as in design 1. It can delay commands. It can record a command and send it again, which is called a replay attack §1.26; the counter check makes each device reject the second copy, because its counter is no longer higher than the last one accepted. And it can read every command, because a MAC tag does not hide content. Least privilege moved the relay from “can forge and interfere” to “can only interfere”. The counter check, encryption and the design’s tolerance of lost commands must handle the rest.

Stated precisely

Let NN be the set of operations that a component’s task needs, GG the set of operations that the design grants it, and PP the set of operations that the component can actually cause, directly or by asking other components to act for it. The component can do its task only if every operation in NN is also in PP. An attacker who takes over the component gains every operation in PP, not only those in NN. Least privilege asks that the excess, the operations in GG but not in NN, be as small as the available enforcement allows, ideally empty, that each operation stay in GG only during the time the task needs it, and that PP contain nothing outside GG.

This bound on damage depends on three assumptions.

  1. Enforced limits. A mechanism that the component cannot bypass or alter keeps PP inside GG. A privilege that is withheld only on paper, for example by a rule in a design document, bounds nothing.

  2. Complete count. The count of GG includes indirect privileges: requests to more privileged components, keys from which other keys can be computed, and data the component can read. A privilege left out of the count is still in PP.

  3. Correct task description. NN includes everything the task needs, including error handling and recovery. A set that is too small breaks the task, and the missing rights tend to be added back later in a broader form.

Limits and common mistakes

Least privilege does not stop misuse of the privileges that a task really needs. A relay that must forward traffic can always refuse to forward it, so least privilege never removes a relay’s power to cause a denial of service §1.28.

Removing one key does not remove all authority. A component that sees the messages can still read unencrypted content, learn who talks to whom and when, and replay or delay messages. List what remains, not only what was removed.

A shared credential defeats the principle. If one key is stored in every device, taking over any one device gives the key for all of them. Per-device key derivation §5.24, which computes each device’s key from one root key §5.25, keeps each device limited to itself only while the root key stays out of every device and every relay: a component that holds the root key can recompute every device key.

Enforcement has a granularity, and the smallest grant it can express may exceed the need. A memory protection unit protects only a small fixed number of regions, often 8 or 16, each with rules on its size and alignment §4.22, so a component may have to receive a whole region when it needs part of one. State the excess instead of claiming least privilege.

Least privilege does not mean the smallest possible privilege. A component whose job is recovery, such as a bootloader §6.30 that must be able to reinstall software, needs strong rights. The principle asks that such rights belong only to the component whose task needs them, and that this component be protected in proportion to its rights.

Questions answered

Can a forwarding component operate without an origin-authentication key?

Yes, a forwarding component such as a relay or a gateway can operate without the origin-authentication key, provided that the receiving endpoint checks the origin itself. Origin authentication means checking that a message was created by an authorized sender; its key creates or checks a tag, a short value computed over the message. Forwarding means receiving bytes and sending the same bytes on, which needs no such key. The sender computes the tag over the whole message, and the endpoint, the device that acts on the message, checks the tag with its own copy of the key. This arrangement is called end-to-end security §1.34: the protection runs from the sender to the endpoint and does not depend on the relay.

Withholding the key follows least privilege, the principle that each component gets only the privileges its task needs: a relay that holds the key can be made to forge commands once it is taken over. With a message authentication code, checking and creating tags use the same key, so the relay should hold the key for neither. With a digital signature, a component that must verify the origin can hold only the public verification key. The relay may still need its own transport credential, such as a key for its link to the next hop. That credential lets it use the link but not create commands that the endpoint accepts.

A relay without the key still controls delivery. It can drop, delay or reorder messages, send a recorded message again, and read any content that is not encrypted. The endpoint must therefore enforce freshness itself, for example by accepting a command only if its counter is higher than the last one accepted, and the design must accept that a relay that has been taken over can stop delivery.

Related entries: Confused deputy (§1.25), End-to-end security (§1.34), Key separation (§5.23), Capability security (§1.40), Per-device key derivation (§5.24), Memory protection unit (MPU) (§6.8). Further reading: [233].