Lesson 3 of 3 Security Models and System Capabilities

Hardware and Operating System Security Capabilities

Security policies are ultimately enforced by hardware and the operating system. This lesson covers memory protection, the trusted computing base, TPMs, HSMs and built-in encryption capabilities.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe memory protection, the trusted computing base and the reference monitor.
  • Distinguish the roles of TPMs and HSMs.

Memory protection and isolation

Operating systems give each process its own virtual address space, enforced by the processor's memory management unit, so one process cannot read or modify another's memory. Processors provide privilege levels, often described as protection rings: the kernel runs in the most privileged mode (ring 0), and applications in the least privileged (ring 3). System calls are the controlled way for applications to request privileged operations.

Further protections make memory corruption harder to exploit: data execution prevention marks data areas as non-executable, address space layout randomisation (ASLR) places code and data at unpredictable addresses, and stack canaries detect buffer overflows. Virtualisation adds hardware-supported isolation between virtual machines.

The privilege levels matter because they decide what a compromised program can do. When a word processor running in user mode is exploited, the attacker initially has only the rights of that process: it cannot directly read another process's memory, change kernel structures or access hardware. To do more, the attacker needs a second vulnerability, often in the kernel or a driver, to escalate to kernel mode. This is why kernel and driver flaws are rated so severely, and why browsers run untrusted web content in additional sandboxed processes with even fewer rights.

Each memory protection defeats a different step of an exploit. When an attacker overflows a buffer on the stack, a stack canary, a value placed before the return address, is overwritten and the program stops before using the corrupted address. If the attacker manages to place code in memory anyway, data execution prevention refuses to execute it because it sits in a data area. If the attacker tries instead to reuse existing code, ASLR means they do not know where that code is. None of these is perfect on its own, which is why they are used together.

Match the pairs

Exploit mitigations

Exam skills 3.4.1

Match each memory protection with the exploit step it defeats.

Log in to try this activity Interactive activities are free with an account.

Trusted computing base and reference monitor

The trusted computing base (TCB) is all the hardware, firmware and software that enforces the security policy; everything outside it is untrusted. The security perimeter is the boundary between the TCB and the rest of the system. The reference monitor is the concept that mediates every access by subjects to objects; its implementation, the security kernel, must be tamper-proof, always invoked and small enough to be verified.

Each of the three reference monitor requirements protects against a specific failure. If the mechanism is not tamper-proof, an attacker can modify it to approve everything. If it is not always invoked, an attacker can find a path to the object that skips the check, such as reading a file directly from the disk device instead of through the file system. If it is not verifiable, nobody can be confident that it makes the right decisions. These requirements apply well beyond operating systems: an API gateway that enforces authorisation is only effective if back-end services cannot be reached around it, which is the always-invoked requirement in a modern form.

Keeping the TCB small is a practical goal as well as a theoretical one. Every driver, service or plug-in that runs with kernel privileges becomes part of the TCB, because a flaw in it can undermine the security policy. Operating systems that move drivers and services out of the kernel into less privileged processes reduce the amount of code that must be trusted.

Sort into groups

Which requirement failed?

Exam skills 3.4.1

Identify which reference monitor requirement each weakness breaks.

Log in to try this activity Interactive activities are free with an account.

TPM, HSM and encryption capabilities

A Trusted Platform Module (TPM) is a secure cryptoprocessor, built into the device as a chip or firmware. It generates and protects keys, measures each stage of the boot process into platform configuration registers, seals secrets so they are released only if the measurements match (for example the key for full-disk encryption) and supports remote attestation of the device's state.

Measured boot and sealing work together as follows. As the laptop starts, each stage, from the firmware to the boot loader to the operating system loader, calculates a hash of the next stage before running it and records that hash in the TPM. The disk encryption key was sealed to the expected values when encryption was set up. If an attacker replaces the boot loader with a malicious one, the recorded hash differs, the TPM refuses to unseal the key and the disk stays encrypted, so the user is asked for a recovery key instead. An attacker who removes the disk and places it in another computer also fails, because the key never leaves the original TPM.

A hardware security module (HSM) is a dedicated, tamper-resistant appliance or card that generates, stores and uses keys for high-volume operations, such as certificate authorities, payment processing and cloud key management services. Keys never leave the HSM in plaintext, and HSMs are validated against FIPS 140-3.

Other built-in capabilities include processor instructions that accelerate AES, self-encrypting drives, operating system full-disk and file encryption, and trusted execution environments (secure enclaves) that protect data in use.

The following comparison summarises how the TPM and the HSM differ, since questions often ask which one fits a requirement.

TPM
ScopeOne device, built in
PerformanceLow; a few operations at boot and login
Typical useDisk encryption keys, measured boot, device attestation
CostIncluded with the device
Choose when Protecting secrets bound to a single endpoint and its boot state
HSM
ScopeShared service for many applications
PerformanceHigh; thousands of operations per second
Typical useCA signing keys, payment keys, cloud key management
CostDedicated appliance or cloud service
Choose when Protecting high-value keys used by servers and services at volume

The following diagram compares the TPM with the HSM.

Comparing a TPM with an HSM. A trusted platform module is a chip built into each device that measures the boot process and seals keys, such as a disk encryption key, so they are released only if the platform is untampered. A hardware security module is a dedicated, high-assurance appliance or cloud service that generates, stores and uses high-value keys at volume, such as a certificate authority's signing key.
Both keep keys inside tamper-resistant hardware.
Put in order

Measured boot and sealing

Exam skills 3.4.2

Arrange how measured boot and a sealed disk key work together.

Log in to try this activity Interactive activities are free with an account.
Worked example

TPM or HSM

A company needs to protect the private key of its internal certificate authority, which signs thousands of certificates per day, and separately wants laptops' disk encryption keys released only if the boot process has not been tampered with. Which technology fits each need?

The certificate authority's key needs a dedicated, high-assurance device for high-volume signing, which is an HSM. Releasing laptop disk keys only when boot measurements match is TPM sealing, which works per device and is built into the hardware.

Check yourself

Name the three required properties of a reference monitor.

Show answer

Tamper-proof, always invoked and small enough to be verified.

Exam Tips

Remember for the exam

  • The reference monitor must be tamper-proof, always invoked and verifiable.
  • TPM: per device, measured boot, sealing, attestation.
  • HSM: dedicated, high-volume key protection.