Endpoint Security and System Hardening: EDR, Patching, CIS Benchmarks
Endpoints (laptops, desktops, servers, phones) are where users work and where most attacks land. Even the best network defences fail if a single laptop is poorly configured. System hardening means reducing the attack surface of a computer by removing what is unnecessary, tightening what remains and verifying that it stays that way. Endpoint security adds tools that detect and respond to threats on the device. This lesson gives you a practical hardening framework, with hands-on lab steps for Linux and Windows and an explanation of modern endpoint protection.
Hardening Principles
- Minimise: install only what is needed; disable unneeded services, accounts, ports and features.
- Patch: keep operating systems, applications and firmware up to date.
- Least privilege: standard accounts for daily work; separate admin accounts for administration.
- Secure configuration: follow trusted baselines and remove insecure defaults.
- Protect data: full-disk encryption, secure backups, controlled removable media.
- Monitor: log security events and check for configuration drift.
- Automate: use configuration management so every machine starts the same and stays compliant.
Where to Find Trusted Baselines
| Source | What it provides |
|---|---|
| CIS Benchmarks (Center for Internet Security) | Detailed, consensus-based configuration guides for operating systems, browsers, cloud and more |
| CIS Controls | Prioritised safeguards for defence |
| DISA STIGs | Security technical implementation guides used by US defence organisations |
| Microsoft Security Baselines | Recommended settings for Windows and Microsoft products |
| Vendor hardening guides | Guidance from Red Hat, Ubuntu, Apple and others |
Always test a baseline on non-production systems first, since strict settings can break applications.
Practice Lab 1: Harden a Linux Server (Your Lab VM)
Take a snapshot first, so you can roll back. Then work through these steps and record the “before” and “after” for each.
Step 1: Update everything
sudo apt update && sudo apt upgrade -y
sudo apt install unattended-upgrades # automatic security updates
Step 2: Review users and sudo
awk -F: '$3 >= 1000 {print $1}' /etc/passwd # human accounts
getent group sudo # who has admin rights
sudo passwd -l unwanted_user # lock an unused account
Step 3: Harden SSH
Edit /etc/ssh/sshd_config (keep a second session open when testing):
PermitRootLogin no
PasswordAuthentication no # after you have set up key-based login
PubkeyAuthentication yes
MaxAuthTries 3
AllowUsers analyst
X11Forwarding no
sudo sshd -t && sudo systemctl reload ssh
Step 4: Close unneeded ports and services
sudo ss -tulpn # what is listening?
systemctl list-unit-files --state=enabled
sudo systemctl disable --now cups # example: disable printing service if not needed
Step 5: Enable a firewall
Use the steps in Firewalls, IDS/IPS and Segmentation.
Step 6: File permissions and integrity
sudo find / -xdev -perm -0002 -type f 2>/dev/null # world-writable files
sudo apt install aide # file integrity monitoring
sudo aideinit
Step 7: Mandatory access control and audit
Keep AppArmor (Ubuntu) or SELinux (Red Hat family) enabled and enforcing. Install and configure auditd to log security-relevant events.
Step 8: Measure with an audit tool
sudo apt install lynis
sudo lynis audit system
Lynis gives a hardening index and a list of suggestions. Record your score before and after your changes, then fix the top five suggestions and rerun.
Practice Lab 2: Harden a Windows Machine (Your Lab VM)
- Update: run Windows Update and enable automatic updates.
- Accounts: use a standard account for daily work; rename or disable the built-in Administrator if appropriate; check
net localgroup Administrators. - Firewall: confirm Windows Defender Firewall is on for all profiles.
Get-NetFirewallProfile | Select-Object Name, Enabled - Disk encryption: enable BitLocker where supported and store the recovery key safely.
- Protection features: check Microsoft Defender Antivirus, SmartScreen, tamper protection, Controlled Folder Access and Credential Guard availability.
Get-MpComputerStatus | Select-Object AMServiceEnabled, RealTimeProtectionEnabled Get-MpPreference | Select-Object EnableControlledFolderAccess - Remove risky features: disable SMBv1 if present.
Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol - Policy: apply a Microsoft baseline or CIS benchmark profile using Group Policy, and compare before and after.
- Logging: enable command-line logging and PowerShell script block logging; see Windows and Active Directory Security Basics.
Modern Endpoint Protection
| Technology | What it does |
|---|---|
| Antivirus (AV) | Detects known malware by signatures and heuristics |
| Next-generation antivirus (NGAV) | Adds machine-learning, behaviour analysis and exploit prevention |
| EDR (endpoint detection and response) | Continuously records endpoint activity, detects suspicious behaviour and lets analysts investigate and isolate hosts |
| XDR (extended detection and response) | Correlates data from endpoints, email, identity, network and cloud |
| Application control / allow-listing | Permits only approved programs to run |
| Mobile device management (MDM) | Enforces policies on phones and tablets: encryption, updates, remote wipe |
| Data loss prevention (DLP) | Detects and blocks sensitive data leaving the endpoint |
EDR is valuable because prevention is never perfect; it gives you visibility to see what an intruder did and the ability to contain a machine quickly. Pair it with a team or service that actually watches the alerts; see SIEM, Logging and SOC Operations.
Configuration Management and Drift
Manual hardening does not scale. Use tools such as Ansible, Group Policy, Microsoft Intune, Puppet or Chef to apply the baseline automatically, and compliance scanners (OpenSCAP, Lynis, CIS-CAT) to check it. A minimal Ansible example that enforces an SSH setting:
- hosts: lab_servers
become: true
tasks:
- name: Disable root login over SSH
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PermitRootLogin'
line: 'PermitRootLogin no'
notify: Reload ssh
handlers:
- name: Reload ssh
ansible.builtin.service:
name: ssh
state: reloaded
Common Mistakes
- Hardening a “golden image” once and never reviewing it.
- Giving everyone local administrator rights.
- Disabling security tools to fix an application problem and forgetting to re-enable them.
- Unencrypted laptops that can be lost or stolen with all their data.
- No inventory, so unmanaged devices sit outside the controls.
Practice Exercises
- Create a one-page hardening checklist for a new Linux web server and a new Windows laptop.
- Run Lynis (or another audit tool) before and after your changes, and write a short summary of what improved.
- Explain the difference between antivirus and EDR to a non-technical manager.
- Write an Ansible task or Group Policy setting that enforces a password-length rule.
- Describe how you would recover an encrypted laptop whose user has forgotten the password, and why key escrow matters.
Mentor tip: Hardening is not a project; it is a habit. Measure it, automate it and review it after every major update. A system that was secure last year may not be secure today.
Educational use only: apply hardening changes on systems you own or administer, and test them in a lab or staging first.
- Hardening shrinks the attack surface: minimise, patch, restrict, encrypt and monitor.
- Use CIS Benchmarks or vendor baselines and test before rollout.
- EDR adds detection and response on top of prevention.
- Automate configuration and check for drift.
- Measure progress with audit tools and track improvements over time.