How to harden security in Ubuntu Linux

Case #

Canonical provides documentation and tools to help you get started in your journey to make Ubuntu Linux more secure. This KB article provides guidance on how to harden security in Ubuntu Linux. All security-related documentation and tools can be found under https://ubuntu.com/security.

Solution #

Ubuntu infrastructure hardening guide #

Before moving on with any security hardening tasks, you should first download and review the guide to Ubuntu infrastructure hardening: https://ubuntu.com/engage/a-guide-to-infrastructure-hardening. This includes all security design considerations for any Ubuntu on-premise, cloud or hybrid deployment.

Ubuntu Linux security features #

Ubuntu Linux is full of security features as described in a relevant security features matrix by Canonical.

https://wiki.ubuntu.com/Security/Features

feature20.04 LTS22.04 LTS23.0423.1024.04 LTS.
No Open Portspolicypolicypolicypolicypolicy
Password hashingsha512yescryptyescryptyescryptyescrypt
SYN cookieskernel & sysctlkernel & sysctlkernel & sysctlkernel & sysctlkernel & sysctl
Automatic security updatesenabledenabledenabledenabledenabled
Kernel Livepatches20.04 LTS Kernel22.04 LTS Kernel------
Disable legacy TLSpolicypolicypolicypolicypolicy
Filesystem Capabilitieskernel & userspace (default on server)kernel & userspace (default on server)kernel & userspace (default on server)kernel & userspace (default on server)kernel & userspace (default on server)
Configurable Firewallufwufwufwufwufw
Cloud PRNG seedpollinatepollinatepollinatepollinatepollinate
PR_SET_SECCOMPkernelkernelkernelkernelkernel
AppArmor2.13.33.0.43.0.73.0.73.0.7
SELinuxuniverseuniverseuniverseuniverseuniverse
SMACKkernelkernelkernelkernelkernel
Encrypted LVMmain installermain installermain installermain installermain installer
File EncryptionZFS dataset encryption available, encrypted Home (eCryptfs) and ext4 encryption (fscrypt) available in universeZFS dataset encryption available, encrypted Home (eCryptfs) and ext4 encryption (fscrypt) available in universeZFS dataset encryption available, encrypted Home (eCryptfs) and ext4 encryption (fscrypt) available in universeZFS dataset encryption available, encrypted Home (eCryptfs) and ext4 encryption (fscrypt) available in universeZFS dataset encryption available, encrypted Home (eCryptfs) and ext4 encryption (fscrypt) available in universe
Trusted Platform Modulekernel & userspace (tpm-tools)kernel & userspace (tpm-tools)kernel & userspace (tpm-tools)kernel & userspace (tpm-tools)kernel & userspace (tpm-tools)
Stack Protectorgcc patchgcc patchgcc patchgcc patchgcc patch
Heap Protectorglibcglibcglibcglibcglibc
Pointer Obfuscationglibcglibcglibcglibcglibc
Stack ASLRkernelkernelkernelkernelkernel
Libs/mmap ASLRkernelkernelkernelkernelkernel
Exec ASLRkernelkernelkernelkernelkernel
brk ASLRkernelkernelkernelkernelkernel
VDSO ASLRkernelkernelkernelkernelkernel
Built as PIEgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for others
Built with Fortify Sourcegcc patchgcc patchgcc patchgcc patchgcc patch
Built with RELROgcc patchgcc patchgcc patchgcc patchgcc patch
Built with BIND_NOWgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for othersgcc patch (amd64, ppc64el, s390x), package list for others
Built with -fstack-clash-protectiongcc patch (i386, amd64, ppc64el, s390x)gcc patch (i386, amd64, ppc64el, s390x)gcc patch (i386, amd64, ppc64el, s390x)gcc patch (i386, amd64, ppc64el, s390x)gcc patch (i386, amd64, ppc64el, s390x)
Built with -fcf-protectiongcc patch (i386, amd64)gcc patch (i386, amd64)gcc patch (i386, amd64)gcc patch (i386, amd64)gcc patch (i386, amd64)
Non-Executable MemoryPAE, ia32 partial-NX-emulationPAE, ia32 partial-NX-emulationPAE, ia32 partial-NX-emulationPAE, ia32 partial-NX-emulationPAE, ia32 partial-NX-emulation
/proc/$pid/maps protectionkernelkernelkernelkernelkernel
Symlink restrictionskernelkernelkernelkernelkernel
Hardlink restrictionskernelkernelkernelkernelkernel
FIFO restrictionskernel & sysctlkernel & sysctlkernel & sysctlkernel & sysctlkernel & sysctl
Regular file restrictionskernel & sysctlkernel & sysctlkernel & sysctlkernel & sysctlkernel & sysctl
ptrace scopekernelkernelkernelkernelkernel
0-address protectionkernelkernelkernelkernelkernel
/dev/mem protectionkernelkernelkernelkernelkernel
/dev/kmem disabledkernelkernelkernelkernelkernel
Block module loadingsysctlsysctlsysctlsysctlsysctl
Read-only data sectionskernelkernelkernelkernelkernel
Stack protectorkernelkernelkernelkernelkernel
Module RO/NXkernelkernelkernelkernelkernel
Kernel Address Display Restrictionkernelkernelkernelkernelkernel
Kernel Address Space Layout Randomisationkernel (i386, amd64, arm64, and s390 only)kernel (i386, amd64, arm64, and s390 only)kernel (i386, amd64, arm64, and s390 only)kernel (i386, amd64, arm64, and s390 only)kernel (i386, amd64, arm64, and s390 only)
Denylist Rare Protocolskernelkernelkernelkernelkernel
Syscall Filteringkernelkernelkernelkernelkernel
dmesg restrictionssysctlkernelkernelkernelkernel
Block kexecsysctlsysctlsysctlsysctlsysctl
UEFI Secure Boot (amd64)amd64, kernel signature enforcementamd64, kernel signature enforcementamd64, kernel signature enforcementamd64, kernel signature enforcementamd64, kernel signature enforcement
usbguardkernel & userspacekernel & userspacekernel & userspacekernel & userspacekernel & userspace
usbauthkernel & userspacekernel & userspacekernel & userspacekernel & userspacekernel & userspace
boltkernel & userspacekernel & userspacekernel & userspacekernel & userspacekernel & userspace
thunderbolt-toolskernel & userspacekernel & userspacekernel & userspacekernel & userspacekernel & userspace
Kernel Lockdownintegrity only, no confidentialityintegrity only, no confidentialityintegrity only, no confidentialityintegrity only, no confidentialityintegrity only, no confidentiality

Ubuntu Pro #

By making use of a free Ubuntu Pro subscription you can ensure that you maximize potential for security features in your Ubuntu installation. Subscribe for free with an Ubuntu Pro account and link up to 5 machines to this subscription. Pricing is free for personal usage.

Visit https://ubuntu.com/pro/dashboard after logging into your Ubuntu Pro account. An example of a free Ubuntu Pro account dashboard is shown below.

Enable any additional features in Ubuntu Pro, as shown in the screenshot below.

With Ubuntu Pro enabled, carry out the following action items for Ubuntu Linux machine security hardening.

ESMSet up access to security updates with ESM
USGAutomated hardening profiles for CIS and DISA STIG
FIPSNIST-certified FIPS 140 cryptographic modules for Ubuntu
LivepatchLivepatch on-prem and Livepatch client
LandscapeHow to use Landscape to manage Ubuntu Systems
Real-time kernelPrioritise high-priority processes with deterministic response times.
Active directoryAdvanced GPO support, privilege management and script execution
Common CriteriaCommon Criteria EAL 2 packages for 16.04 & 18.04

Ubuntu security certifications and hardening #

Canonical Ubuntu provides the following security certifications and compliance controls.

Ubuntu Livepatch #

Livepatch eliminates the need for unplanned maintenance windows for high and critical severity kernel vulnerabilities by patching the Linux kernel while the system runs. You can downtime and keep uninterrupted service with the Ubuntu Livepatch service for up to 10 years.

Expanded Security Maintenance (ESM) #

ESM enables continuous vulnerability management for critical, high and medium CVEs. You can review the terms and 5-year vs 10-year coverage for Ubuntu on the following page: https://ubuntu.com/security/esm.

CVE reports #

The Common Vulnerabilities and Exposures (CVE) system is used to identify, define, and catalog publicly disclosed cybersecurity vulnerabilities. Canonical keeps track of all CVEs affecting Ubuntu, and releases a security notice when an issue is fixed. Canonical also produces Open Vulnerability and Assessment Language (OVAL) data, which is machine-readable, to enable auditing for CVEs and to determine whether a particular patch, via an Ubuntu Security Notice (USN), is appropriate for the local system. Also refer to the Ubuntu Security Notices for more details.

Ubuntu OCI images #

Canonical provides hardened OCI container images, with stable tracks from development to production. Canonical provides up to ten years guaranteed security maintenance from Canonical’s trusted repositories. You can browse the full repository of images on the relevant Docker Hub registry page at: https://hub.docker.com/u/ubuntu.

Canonical cybersecurity webinar #

Last but not least, it is highly recommended to watch the cybersecurity webinar by Canonical, in which the following topics are discussed:

  • Provide an introduction to cybersecurity and zero trust.
  • Highlight the common challenges faced in the implementation of cybersecurity programs, including challenges in vulnerability management, secure configuration of software and defenses against malware.
  • Discuss how Canonical and Ubuntu can help manage these challenges and lay the foundation of a successful cybersecurity program.

Powered by BetterDocs