Lab 16: CIS Benchmark Hardening

Time: 45 minutes | Level: Architect | Docker: docker run -it --rm --privileged ubuntu:22.04 bash

Overview

The Center for Internet Security (CIS) Benchmarks are the gold standard for system hardening. In this lab you will understand the CIS Level 1 vs Level 2 distinction, run an automated Lynis audit to score your baseline, and then apply the most impactful CIS controls: mount options, core dump restrictions, SSH hardening, password policies, sudo configuration, warning banners, and cron access control.


Step 1 — Understand CIS Benchmark Structure

CIS publishes profiles at two levels:

Level
Purpose
Impact

Level 1

Base hardening; minimal operational impact

Low risk, broad applicability

Level 2

Deep hardening for high-security environments

May break some services

💡 Tip: For most production servers start with Level 1 and selectively apply Level 2 controls after testing.

# Install Lynis — the de-facto CIS scoring tool for Linux
apt-get update -qq && apt-get install -y lynis

# Check version
lynis --version

📸 Verified Output:

3.0.7

Key CIS document sections:

  • Section 1 — Initial Setup (filesystem, software updates)

  • Section 2 — Services (remove unnecessary daemons)

  • Section 3 — Network Configuration

  • Section 4 — Logging and Auditing

  • Section 5 — Access, Authentication and Authorization

  • Section 6 — System Maintenance


Step 2 — Run Lynis Baseline Audit

📸 Verified Output:

💡 Tip: A fresh Ubuntu 22.04 container scores ~60/100. Production targets should be ≥ 75 (Level 1) or ≥ 85 (Level 2).


Step 3 — Filesystem Partitioning & Mount Options (CIS 1.1)

CIS requires separate partitions for /tmp, /var, /var/log, and /home with restrictive mount options.

📸 Verified Output:

Mount option reference:

Option
CIS Control
Effect

nodev

1.1.2–1.1.8

No device files on partition

nosuid

1.1.3–1.1.9

Disable setuid bits

noexec

1.1.4–1.1.10

No executable files


Step 4 — Core Dump Restriction (CIS 1.6.1)

Core dumps can expose sensitive memory contents (passwords, keys).

📸 Verified Output:


Step 5 — SSH Hardening Checklist (CIS 5.2)

📸 Verified Output:


Step 6 — Password Policy & Sudo Timeout (CIS 5.4, 5.3)

📸 Verified Output:

💡 Tip: CIS Level 2 requires minlen = 16 and stricter history (remember = 24 in /etc/pam.d/common-password).


Step 7 — Warning Banners & Cron Access Control (CIS 1.7, 5.1)

📸 Verified Output:


Step 8 — Capstone: Score Your Hardened System

Apply all controls from Steps 3–7 in one script, then re-run Lynis to measure improvement.

📸 Verified Output:

💡 Tip: In a real production system, additional Level 2 controls (AppArmor mandatory enforcement, USBguard, AIDE) push scores to 85+. See Lab 20 for the full capstone.


Summary

Control
CIS Section
Tool/File
Impact

Filesystem mount options

1.1

/etc/fstab

Prevents malware execution on /tmp

Core dump restriction

1.6.1

/etc/security/limits.conf

Protects memory secrets

SSH hardening

5.2

/etc/ssh/sshd_config.d/

Eliminates common attack vectors

Password policy

5.4

/etc/security/pwquality.conf

Enforces strong credentials

Sudo timeout

5.3.7

/etc/sudoers.d/

Limits privilege escalation window

Warning banners

1.7

/etc/issue, /etc/issue.net

Legal deterrent & disclosure

Cron access control

5.1

/etc/cron.allow

Restricts scheduled task abuse

Automated scoring

lynis audit system

Baseline + regression tracking

Last updated