Labs / Night Watch / Harden & audit: vulnerability scanning, baselines & file integrity

Lab 1 of 1 · Harden & audit: vulnerability scanning, baselines & file integrity

Vulnerability management: scan, assess, remediate, rescan

Scan a host against a baseline, fix the findings and catch a tampered file.

Start this lab 5 steps

The idea

Abebe looks after the computers at Wrenfield Veterinary Clinic. The contractor who set up the clinic's booking server, appHost, has moved on, and the clinic's insurer wants proof by Friday that its servers meet a security baseline. Abebe has never looked closely at this machine.

Vulnerability management is a loop: scan a host against a security baseline, fix the worst findings first, and rescan until it is clean. Abebe scans appHost with OpenSCAP, watches its files with AIDE, and checks from the admin workstation that the booking page stays up throughout.

The scan compares two lists
The scan compares two lists
Where 8.1 sits
Where 8.1 sits
The vulnerability-management loop
The vulnerability-management loop
A baseline of fingerprints
A baseline of fingerprints
A changed file, a different hash
A changed file, a different hash

Steps

  1. Scan: a credentialed scan of the host you run

    You cannot fix what you have not found, so the loop starts with a scan. Abebe runs oscap on appHost itself, with full access to its real sshd_config and file permissions: a credentialed scan. It checks the host against a small baseline and prints pass or fail for each rule.

    appHost:~# oscap xccdf eval --profile xccdf_org.netlab_profile_baseline --results /root/scan1.xml /root/baseline.xccdf.xml
  2. Assess: read each finding's severity and fix the worst first

    A list of findings is not a plan. Each rule carries a severity, and the regreSSHion rule also carries a real CVE and its CVSS base score, a 0 to 10 rating of how bad a flaw is. Severity is how you prioritise: the high-severity item goes first.

    appHost:~# grep -E "Rule id|severity|CVE-2024|CVSS" /root/baseline.xccdf.xml
  3. Remediate and rescan

    Two halves close the loop: remediate (apply the fixes) and rescan (prove they worked).

    The SSH fixes go in sshd_config. PermitRootLogin no stops anyone logging in as root directly, so an attacker has to get past an ordinary account first. LoginGraceTime 0 is the published mitigation for regreSSHion: the flaw sits in what sshd does when a login takes too long, and 0 turns that timeout off.

    The third fix is the backup credentials file. It holds a password that every user on the box can read, so chmod 600 makes it readable by its owner only.

    Then Abebe runs the same scan again. A fix you never rescan is a fix you only hope worked, and the insurer wants the rescan, not the promise.

    appHost:~# chmod 600 /etc/backup.env
    appHost:~# oscap xccdf eval --profile xccdf_org.netlab_profile_baseline /root/baseline.xccdf.xml
  4. Baseline the host's files with AIDE

    Scanning finds weak settings. File-integrity monitoring catches a trusted file being changed behind your back. With the host clean, Abebe takes an AIDE baseline, then checks against it right away.

    appHost:~# aide --config=/root/aide.conf --init
    appHost:~# aide --config=/root/aide.conf --check
  5. Detect tampering, then restore

    On Thursday night someone edits sshd_config to re-open direct root login. Nobody approved it, and the next settings scan might not run for days, so the integrity check is what catches it. Abebe then restores the file, confirms the baseline holds, and checks the booking page never went down.

    appHost:~# aide --config=/root/aide.conf --check
    appHost:~# aide --config=/root/aide.conf --check
    appHost:~# oscap xccdf eval --profile xccdf_org.netlab_profile_baseline /root/baseline.xccdf.xml
    admin:~# curl -sS -m3 http://10.0.1.10/

Run these steps on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab