Skip to the content.

This checklist assumes that you are using a Linux-based server, and have physical and root-level access to the machine.

Table of Contents

Introduction

[!Note] In computing, hardening is usually the process of securing a system by reducing its surface of vulnerability, which is larger when a system performs more functions; in principle a single-function system is more secure than a multipurpose one. The main goal of systems hardening is to reduce security risk by eliminating potential attack vectors and condensing the system’s attack surface.

This list contains the most important hardening rules for GNU/Linux systems.

Status

Still work in progress…

Proposed Order

  1. Secure the BIOS/UEFI with a strong passphrase and disable booting from external media.
  2. Secure the bootloader using a strong passphrase.
  3. Disable unnecessary kernel modules.
  4. Uninstall unnecessary software.
  5. Configure regular updates.
  6. Schedule daily snapshots of system data and realtime syncing of user data.
  7. Configure a firewall, an IPS/IDS, and an integrity checker.
  8. Enable AppArmor or SELinux.
  9. Configure and enable Auditd.
  10. Enable disk usage quotas.
  11. Tighten permissions.
  12. Configure PAM appropriately.
  13. Restrict the wheel group’s commands.
  14. Restrict su.
  15. Create a privileged admin user and an unprivileged application user.
  16. Disable root login.
  17. Reboot

Todo

Prologue

I’m not advocating throwing your existing hardening and deployment best practices out the door but I recommend is to always turn a feature from this checklist on in pre-production environments instead of jumping directly into production.

Levels of Priority

All items in this checklist have a priority level:

OpenSCAP

![[openscap_logo.png]] SCAP (Security Content Automation Protocol) provides a mechanism to check configurations, manage vulnerability, and evaluate policy compliance for a variety of systems. One of the most popular implementations of SCAP is OpenSCAP, and it is very helpful for vulnerability assessment and hardening.

Some of the external audit tools use this standard. For example, Nessus has functionality for authenticated SCAP scans.

I tried to make this list compatible with OpenSCAP standard and rules. However, there may be differences.

Partitioning

We will use logical volumes inside a single encrypted partition to keep our setup simple. This is known as LVM on LUKS, which uses a single encryption key to unlock our disk—as opposed to individual keys per partition.

Encrypt Partitions

Separate Volumes

Critical system directories should be separated as much as practically possible. This compartmentalization allows granular disk space allocation as well as the ability to apply granular security options to the mounts.

Restrict Mount Options

Mount options for all separately mounted directories should be restricted as much as practically possible.

Below is a recommended baseline for secure volume mounts:

Mount Point Size Filesystem Options
/home 15% ext4 defaults,nosuid,nodev
/usr 10% ext4 defaults,nodev
/boot 0.1% ext2 defaults,noexec,nosuid,nodev,ro
/var 10% ext4 defaults,nosuid,nodev
/var/log 15% ext4 defaults,noexec,nosuid,nodev
/var/log/audit 15% ext4 defaults,noexec,nosuid,nodev
/var/tmp 10% ext4 defaults,noexec,nosuid,nodev
/tmp 0% tmpfs  
swap 10% swap  
/ 100%FREE ext4 defaults

Polyinstantiated Directories

#ToDo

System Processes

System processes should only be visible to members of the proc group.

Shared Memory

Section Checklist

Physical Access

Protect Single User Mode

Section Checklist

Bootloader

Protect Bootloader Configuration

Section Checklist

Linux Kernel

Kernel logs

Kernel pointers

ExecShield

Memory protections

Modules

Section Checklist

Logging

Syslog

Section Checklist

Users and Groups

Create Users

- `# useradd -m -s /bin/bash -G wheel admin && passwd admin`
- `# useradd -m -s /bin/bash -G users user && passwd user`

Configure PAM

- Use `pam_pwquality` to enforce a secure policy for passwords:
    - `# { echo "password required pam_unix.so use_authtok sha512 shadow rounds=65536"; echo "password required pam_pwquality.so retry=2 minlen=15 difok=8 dcredit=-3 ucredit=-2 lcredit=-2 ocredit=-3 enforce_for_root"; } >> /etc/pam.d/passwd`

Passwords

Logon Access

Restrict su Access

Lock root Account

Section Checklist

Filesystem

Dynamic Mounting and Unmounting

Section Checklist

Permissions

SELinux & Auditd

SELinux Enforcing

Auditd

Section Checklist

System Updates

Network

TCP/SYN

Routing

ICMP Protocol

Broadcast

Section Checklist

Services

Securing SSHd

Edit /etc/ssh/sshd_config to harden the sshd service, if running.

Tools

Useful Tools

Fail2ban – a great tool for automatically banning suspicious IP addresses. ClamAV – an open-source antivirus engine. Lynis – open-source auditing tool for Linux Tripwire/aide/osiris – integrity check SATAN – netwrok scanner ISS (internet security scanner) SNORT

Other Notes

Ways to access root: