Security Controls & System Hardening
Turn principles into practice: the control categories (preventive/detective/corrective), least privilege, patching, logging, and a practical hardening baseline.
1. Executive Summary & Objective
Principles (CIA, Zero Trust) become real through controls and hardening. This capstone lesson organizes controls by type and gives you a practical baseline to shrink a systemβs attack surface.
Objective: Classify controls as preventive/detective/corrective, apply least privilege and patching, and build a hardening baseline you can defend.
2. Core Concept & Theory (The βWhyβ)
Controls are commonly categorized by when they act relative to an incident:
Theyβre also grouped as technical (firewall, encryption), administrative (policies, training), and physical (locks, badges). A healthy program has all three, across all three timings.
3. A Practical Hardening Baseline
- Least privilege β remove local admin, scope service accounts, use role-based access.
- Patch β prioritize internet-facing and known-exploited CVEs; automate where safe.
- Reduce surface β disable unused services/ports; remove default accounts and sample apps.
- Harden auth β MFA everywhere, strong password policy, lockouts.
- Log centrally β forward to a SIEM so logs survive the host and feed detection.
- Baseline + benchmark β apply a CIS Benchmark / STIG and measure drift.
4. Command Execution (Linux hardening snippets)
# Who has a login shell / is privileged?
getent passwd | awk -F: '$7 !~ /nologin|false/ {print $1}'
sudo grep -E '^sudo|^wheel' /etc/group
# Remove an unneeded service and close its surface
sudo systemctl disable --now telnet.socket 2>/dev/null
# Ship logs off-box (survives attacker log wiping)
echo '*.* @10.0.0.60:514' | sudo tee /etc/rsyslog.d/90-forward.conf
sudo systemctl restart rsyslog
5. Hands-on Lab
Apply three core hardening steps on a Linux host.
Lab: Linux hardening baseline
Audit privileged users, disable an unused service, and forward logs to the SIEM.
Objectives
- List who has sudo (privileged) rights.
- Disable an insecure/unused service to cut attack surface.
- Forward logs off-box to the SIEM.
- Apply the logging change.
Hands-on: enforce a password policy in code
Security controls arenβt abstract β a password policy is just a function that returns pass or fail. Implement it in real Python.
That function is exactly what an identity provider or PAM module runs on every password change β βhardeningβ is policy, enforced automatically.
6. Key Takeaways
- Classify controls by timing: preventive β detective β corrective, across technical/admin/physical.
- Least privilege shrinks blast radius; patching closes known exploits.
- Reduce attack surface β disable what you donβt need.
- Central logging makes you able to detect, investigate, and prove incidents.
π§ͺ Want to practise this on your own computer? See how to set up your lab →