Kahibaro
Discord Login Register

Vulnerability scanning

Why Vulnerability Scanning Matters in Hardening

Vulnerability scanning is the systematic process of detecting known weaknesses in a system, service, or application by comparing what’s running on the system against:

Within a hardening workflow, scanning is how you:

This chapter focuses on practical, host-centric scanning and how to integrate it into a Linux hardening process.

Types of Vulnerability Scanners

Network vs Host-Based Scanning

You usually want both:

Authenticated vs Unauthenticated Scans

For hardening, prefer authenticated scans wherever possible.

Core Concepts and Terminology

CVEs, CVSS, and CPEs

Scanners map:

  1. Detected software (via package databases, banners, fingerprints)
  2. To CPEs
  3. Then to CVEs with CVSS scores

This mapping is imperfect; understanding that imperfection is critical when interpreting results.

False Positives and False Negatives

Hardening requires you to:

Typical Vulnerability Scanning Workflow

A pragmatic host hardening workflow with scanning might look like:

  1. Define scope and assumptions
    • Which hosts, networks, and environments (prod/stage/dev)?
    • What is “in scope” for compliance or audits?
  2. Establish a baseline scan
    • Run initial authenticated host scans
    • Run a perimeter network scan from a representative vantage point
    • Archive scan results as the “pre-hardening” state
  3. Harden the system
    • Apply OS and package updates
    • Apply baseline hardening (sysctl, SSH settings, firewall, etc. – covered in the hardening chapter)
    • Remove or restrict unnecessary services
  4. Run post-hardening scans
    • Compare before/after
    • Ensure:
      • Fewer exposed ports
      • Fewer high/critical CVEs
      • No newly introduced critical findings (e.g., misconfigured firewall rule)
  5. Triage and remediation
    • Sort by severity and exploitability
    • Identify quick wins vs. architectural issues
    • Open tickets / tasks with clear owners and remediation plans
  6. Continuous scanning
    • Schedule regular scans (daily/weekly)
    • Track new vulnerabilities that appear in:
      • New software you deploy
      • Old software as new CVEs are discovered

Practical Host-Based Scanning on Linux

Distro Security Tools and Package Vulnerability Checks

Most distributions publish security advisories and have tooling to detect vulnerable installed packages.

Debian / Ubuntu

    sudo apt update
    sudo apt upgrade
    sudo apt install debian-security-support
    check-support-status

Third-party tools like debsecan (Debian) or ubuntu-security-status (Ubuntu) can map installed packages to CVEs using distro data.

RHEL / CentOS / AlmaLinux / Rocky Linux

  sudo dnf updateinfo list security
  sudo dnf update --security

Fedora

  sudo dnf updateinfo
  sudo dnf update --security

Arch / Manjaro

  sudo pacman -Syu

openSUSE / SUSE Linux Enterprise

  sudo zypper lp -g security  # list patches
  sudo zypper patch --category security

For hardening, tie vulnerability scanning with your package update policy: unpatched software is the most common, easily measurable risk.

OpenSCAP (SCAP-Based Scanning)

OpenSCAP implements the SCAP standards suite (XCCDF, OVAL, etc.) and is widely used for:

Core ideas:

Basic Usage

Install OpenSCAP and relevant content:

  sudo dnf install openscap-scanner scap-security-guide
  sudo apt install libopenscap8 ssg-base

List available profiles (e.g., for RHEL-like systems):

oscap info /usr/share/xml/scap/ssg/content/ssg-<your-distro>-ds.xml

Run a scan with a specific profile:

sudo oscap xccdf eval \
  --profile xccdf_org.ssgproject.content_profile_standard \
  --results results-xccdf.xml \
  --report report-xccdf.html \
  /usr/share/xml/scap/ssg/content/ssg-<your-distro>-ds.xml

For vulnerability (OVAL) scanning, you may use OVAL feeds supplied by your distro or third parties:

sudo oscap oval eval --results oval-results.xml --report oval-report.html <oval-definitions.xml>

Open the HTML report and look for:

Integrating with Hardening

Lynis: Lightweight Host Audit & Vulnerability Scanner

Lynis is a host-based auditing tool focused on Unix-like systems. It’s useful for:

Installation

On many systems you can install from packages, or directly from upstream tarball:

# Example for Debian/Ubuntu
sudo apt install lynis

Running a Scan

sudo lynis audit system

Key outputs:

To use it in hardening:

Specialized Tools: osquery and Custom Checks

osquery exposes system state as SQL tables. While not a scanner by itself, you can:

For highly specialized environments, it can be more maintainable to:

Network-Based Vulnerability Scanning

Port Scanning as a Baseline

Before running complex scanners, always know which ports are open.

Nmap Port Scanning

Quick scan of common ports:

nmap -sS -T4 <target>

More comprehensive:

nmap -sS -sV -O -p- <target>

Use this to:

Nmap Scripting Engine (NSE) for Known Vulnerabilities

NSE packs many vuln-related scripts. Example:

nmap --script vuln -sV <target>

This runs scripts tagged vuln against detected services to check for:

Use NSE carefully:

Full-Fledged Network Vulnerability Scanners

Tools like OpenVAS/GVM, Nessus, or Qualys:

From a hardening standpoint:

Align scanning with change windows to avoid surprises and plan remediation.

Container and Image Vulnerability Scanning

In containerized environments, you must scan:

Popular image scanners include:

Example using Trivy:

trivy image myapp:latest

Integrate image scanning:

Prioritizing and Acting on Findings

You will always have more findings than you can fix immediately. A disciplined prioritization strategy is essential.

Prioritization Criteria

Combine several dimensions:

You can create a simple formula, for example:

$$
\text{Risk Score} = \text{CVSS} \times \text{Exposure Factor} \times \text{Exploitability Factor}
$$

Where:

Use such a ranking to decide remediation order.

Remediation Strategies

Common hardening actions triggered by scans:

Each accepted risk should be:

Scheduling and Automating Vulnerability Scans

Choosing Scan Frequencies

Typical patterns:

Combine:

Automation with Cron and CI/CD

Example: Run Lynis weekly and keep logs:

sudo crontab -e

Add:

0 3 * * 1 /usr/sbin/lynis audit system --quiet --logfile /var/log/lynis-$(date +\%F).log

For OpenSCAP, you might:

In CI/CD:

Integrating Vulnerability Scanning into a Hardening Program

To make vulnerability scanning truly useful (and not just report spam):

  1. Define policies
    • Acceptable maximum age for unpatched criticals
    • Required frequency of scans by asset class
  2. Standardize tooling
    • Choose a primary host scanner and network scanner
    • Standardize profiles (OpenSCAP, Lynis configs, etc.)
  3. Connect with patch management
    • Findings should feed directly into your patch/change process
    • Track time-to-remediate for key vulnerabilities
  4. Measure and track trends
    • Number of open critical/high findings over time
    • Percentage of systems fully scanned in the last period
    • Hardening score trends (from Lynis / OpenSCAP profiles)
  5. Ensure coverage
    • Use inventory/CMDB to verify all assets are included
    • Include ephemeral/cloud resources (dynamic IPs, autoscaling)

Common Pitfalls and How to Avoid Them

By treating vulnerability scanning as a continuous feedback loop—informing and validating your hardening efforts—you convert raw findings into a structured, repeatable process for reducing risk on Linux systems.

Views: 23

Comments

Please login to add a comment.

Don't have an account? Register now!