Layered defense-in-depth architecture

Ubuntu protects the system with four layers of security mechanisms. Each layer assumes that the layer above it can fail or be compromised, so an attacker needs to defeat several independent mechanisms to compromise the system.

The diagram on this page follows the diagram conventions. To go to the description of a layer, select the layer in the diagram.

        ---
config:
  theme: base
  fontFamily: Ubuntu variable, Ubuntu, sans-serif
  themeCSS: 'svg, svg * { font-family: Ubuntu variable, Ubuntu, sans-serif !important; } .flowchart-link { stroke-width: 3px !important; } .edge-pattern-dotted { stroke-dasharray: 8 5 !important; }'
  flowchart:
    curve: linear
  themeVariables:
    fontFamily: Ubuntu variable, Ubuntu, sans-serif
    lineColor: "#E95420"
    primaryColor: "#F3F3F3"
    primaryBorderColor: "#000000"
    primaryTextColor: "#000000"
    clusterBkg: "#FFFFFF"
    clusterBorder: "#000000"
    edgeLabelBackground: "#FFFFFF"
---
flowchart TB
    subgraph MAIN[" "]
        direction TB
        L1["1 — Network and perimeter"]
        L2["2 — Userspace<br>(deb packages, systemd services, snaps)"]
        L3["3 — Linux kernel"]
        L4["4 — Hardware, firmware, and boot chain"]
        L1 -->|"Accepted connections"| L2
        L2 -->|"System calls"| L3
        L3 -->|"Device and storage access"| L4
    end

    subgraph LEG["Legend"]
        direction LR
        leg0["Layer"]
        leg1s[" "] --> leg1["Data flow"]
        leg0 ~~~ leg1s
    end
    MAIN ~~~ LEG

    classDef component fill:#F3F3F3,stroke:#000000,stroke-width:1px,color:#000000
    classDef hidden fill:none,stroke:none,color:#FFFFFF
    classDef note fill:#FFFFFF,stroke:none,color:#000000
    class L1,L2,L3,L4 component
    class leg0 component
    class leg1 note
    class leg1s hidden
    click L1 href "#security-architecture-layer-network"
    click L2 href "#security-architecture-layer-userspace"
    click L3 href "#security-architecture-layer-kernel"
    click L4 href "#security-architecture-layer-hardware"
    style LEG fill:#FFFFFF,stroke:#666666,stroke-width:1px
    style MAIN fill:none,stroke:none
    

The four security layers of Ubuntu

Many of these mechanisms are part of the upstream Linux kernel and userspace, and are available on any Linux distribution. Ubuntu adds its own defaults and integrations on top of them. Each mechanism below states its default state as one of the following:

  • Ubuntu default: Ubuntu enables or configures the mechanism, beyond what upstream Linux does

  • Upstream, enabled by default: an upstream Linux mechanism that is active on a new installation of Ubuntu

  • Opt-in: Ubuntu provides the mechanism, but you need to choose and enable it

  • Platform-dependent: Ubuntu can use the mechanism when the hardware or firmware supports and enables it.

Network and perimeter

The network layer filters and authenticates traffic before it reaches a service, and authenticates the network services that the system itself relies on.

Netfilter and nftables

Default state: Upstream, enabled by default, with no filtering rules

Netfilter is the packet filtering framework of the Linux kernel. Every packet that the system receives, sends, or forwards passes its hooks, where rules can accept, drop, or rate-limit it. You manage the rules with nft(8). Without rules, Netfilter accepts all traffic, so the no open ports policy is what limits exposure on a new installation. See Packet filtering.

TCP SYN cookies

Default state: Upstream, enabled by default

In a SYN flood attack, an attacker opens many half-completed TCP connections to exhaust the connection queue of a service. With SYN cookies, the kernel encodes the connection state in its reply instead of storing it, so legitimate clients can still connect while the queue is full. Ubuntu has set net.ipv4.tcp_syncookies to 1 since Ubuntu 9.04. See SYN cookies.

No open ports policy

Default state: Ubuntu default

A new installation of Ubuntu has no listening network services, with a small number of documented exceptions that must follow strict guidelines, such as not exposing application data to the network. A service only listens on the network after you install it, which keeps the attack surface of a new system small. To list the services that listen on your system, use ss(8). See no open ports.

ufw host firewall

Default state: Opt-in

Ubuntu installs ufw(8), the Uncomplicated Firewall, as a front end that writes Netfilter rules from short commands, but does not enable it. To restrict which traffic reaches the services that you install, enable ufw and add rules for those services, or write nftables rules directly. See Firewall and netfilter subsystem.

Authenticated time synchronization

Default state: Ubuntu default

Correct time is a security property: certificate validity, Kerberos tickets, and log timestamps all depend on it. Ubuntu synchronizes time with chrony, configured to use Ubuntu’s time servers with Network Time Security (NTS), which authenticates the time servers so that an attacker on the network cannot change the system time. See About time synchronization and Time, name, and identity services.

Note

Ubuntu 24.04 LTS synchronizes time with systemd-timesyncd, which does not support NTS. New installations use chrony with NTS starting with Ubuntu 25.10.

DNSSEC validation

Default state: Opt-in

DNS Security Extensions (DNSSEC) let a resolver verify that DNS answers for a signed domain come from the domain owner and were not modified. Ubuntu’s stub resolver, systemd-resolved, supports DNSSEC validation but ships with it disabled, because validation can affect name resolution in some environments, for example with DNS servers that do not fully follow the specification. For background, see testing the waters with DNSSEC. To reject forged answers for signed domains, enable validation in the resolver. See DNS Security Extensions (DNSSEC) and Installing DNS Security Extensions (DNSSEC).

Connections that pass the network layer reach a service that listens in userspace. Only services that you install listen on the network, and each service authenticates its clients and validates their input itself, as OpenSSH does. See Network to userspace.

Userspace

Userspace runs services and applications from deb packages and snaps. The mechanisms in this layer control which software is installed, how it was built, what it can access, and who can act with administrative privileges.

PAM and polkit

Default state: Upstream, enabled by default

Pluggable Authentication Modules (PAM) authenticate users for every login service, and polkit lets privileged daemons decide whether an unprivileged caller may perform an action. Both are upstream components that Ubuntu configures for its login services and desktop. See PAM and polkit.

systemd service sandboxing

Default state: Upstream, enabled by default for services whose unit file configures it

systemd can start each service with a dedicated user, without the ability to gain privileges, and with restricted access to the file system, devices, and kernel interfaces. Which restrictions apply depends on the unit file of each service. To check a service, run systemd-analyze security <unit>. See Service sandboxing.

sudo-rs and the locked root account

Default state: Ubuntu default

The root account of a new installation has no usable password, so nobody can log in as root directly. Administrators run commands as root through sudo-rs, a memory-safe implementation of sudo, using their own credentials, so that administrative actions are tied to a user account. Grant administrative rights only to users who need them. See and User management.

Note

Ubuntu 24.04 LTS uses sudo instead of sudo-rs as the default sudo provider. See the sudo-rs replacement and announcement pages.

Package signature verification and automatic security updates

Default state: Ubuntu default

APT verifies every package that it installs from a configured repository against signed repository metadata, and snapd verifies every snap against signed assertions. Ubuntu also installs and enables unattended-upgrades, which installs security updates automatically. Only add package sources that you trust, because packages run their installation scripts as root. Plan your scheduled reboots, because kernel updates take effect after a reboot. See Automatic updates, Third party repository usage, and Ubuntu archive and mirrors.

AppArmor profiles for packaged software

Default state: Ubuntu default

Ubuntu enforces AppArmor, and ships AppArmor profiles for many services and applications in the archive, to confine them even when they run as root. Each release adds more profiles. Do not disable AppArmor, and write profiles for the services that you add yourself. See AppArmor, disabling AppArmor, and AppArmor.

Snap strict confinement

Default state: Ubuntu default

snapd runs each strictly confined snap with its own AppArmor profile, seccomp filter, device cgroup, and mount namespace, so that the snap can only access the resources that its connected interfaces allow. Review the interfaces that a snap requests, and avoid classic or devmode confinement for snaps that you do not trust, because they turn off this confinement. See snap confinement and Snap Store.

Hardened compiler and linker flags

Default state: Ubuntu default

Ubuntu builds the packages in its archive as position-independent executables (PIE), which take full advantage of address space layout randomization, with stack protection, and with checks of buffer sizes in common C library functions (_FORTIFY_SOURCE). These make memory corruption bugs harder to exploit. Ubuntu configures its compiler to enable many of these flags by default, so they also apply to software that you build on Ubuntu. See default compiler and linker flags.

Auditing and compliance hardening

Default state: Opt-in

Ubuntu does not record security-relevant events, such as file access or privilege changes, unless you install the auditd(8) audit daemon. To apply and audit a hardening profile, such as the CIS Benchmarks or DISA-STIG, use the Ubuntu Security Guide (USG), which is available with an Ubuntu Pro subscription.

Userspace processes cannot access files, devices, the network, or other processes directly. To do so, they make a system call: a request that switches the CPU from user mode to the kernel at a fixed entry point. The kernel then checks the request against the credentials of the process and the loaded security policies before it acts on it. See Userspace to kernel.

Linux kernel

The kernel enforces access control and isolation for every process, and protects itself against exploitation.

Discretionary access control and capabilities

Default state: Upstream, enabled by default

The kernel checks every access attempt against the owner, group, and permissions of the file or device, and its access control lists. Capabilities split the privileges of root into separate units, so that a process can hold only the privileges that it needs. See Discretionary access control and capabilities.

Namespaces and cgroups

Default state: Upstream, enabled by default

Namespaces limit which resources a process can see, such as other processes, mounts, and network interfaces, and cgroups limit how much CPU, memory, and I/O the process can use. Containers, snaps, and systemd services build on them. See Namespaces and cgroups.

seccomp-bpf

Default state: Upstream, enabled by default for processes that install a filter

A seccomp filter limits which system calls a process can make, which reduces the kernel attack surface that a compromised process can reach. snapd, systemd, container runtimes, and many applications install filters. See seccomp-bpf.

AppArmor

Default state: Ubuntu default

Ubuntu enables AppArmor as its Linux Security Module (LSM). AppArmor enforces mandatory access control: it restricts each confined program to the files, network access, and capabilities listed in its profile, regardless of the permissions of the user that runs it. See AppArmor.

Yama ptrace scope

Default state: Ubuntu default

Normally a process can inspect and modify the memory of any other process of the same user with ptrace, so one compromised application could read the secrets of all others. Ubuntu enables the Yama LSM and limits ptrace to a process’s own descendants. See Yama.

Unprivileged user namespace restriction

Default state: Ubuntu default

Unprivileged user namespaces let a process gain capabilities inside a namespace, which exposes kernel code that otherwise only root can reach. Starting with Ubuntu 24.04 LTS, the kernel and AppArmor restrict them: unconfined, unprivileged applications can still create user namespaces, but cannot use capabilities inside them. AppArmor profiles allow full use for applications that need it, such as browsers and container tools. See AppArmor unprivileged user namespace restrictions.

Kernel memory hardening

Default state: Ubuntu default

Ubuntu configures its kernel to make kernel exploits harder. Kernel address space layout randomization (KASLR) places the kernel at a different address on every boot, kernel.kptr_restrict and kernel.dmesg_restrict hide kernel addresses and messages from unprivileged users, and kernel code and read-only data are write-protected. Avoid weakening these protections with sysctl settings. See kernel protections and dangerous sysctls.

Kernel lockdown and module signatures

Default state: Platform-dependent

When UEFI Secure Boot is enabled, the kernel enables lockdown in integrity mode, which prevents even root from modifying the running kernel, and only loads signed kernel modules. This extends the verified boot chain into the running system. See Kernel protections, kernel lockdown and Module signature check).

Only the kernel accesses the hardware: it drives devices, manages memory, and reads and writes storage on behalf of processes. In the other direction, devices signal the kernel through interrupts, and can read and write memory directly through direct memory access (DMA), which the IOMMU restricts. Which kernel runs at all is decided earlier, by the boot chain. See Kernel, hardware, boot, and storage boundary.

Hardware, firmware, and boot chain

The lowest layer anchors trust in the hardware: it decides which code runs at boot, protects data at rest, and keeps firmware up to date.

UEFI Secure Boot

Default state: Platform-dependent

When Secure Boot is enabled in the firmware, the firmware verifies the boot loader, and the boot loader verifies the kernel, so that only signed code runs at boot. Ubuntu ships a signed boot chain, so Secure Boot works without changes. Enable Secure Boot in the firmware of your system. See Verified and measured boot.

TPM measured boot

Default state: Platform-dependent

If the system has a Trusted Platform Module (TPM) 2.0, the firmware records a measurement of each boot stage in the TPM. The TPM can then release secrets, such as a disk encryption key, only to a system that booted the expected software. See Verified and measured boot.

IOMMU DMA protection

Default state: Platform-dependent

An Input-Output Memory Management Unit (IOMMU) restricts which memory a device can access through DMA, which protects against malicious peripherals. Use hardware that provides an IOMMU, and enable it in the firmware. See IOMMU.

Firmware updates

Default state: Ubuntu default

Ubuntu ships fwupd, which downloads firmware updates from the Linux Vendor Firmware Service (LVFS), verifies their signatures, and installs them. Firmware vulnerabilities can undermine every layer above, so keep firmware up to date with fwupdmgr(1). See Firmware updates (fwupd).

Full disk encryption

Default state: Opt-in

Full disk encryption with LUKS protects data at rest if a disk is lost or stolen. Select encryption during installation. To unlock the disk with the TPM instead of a passphrase, use TPM-backed full disk encryption on Ubuntu Desktop, or Clevis on Ubuntu Server. See Full disk encryption and TPM-backed unlocking.