← Rules Catalog
mediumsystem

Ensure updates, patches, and additional security software are installed

security-updates-installed · RHEL ≥ 8 · 1 impl

Description

Available vendor updates and security patches should be applied. This rule flags when the package manager reports pending updates.

Rationale

Unapplied updates leave known vulnerabilities exploitable. Keeping the system current is a primary defense against publicly known CVEs.

Check → Remediate

Checkcommand
# Capture the exit code DIRECTLY. The previous version wrapped this in
# `if dnf check-update; then ... fi` and then read $? afterwards, which
# is always 0: a shell `if` whose condition fails and which has no else
# returns success. So rc was never 100, the pending-updates branch was
# unreachable, and a host with 384 pending packages reported OK.
dnf -q check-update >/dev/null 2>&1
rc=$?
case "$rc" in
  0)
    echo "OK: no pending package updates"
    exit 0
    ;;
  100)
    n=$(dnf -q check-update 2>/dev/null | grep -cE '^[a-zA-Z0-9]')
    echo "FAIL: ${n:-some} package update(s) pending; system flaws are not corrected"
    exit 1
    ;;
  *)
    # dnf could not answer: no network, a broken repo, no metadata. That
    # is not evidence the host is patched, and reporting OK here is how
    # the old version hid a real finding. Fail loudly with the code.
    echo "FAIL: dnf check-update could not complete (exit $rc), so pending updates are unknown"
    exit 1
    ;;
esac
expected_exit:
0
Remediatemanual
note:
Review pending updates with `dnf check-update` and apply approved updates with `dnf update` on your change-controlled schedule.

Framework references

CIS

rhel9 1.2.2.1rhel8 1.2.2.1rhel10 1.2.2.1

STIG

V-257778 / RHEL-09-211015V-230222 / RHEL-08-010010

NIST 800-53

SI-2
#patching#updates#vulnerability-management