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