Ubuntu 16,04 LTS Security Features

2020-02-27 169浏览

  • 1.Ubuntu What’s the security story?
  • 2.We raise the bar on Linux security
  • 3.No Open Ports Default installations of Ubuntu must have no listening network services after initial install. Exceptions to this rule include network infrastructure services such as the DHCP client and mDNS (Avahi/ZeroConf, see ZeroConfPolicySpec for implementation details and justification). When installing Ubuntu Server, the administrator can, of course, select specific services to install beyond the defaults (e.g. Apache). Testing for this can be donewith:netstat -an --inet grep LISTEN grep -v 127.0.0.1: on a fresh install.
  • 4.Kernel Livepatches The Canonical Livepatch service provides security fixes for most major kernel security issues without requiring a reboot. Users can take advantage of the service on up to three nodes at no charge. Customers with Ubuntu Advantage support subscription are able to receive live patches on all supported machines at all tiers of support.
  • 5.Extended Security Maintenance The Extended Security Maintenance (ESM) service provides security fixes for high and critical security vulnerabilities after the EOL of Ubuntu LTS. Canonical’s customers with Ubuntu Advantage subscriptions are able to receive ESM updates on all supported machines at all tiers of support.
  • 6.Automatic security updates Starting with Ubuntu 16.04 LTS, unattended-upgrades is configured to automatically apply security updates daily. Earlier Ubuntu releases can be configured to automatically apply security updates.
  • 7.Password hashing Ubuntu 8.10 and later proactively moved to salted SHA-512 based password hashes The system password used for logging into Ubuntu is stored in /etc/shadow. Very old style password hashes were based on DES and visible in /etc/passwd. Modern Linux has long since moved to /etc/shadow, and for some time now has used salted MD5-based hashes for password verification (crypt id 1). MD5 is now considered "broken" for some uses and as computational power available to perform brute-forcing of MD5 increases. Ubuntu uses crypt id 6, which are orders of magnitude more difficult to brute-force. See the crypt manpage for additional details. See test-glibc-security.py for regression tests.
  • 8.SYN cookies When a system is overwhelmed by new network connections, SYN cookie use is activated, which helps mitigate a SYN-flood attack. See test-kernel-security.py for configuration regression tests.
  • 9.Filesystem Capabilities The need for setuid applications can be reduced via the application of filesystem capabilities using the xattrs available to most modern filesystems. This reduces the possible misuse of vulnerable setuid applications. The kernel provides the support, and the user-space tools are in main ("libcap2-bin"). See test-kernel-security.py for configuration regression tests.
  • 10.Configurable Firewall ufw is a frontend for iptables, and is installed by default in Ubuntu (users must explicitly enable it). Particularly well-suited for host-based firewalls, ufw provides a framework for managing a netfilter firewall, as well as a command-line interface for manipulating the firewall. ufw aims to provide an easy to use interface for people unfamiliar with firewall concepts, while at the same time simplifies iptables commands to help an administrator who knows what he or she is doing. ufw is an upstream for other distributions and graphical frontends. See ufw tests for regression tests.
  • 11.Cloud PRNG seed Ubuntu proactively seeds entropy in its pseudo-random number generator. Pollinate is a client application that retrieves entropy from one or more Pollen servers to seed the local Pseudo Random Number Generator (PRNG). Pollinate is designed to adequately and securely seed the PRNG through communications with a Pollen server which is particularly important for systems operating in cloud environments. Starting with Ubuntu 14.04 LTS, Ubuntu cloud images include the Pollinate client, which will try to seed the PRNG with input fromhttps://entropy.ubuntu.comfor up to 3 seconds on first boot. See pollen_test.go for regression tests.
  • 12.PR_SET_SECCOMP Attack surface for system calls is minimized with SECCOMP. Setting SECCOMP for a process is meant to confine it to a small subsystem of system calls, used for specialized processing-only programs. See test-kernel-security.py for regression tests.
  • 13.AppArmor AppArmor is a path-based MAC. It canmediate:● file access (read, write, link, lock), library loading, execution of applications, coarse-grained network (protocol, type, domain), capabilities, coarse owner checks (task must have the same euid/fsuid as the object being checked), mount, unix(7) named sockets, DBus API (path, interface, method), signal(7), ptrace(2), unix(7) abstract and anonymous sockets AppArmor is a core technology for application confinement for snaps on servers, IoT and Ubuntu Touch. See the security policy for Ubuntu Core and Personal. See test-apparmor.py and test-kernel-security.py for regression tests.
  • 14.SELinux SELinux is an inode-based MAC. Targeted policies are available for Ubuntu in universe. Installing the "selinux" package will make the boot-time adjustments that are needed. See test-kernel-security.py for configuration regression tests.
  • 15.SMACK SMACK is a flexible inode-based MAC. See test-kernel-security.py for configuration regression tests.
  • 16.Encrypted LVM Ubuntu can install on an encrypted LVM, which allows all partitions in the logical volume, including swap, to be encrypted. This has been a key capability since the first LTS server release, when it was available in the advanced installer. It is now available across all versions of Ubuntu in the default installer.
  • 17.eCryptfs Encrypted Private Directories, including user home directories enable a secure location for users to store sensitive information. Encrypted Home is supported in the Alternate Installer, and available in the Desktop Installer via the preseed option user-setup/encrypt-home=true.
  • 18.Trusted Platform Module TPM 1.2 support from ‘tpm-tools’ and related libraries are available in Ubuntu. For TPM 2.0, tpm2-tools is available.
  • 19.Userspace Hardening Default compiler flags and kernel settings are tuned for security in Ubuntu. Ubuntu's compiler hardening applies not only to its official builds but also to anything built on Ubuntu using its compiler.
  • 20.Stack Protector gcc's -fstack-protector provides a randomized stack canary that protects against stack overflows. This reduces the chances of arbitrary code execution via controlling return address destinations. Enabled at compile-time. A small number of applications do not play well with it, and have it disabled. The routines used for stack checking are actually part of glibc, but gcc is patched to enable linking against those routines by default. See test-gcc-security.py for regression tests.
  • 21.Heap Protector Ubuntu stops the ability to perform arbitrary code execution via heap memory overflows. The GNU C Library heap protector (both automatic via ptmalloc and manual) provides corrupted-list/unlink/double-free/overflow protections to the glibc heap memory manager (first introduced in glibc 2.3.4), preventing attacks that try to corrupt the control structures of the malloc heap memory areas. This protection has evolved over time, adding more and more protections as additional corner-cases were researched. As it currently stands, glibc 2.10 and later appears to successfully resist even these hard-to-hit conditions. See test-glibc-security.py for regression tests.
  • 22.Pointer Obfuscation Some pointers stored in glibc are obfuscated via PTR_MANGLE/PTR_UNMANGLE macros internally in glibc, preventing libc function pointers from being overwritten during runtime. See test-glibc-security.py for regression tests.
  • 23.Address Space Layout Randomisation (ASLR) Ubuntu makes memory addresses harder to predict when an attacker is attempting a memory-corruption exploit. ASLR is implemented by the kernel and the ELF loader by randomising the location of memory allocations (stack, heap, shared libraries, etc). ASLR is controlled system-wide by the value of /proc/sys/kernel/randomize_va_space. Prior to Ubuntu 8.10, this defaulted to "1" (on). In later releases that included brk ASLR, it defaults to "2" (on, with brk ASLR). See test-kernel-security.py for regression tests for all the different types of ASLR.
  • 24.STACK ASLR Ubuntu makes it harder to locate in memory where to attack or deliver an executable attack payload. Each execution of a program results in a different stack memory space layout.
  • 25.LIBS/MMAP ASLR Ubuntu makes it harder to locate in memory where to jump to for "return to libc" or similar attacks. Each execution of a program results in a different mmap memory space layout, which causes the dynamically loaded libraries to get loaded into different locations each time.
  • 26.EXEC ASLR Ubuntu makes it harder to locate in memory where to attack or jump to when performing memory-corruption-based attacks. Each execution of a program that has been built with "-fPIE -pie" will get loaded into a different memory location. This was backported to Ubuntu 8.04 LTS.
  • 27.BRK ASLR Similar to exec ASLR, brk ASLR adjusts the memory locations relative between the exec memory area and the brk memory area (for small mallocs). The randomization of brk offset from exec memory was added in Ubuntu 8.10, though some of the effects of brk ASLR can be seen for PIE programs in Ubuntu 8.04 LTS since exec was ASLR, and brk is allocated immediately after the exec region - so it was technically randomized, but not randomized with respect to the text region until 8.10.
  • 28.VDSO ASLR Each execution of a program results in a random vdso location. This protects against jump-into-syscall attacks.
  • 29.Built as PIE All programs built on Ubuntu as Position Independent Executables (PIE) with "-fPIE -pie" can take advantage of the exec ASLR. This protects against "return-to-text" and generally frustrates memory corruption attacks. This requires centralized changes to the compiler options when building the entire archive. PIE has a large (5-10%) performance penalty on architectures with small numbers of general registers (e.g. x86), so it should only be used for a select number of security-critical packages (some upstreams natively support building with PIE, other require the use of "hardening-wrapper" to force on the correct compiler and linker flags). PIE on 64-bit architectures do not have the same penalties, and will eventually be made the default. As of 16.10, it is the default on amd64, ppc64el and s390x.
  • 30.Built with Fortify Source Programs built with "-D_FORTIFY_SOURCE=2" (and -O1 or higher), enable several compile-time and run-time protections inglibc:● expand unbounded calls to "sprintf", "strcpy" into their "n" length-limited cousins when the size of a destination buffer is known (protects against memory overflows). ● stop format string "%n" attacks when the format string is in a writable memory segment. ● require checking various important function return codes and arguments (e.g. system, write, open). ● require explicit file mask when creating new files. See test-gcc-security.py for regression tests.
  • 31.Built with RELRO Ubuntu hardens ELF programs against loader memory area overwrites by having the loader mark any areas of the relocation table as read-only for any symbols resolved at load-time ("read-only relocations"). This reduces the area of possible GOT-overwrite-style memory corruption attacks. See test-gcc-security.py for regression tests.
  • 32.Built with BIND_NOW Marks ELF programs to resolve all dynamic symbols at start-up (instead of on-demand, also known as "immediate binding") so that the GOT can be made entirely read-only (when combined with RELRO above). See test-built-binaries.py for regression tests.
  • 33.Non-Executable Memory Most modern CPUs protect against executing non-executable memory regions (heap, stack, etc). This is known either as Non-eXecute (NX) or eXecute-Disable (XD), and some BIOS manufacturers needlessly disable it by default, so check your BIOS Settings. This protection reduces the areas an attacker can use to perform arbitrary code execution. It requires that the kernel use "PAE" addressing (which also allows addressing of physical addresses above 3GB). The 64bit and 32bit -server and -generic-pae kernels are compiled with PAE addressing. Starting in Ubuntu 9.10, this protection is partially emulated for processors lacking NX when running on a 32bit kernel (built with or without PAE).
  • 34./proc/$pid/maps protection Ubuntu protects process memory space layout from other users. With ASLR, a process's memory space layout suddenly becomes valuable to attackers. The "maps" file is made read-only except to the process itself or the owner of the process. See test-kernel-security.py for regression tests.
  • 35.Symlink restrictions Ubuntu symlinks in world-writable sticky directories (e.g. /tmp) cannot be followed if the follower and directory owner do not match the symlink owner. A long-standing class of security issues is the symlink-based ToCToU race, most commonly seen in world-writable directories like /tmp/. The common method of exploitation of this flaw is crossing privilege boundaries when following a given symlink (i.e. a root user follows a symlink belonging to another user). The behavior is controllable through the /proc/sys/kernel/yama/protected_sticky_symlinks sysctl, available via Yama. See test-kernel-security.py for regression tests.
  • 36.Hardlink restrictions Hardlinks cannot be created to files that the user would be unable to read and write originally, or are otherwise sensitive. Hardlinks can be abused in a similar fashion to symlinks above, but they are not limited to world-writable directories. If /etc/ and /home/ are on the same partition, a regular user can create a hardlink to /etc/shadow in their home directory. While it retains the original owner and permissions, it is possible for privileged programs that are otherwise symlink-safe to mistakenly access the file through its hardlink. Additionally, a very minor untraceable quota-bypassing local denial of service is possible by an attacker exhausting disk space by filling a world-writable directory with hardlinks. See test-kernel-security.py for regression tests.
  • 37.ptrace scope In Ubuntu, users cannot ptrace processes that are not a descendant of the debugger. A potential weakness of the Linux process interfaces is that a single user is able to examine the memory and running state of any of their processes. For example, if one application was compromised, it would be possible for an attacker to attach to other running processes (e.g. SSH sessions, GPG agent, etc) to extract additional credentials and continue to immediately expand the scope of their attack without resorting to user-assisted phishing or trojans. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope sysctl, available via Yama. See test-kernel-security.py for regression tests.
  • 38.0-address protection Since the kernel and userspace share virtual memory addresses, the "NULL" memory space needs to be protected so that userspace mmap'd memory cannot start at address 0, stopping "NULL dereference" kernel attacks. This is implemented with the "mmap_min_addr" sysctl setting. Since Ubuntu 9.04, the mmap_min_addr setting is built into the kernel (64k for x86, 32k for ARM). See test-kernel-security.py for regression tests.
  • 39./dev/mem protection Some applications (Xorg) need direct access to the physical memory from user-space. The special file /dev/mem exists to provide this access. In the past, it was possible to view and change kernel memory from this file if an attacker had root access. The CONFIG_STRICT_DEVMEM kernel option was introduced to block non-device memory access (originally named CONFIG_NONPROMISC_DEVMEM). See test-kernel-security.py for regression tests.
  • 40./dev/kmem disabled There is no modern user of /dev/kmem any more beyond attackers using it to load kernel rootkits. CONFIG_DEVKMEM is set to "n". While the /dev/kmem device node still exists in Ubuntu 8.04 LTS through Ubuntu 9.04, it is not actually attached to anything in the kernel and thus disabled. See test-kernel-security.py for regression tests.
  • 41.Block module loading In Ubuntu 8.04 LTS and earlier, it was possible to remove CAP_SYS_MODULES from the system-wide capability bounding set, which would stop any new kernel modules from being loaded. This was another layer of protection to stop kernel rootkits from being installed. The 2.6.25 Linux kernel (Ubuntu 8.10) changed how bounding sets worked, and this functionality disappeared. Starting with Ubuntu 9.10, it is now possible to block module loading again by setting "1" in /proc/sys/kernel/modules_disabled. See test-kernel-security.py for regression tests.
  • 42.Read-only data sections This makes sure that certain kernel data sections are marked to block modification. This helps protect against some classes of kernel rootkits. Enabled via the CONFIG_DEBUG_RODATA option. See test-kernel-security.py for configuration regression tests.
  • 43.Stack protector Similar to the stack protector used for ELF programs in userspace, the kernel can protect its internal stacks as well. Enabled via the CONFIG_CC_STACKPROTECTOR option. See test-kernel-security.py for configuration regression tests.
  • 44.Module RO/NX This feature extends CONFIG_DEBUG_RODATA to include similar restrictions for loaded modules in the kernel. This can help resist future kernel exploits that depend on various memory regions in loaded modules. Enabled via the CONFIG_DEBUG_MODULE_RONX option. See test-kernel-security.py for configuration regression tests.
  • 45.Kernel Address Display Restriction When attackers try to develop "run anywhere" exploits for kernel vulnerabilities, they frequently need to know the location of internal kernel structures. By treating kernel addresses as sensitive information, those locations are not visible to regular local users. Starting with Ubuntu 11.04, /proc/sys/kernel/kptr_restrict is set to "1" to block the reporting of known kernel address leaks. Additionally, various files and directories were made readable only by the rootuser:/boot/vmlinuz*, /boot/System.map*, /sys/kernel/debug/, /proc/slabinfo See test-kernel-security.py for regression tests.
  • 46.Kernel Address Space Layout Randomisation Kernel Address Space Layout Randomisation (kASLR) aims to make some kernel exploits more difficult to implement by randomizing the base address value of the kernel. Exploits that rely on the locations of internal kernel symbols must discover the randomized base address. kASLR is available but it is not enabled by default. Specify the "kaslr" option on the kernel command line to use kASLR.Note:Enabling kASLR will disable the ability to enter hibernation mode.
  • 47.Blacklist Rare Protocols Normally the kernel allows all network protocols to be autoloaded on demand via the MODULE_ALIAS_NETPROTO(PF_...) macros. Since many of these protocols are old, rare, or generally of little use to the average Ubuntu user and may contain undiscovered exploitable vulnerabilities, they have been blacklisted since Ubuntu 11.04. Theseinclude:ax25, netrom, x25, rose, decnet, econet, rds, and af_802154. If any of the protocols are needed, they can be loaded via modprobe, or the /etc/modprobe.d/blacklist-rare-network.conf file can be updated to remove the blacklist entry. See test-kernel-security.py for regression tests.
  • 48.Syscall Filtering Programs can filter out the availability of kernel syscalls by using the seccomp_filter interface. This is done in containers or sandboxes that want to further limit the exposure to kernel interfaces when potentially running untrusted software. See test-kernel-security.py for regression tests.
  • 49.dmesg restrictions When attackers try to develop "run anywhere" exploits for vulnerabilities, they frequently will use dmesg output. By treating dmesg output as sensitive information, this output is not available to the attacker. Starting with Ubuntu 12.04 LTS, /proc/sys/kernel/dmesg_restrict can be set to "1" to treat dmesg output as sensitive. Ubuntu Touch kernels have this enabled by default.
  • 50.Block kexec Starting with Ubuntu 14.04 LTS, it is now possible to disable kexec via sysctl. CONFIG_KEXEC is enabled in Ubuntu so end users are able to use kexec as desired and the new sysctl allows administrators to disable kexec_load. This is desired in environments where CONFIG_STRICT_DEVMEM and modules_disabled are set, for example.
  • 51.UEFI Secure Boot (amd64) UEFI Secure Boot is implemented in enforcing mode for the bootloader and non-enforcing mode for the kernel. With this configuration, a kernel that fails to verify will boot without UEFI quirks enabled. In the future, all supported Ubuntu releases will receive updates to use enforcing mode for the bootloader and kernel by default.
  • 52.