1a03ef333SWilly TarreauThe Linux Kernel threat model 2a03ef333SWilly Tarreau============================= 3a03ef333SWilly Tarreau 4a03ef333SWilly TarreauThere are a lot of assumptions regarding what the kernel does and does not 5a03ef333SWilly Tarreauprotect against. These assumptions tend to cause confusion for bug reports 6a03ef333SWilly Tarreau(:doc:`security-related ones <security-bugs>` vs :doc:`non-security ones 7a03ef333SWilly Tarreau<../admin-guide/reporting-issues>`), and can complicate security enforcement 8a03ef333SWilly Tarreauwhen the responsibilities for some boundaries is not clear between the kernel, 9a03ef333SWilly Tarreaudistros, administrators and users. 10a03ef333SWilly Tarreau 11a03ef333SWilly TarreauThis document tries to clarify the responsibilities of the kernel in this 12a03ef333SWilly Tarreaudomain. 13a03ef333SWilly Tarreau 14a03ef333SWilly TarreauThe kernel's responsibilities 15a03ef333SWilly Tarreau----------------------------- 16a03ef333SWilly Tarreau 17a03ef333SWilly TarreauThe kernel abstracts access to local hardware resources and to remote systems 18a03ef333SWilly Tarreauin a way that allows multiple local users to get a fair share of the available 19a03ef333SWilly Tarreauresources granted to them, and, when the underlying hardware permits, to assign 20a03ef333SWilly Tarreaua level of confidentiality to their communications and to the data they are 21a03ef333SWilly Tarreauprocessing or storing. 22a03ef333SWilly Tarreau 23a03ef333SWilly TarreauThe kernel assumes that the underlying hardware behaves according to its 24a03ef333SWilly Tarreauspecifications. This includes the integrity of the CPU's instruction set, the 25a03ef333SWilly Tarreautransparency of the branch prediction unit and the cache units, the consistency 26a03ef333SWilly Tarreauof the Memory Management Unit (MMU), the isolation of DMA-capable peripherals 27a03ef333SWilly Tarreau(e.g., via IOMMU), state transitions in controllers, ranges of values read from 28a03ef333SWilly Tarreauregisters, the respect of documented hardware limitations, etc. 29a03ef333SWilly Tarreau 30a03ef333SWilly TarreauWhen hardware fails to maintain its specified isolation (e.g., CPU bugs, 31a03ef333SWilly Tarreauside-channels, hardware response to unexpected inputs), the kernel will usually 32a03ef333SWilly Tarreauattempt to implement reasonable mitigations. These are best-effort measures 33a03ef333SWilly Tarreauintended to reduce the attack surface or elevate the cost of an attack within 34a03ef333SWilly Tarreauthe limits of the hardware's facilities; they do not constitute a 35a03ef333SWilly Tarreaukernel-provided safety guarantee. 36a03ef333SWilly Tarreau 37a03ef333SWilly TarreauUsers always perform their activities under the authority of an administrator 38a03ef333SWilly Tarreauwho is able to grant or deny various types of permissions that may affect how 39a03ef333SWilly Tarreauusers benefit from available resources, or the level of confidentiality of 40a03ef333SWilly Tarreautheir activities. Administrators may also delegate all or part of their own 41a03ef333SWilly Tarreaupermissions to some users, particularly via capabilities but not only. All this 42a03ef333SWilly Tarreauis performed via configuration (sysctl, file-system permissions etc). 43a03ef333SWilly Tarreau 44a03ef333SWilly TarreauThe Linux Kernel applies a certain collection of default settings that match 45a03ef333SWilly Tarreauits threat model. Distros have their own threat model and will come with their 46a03ef333SWilly Tarreauown configuration presets, that the administrator may have to adjust to better 47a03ef333SWilly Tarreausuit their expectations (relax or restrict). 48a03ef333SWilly Tarreau 49a03ef333SWilly TarreauBy default, the Linux Kernel guarantees the following protections when running 50a03ef333SWilly Tarreauon common processors featuring privilege levels and memory management units: 51a03ef333SWilly Tarreau 52a03ef333SWilly Tarreau* **User-based isolation**: an unprivileged user may restrict access to their 53a03ef333SWilly Tarreau own data from other unprivileged users running on the same system. This 54a03ef333SWilly Tarreau includes: 55a03ef333SWilly Tarreau 56a03ef333SWilly Tarreau * stored data, via file system permissions 57a03ef333SWilly Tarreau * in-memory data (pages are not accessible by default to other users) 58a03ef333SWilly Tarreau * process activity (ptrace is not permitted to other users) 59a03ef333SWilly Tarreau * inter-process communication (other users may not observe data exchanged via 60a03ef333SWilly Tarreau UNIX domain sockets or other IPC mechanisms). 61a03ef333SWilly Tarreau * network communications within the same or with other systems 62a03ef333SWilly Tarreau 63a03ef333SWilly Tarreau* **Capability-based protection**: 64a03ef333SWilly Tarreau 65*f2e65e4eSJonathan Corbet * users not having elevated capabilities (including but not limited to 66*f2e65e4eSJonathan Corbet CAP_SYS_ADMIN) may not alter the 67a03ef333SWilly Tarreau kernel's configuration, memory nor state, change other users' view of the 68a03ef333SWilly Tarreau file system layout, grant any user capabilities they do not have, nor 69a03ef333SWilly Tarreau affect the system's availability (shutdown, reboot, panic, hang, or making 70a03ef333SWilly Tarreau the system unresponsive via unbounded resource exhaustion). 71a03ef333SWilly Tarreau * users not having the ``CAP_NET_ADMIN`` capability may not alter the network 72a03ef333SWilly Tarreau configuration, intercept nor spoof network communications from other users 73a03ef333SWilly Tarreau nor systems. 74a03ef333SWilly Tarreau * users not having ``CAP_SYS_PTRACE`` may not observe other users' processes 75a03ef333SWilly Tarreau activities. 76a03ef333SWilly Tarreau 77a03ef333SWilly TarreauWhen ``CONFIG_USER_NS`` is set, the kernel also permits unprivileged users to 78a03ef333SWilly Tarreaucreate their own user namespace in which they have all capabilities, but with a 79a03ef333SWilly Tarreaunumber of restrictions (they may not perform actions that have impacts on the 80a03ef333SWilly Tarreauinitial user namespace, such as changing time, loading modules or mounting 81a03ef333SWilly Tarreaublock devices). Please refer to ``user_namespaces(7)`` for more details, the 82a03ef333SWilly Tarreaupossibilities of user namespaces are not covered in this document. 83a03ef333SWilly Tarreau 84a03ef333SWilly TarreauThe kernel also offers a lot of troubleshooting and debugging facilities, which 85a03ef333SWilly Tarreaucan constitute attack vectors when placed in wrong hands. While some of them 86a03ef333SWilly Tarreauare designed to be accessible to regular local users with a low risk (e.g. 87a03ef333SWilly Tarreaukernel logs via ``/proc/kmsg``), some would expose enough information to 88a03ef333SWilly Tarreaurepresent a risk in most places and the decision to expose them is under the 89a03ef333SWilly Tarreauadministrator's responsibility (perf events, traces), and others are not 90a03ef333SWilly Tarreaudesigned to be accessed by non-privileged users (e.g. debugfs). Access to these 91a03ef333SWilly Tarreaufacilities by a user who has been explicitly granted permission by an 92a03ef333SWilly Tarreauadministrator does not constitute a security breach. 93a03ef333SWilly Tarreau 94a03ef333SWilly TarreauBugs that permit to violate the principles above constitute security breaches. 95a03ef333SWilly TarreauHowever, bugs that permit one violation only once another one was already 96a03ef333SWilly Tarreauachieved are only weaknesses. The kernel applies a number of self-protection 97a03ef333SWilly Tarreaumeasures whose purpose is to avoid crossing a security boundary when certain 98a03ef333SWilly Tarreauclasses of bugs are found, but a failure of these extra protections do not 99a03ef333SWilly Tarreauconstitute a vulnerability alone. 100a03ef333SWilly Tarreau 101a03ef333SWilly TarreauWhat does not constitute a security bug 102a03ef333SWilly Tarreau--------------------------------------- 103a03ef333SWilly Tarreau 104a03ef333SWilly TarreauIn the Linux kernel's threat model, the following classes of problems are 105a03ef333SWilly Tarreau**NOT** considered as Linux Kernel security bugs. However, when it is believed 106a03ef333SWilly Tarreauthat the kernel could do better, they should be reported, so that they can be 107a03ef333SWilly Tarreaureviewed and fixed where reasonably possible, but they will be handled as any 108a03ef333SWilly Tarreauregular bug: 109a03ef333SWilly Tarreau 110a03ef333SWilly Tarreau* **Configuration**: 111a03ef333SWilly Tarreau 112a03ef333SWilly Tarreau * outdated kernels and particularly end-of-life branches are out of the scope 113a03ef333SWilly Tarreau of the kernel's threat model: administrators are responsible for keeping 114a03ef333SWilly Tarreau their system up to date. For a bug to qualify as a security bug, it must be 115a03ef333SWilly Tarreau demonstrated that it affects actively maintained versions. 116a03ef333SWilly Tarreau 117a03ef333SWilly Tarreau * build-level: changes to the kernel configuration that are explicitly 118a03ef333SWilly Tarreau documented as lowering the security level (e.g. ``CONFIG_NOMMU``), or 119a03ef333SWilly Tarreau targeted at developers only. 120a03ef333SWilly Tarreau 121a03ef333SWilly Tarreau * OS-level: changes to command line parameters, sysctls, filesystem 122a03ef333SWilly Tarreau permissions, user capabilities, exposure of privileged interfaces, that 123a03ef333SWilly Tarreau explicitly increase exposure by either offering non-default access to 124a03ef333SWilly Tarreau unprivileged users, or reduce the kernel's ability to enforce some 125a03ef333SWilly Tarreau protections or mitigations. Example: write access to procfs or debugfs. 126a03ef333SWilly Tarreau 127a03ef333SWilly Tarreau * issues triggered only when using features intended for development or 128a03ef333SWilly Tarreau debugging (e.g., LOCKDEP, KASAN, FAULT_INJECTION): these features are known 129a03ef333SWilly Tarreau to introduce overhead and potential instability and are not intended for 130a03ef333SWilly Tarreau production use. 131a03ef333SWilly Tarreau 132a03ef333SWilly Tarreau * issues affecting drivers exposed under CONFIG_STAGING, as well as features 133a03ef333SWilly Tarreau marked EXPERIMENTAL in the configuration. 134a03ef333SWilly Tarreau 135a03ef333SWilly Tarreau * loading of explicitly insecure/broken/staging modules, and generally any 136a03ef333SWilly Tarreau using any subsystem marked as experimental or not intended for production 137a03ef333SWilly Tarreau use. 138a03ef333SWilly Tarreau 139a03ef333SWilly Tarreau * running out-of-tree modules or unofficial kernel forks; these should be 140a03ef333SWilly Tarreau reported to the relevant vendor. 141a03ef333SWilly Tarreau 142a03ef333SWilly Tarreau* **Excess of initial privileges**: 143a03ef333SWilly Tarreau 144a03ef333SWilly Tarreau * actions performed by a user already possessing the privileges required to 145a03ef333SWilly Tarreau perform that action or modify that state (e.g. ``CAP_SYS_ADMIN``, 146a03ef333SWilly Tarreau ``CAP_NET_ADMIN``, ``CAP_SYS_RAWIO``, ``CAP_SYS_MODULE`` with no further 147a03ef333SWilly Tarreau boundary being crossed). 148a03ef333SWilly Tarreau 149a03ef333SWilly Tarreau * actions performed in user namespace that do not bypass the restrictions 150a03ef333SWilly Tarreau imposed to the initial user (e.g. ptrace usage, signal delivery, resource 151a03ef333SWilly Tarreau usage, access to FS/device/sysctl/memory, network binding, system/network 152a03ef333SWilly Tarreau configuration etc). 153a03ef333SWilly Tarreau 154a03ef333SWilly Tarreau * anything performed by the root user in the initial namespace (e.g. kernel 155a03ef333SWilly Tarreau oops when writing to a privileged device). 156a03ef333SWilly Tarreau 157a03ef333SWilly Tarreau* **Out of production use**: 158a03ef333SWilly Tarreau 159a03ef333SWilly Tarreau This covers theoretical/probabilistic attacks that rely on laboratory 160a03ef333SWilly Tarreau conditions with zero system noise, or those requiring an unrealistic number 161a03ef333SWilly Tarreau of attempts (e.g., billions of trials) that would be detected by standard 162a03ef333SWilly Tarreau system monitoring long before success, such as: 163a03ef333SWilly Tarreau 164a03ef333SWilly Tarreau * prediction of random numbers that only works in a totally silent 165a03ef333SWilly Tarreau environment (such as IP ID, TCP ports or sequence numbers that can only be 166a03ef333SWilly Tarreau guessed in a lab). 167a03ef333SWilly Tarreau 168a03ef333SWilly Tarreau * activity observation and information leaks based on probabilistic 169a03ef333SWilly Tarreau approaches that are prone to measurement noise and not realistically 170a03ef333SWilly Tarreau reproducible on a production system. 171a03ef333SWilly Tarreau 172a03ef333SWilly Tarreau * issues that can only be triggered by heavy attacks (e.g. brute force) whose 173a03ef333SWilly Tarreau impact on the system makes it unlikely or impossible to remain undetected 174a03ef333SWilly Tarreau before they succeed (e.g. consuming all memory before succeeding). 175a03ef333SWilly Tarreau 176a03ef333SWilly Tarreau * problems seen only under development simulators, emulators, or combinations 177a03ef333SWilly Tarreau that do not exist on real systems at the time of reporting (issues 178a03ef333SWilly Tarreau involving tens of millions of threads, tens of thousands of CPUs, 179a03ef333SWilly Tarreau unrealistic CPU frequencies, RAM sizes or disk capacities, network speeds. 180a03ef333SWilly Tarreau 181a03ef333SWilly Tarreau * issues whose reproduction requires hardware modification or emulation, 182a03ef333SWilly Tarreau including fake USB devices that pretend to be another one. 183a03ef333SWilly Tarreau 184a03ef333SWilly Tarreau * as well as issues that can be triggered at a cost that is orders of 185a03ef333SWilly Tarreau magnitude higher than the expected benefits (e.g. fully functional keyboard 186a03ef333SWilly Tarreau emulator only to retrieve 7 uninitialized bytes in a structure, or 187a03ef333SWilly Tarreau brute-force method involving millions of connection attempts to guess a 188a03ef333SWilly Tarreau port number). 189a03ef333SWilly Tarreau 190a03ef333SWilly Tarreau* **Hardening failures**: 191a03ef333SWilly Tarreau 192a03ef333SWilly Tarreau * ability to bypass some of the kernel's hardening measures with no 193a03ef333SWilly Tarreau demonstrable exploit path (e.g. ASLR bypass, events timing or probing with 194a03ef333SWilly Tarreau no demonstrable consequence). These are just weaknesses, not 195a03ef333SWilly Tarreau vulnerabilities. 196a03ef333SWilly Tarreau 197a03ef333SWilly Tarreau * missing argument checks and failure to report certain errors with no 198a03ef333SWilly Tarreau immediate consequence. 199a03ef333SWilly Tarreau 200a03ef333SWilly Tarreau* **Random information leaks**: 201a03ef333SWilly Tarreau 202a03ef333SWilly Tarreau This concerns information leaks of small data parts that happen to be there 203a03ef333SWilly Tarreau and that cannot be chosen by the attacker, or face access restrictions: 204a03ef333SWilly Tarreau 205a03ef333SWilly Tarreau * structure padding reported by syscalls or other interfaces. 206a03ef333SWilly Tarreau 207a03ef333SWilly Tarreau * identifiers, partial data, non-terminated strings reported in error 208a03ef333SWilly Tarreau messages. 209a03ef333SWilly Tarreau 210a03ef333SWilly Tarreau * Leaks of kernel memory addresses/pointers do not constitute an immediately 211a03ef333SWilly Tarreau exploitable vector and are not security bugs, though they must be reported 212a03ef333SWilly Tarreau and fixed. 213a03ef333SWilly Tarreau 214a03ef333SWilly Tarreau* **Crafted file system images**: 215a03ef333SWilly Tarreau 216a03ef333SWilly Tarreau * bugs triggered by mounting a corrupted or maliciously crafted file system 217a03ef333SWilly Tarreau image are generally not security bugs, as the kernel assumes the underlying 218a03ef333SWilly Tarreau storage media is under the administrator's control, unless the filesystem 219a03ef333SWilly Tarreau driver is specifically documented as being hardened against untrusted media. 220a03ef333SWilly Tarreau 221a03ef333SWilly Tarreau * issues that are resolved, mitigated, or detected by running a filesystem 222a03ef333SWilly Tarreau consistency check (fsck) on the image prior to mounting. 223a03ef333SWilly Tarreau 224a03ef333SWilly Tarreau* **Physical access**: 225a03ef333SWilly Tarreau 226a03ef333SWilly Tarreau Issues that require physical access to the machine, hardware modification, or 227a03ef333SWilly Tarreau the use of specialized hardware (e.g., logic analyzers, DMA-attack tools over 228a03ef333SWilly Tarreau PCI-E/Thunderbolt) are out of scope unless the system is explicitly 229a03ef333SWilly Tarreau configured with technologies meant to defend against such attacks 230a03ef333SWilly Tarreau (e.g. IOMMU). 231a03ef333SWilly Tarreau 232a03ef333SWilly Tarreau* **Functional and performance regressions**: 233a03ef333SWilly Tarreau 234a03ef333SWilly Tarreau Any issue that can be mitigated by setting proper permissions and limits 235a03ef333SWilly Tarreau doesn't qualify as a security bug. 236