Puppet Class: cis_security_hardening::rules::nfs_utils

Defined in:
manifests/rules/nfs_utils.pp

Summary

Ensure nfs-utils is not installed or the nfs-server service is masked

Overview

The Network File System (NFS) is one of the first and most widely distributed file systems in the UNIX environment. It provides the ability for systems to mount file systems of other servers through the network.

Rationale: If the system does not require network shares, it is recommended that the nfs-utils package be removed to reduce the attack surface of the system. Note: many of the libvirt packages used by Enterprise Linux virtualization are dependent on the nfs-utils package. If the nfs-package is required as a dependency, the nfs-server should be disabled and masked to reduce the attack surface of the system.

Examples:

class { 'cis_security_hardening::rules::nfs_utils':
    enforce => true,
}

Parameters:

  • enforce (Boolean) (defaults to: false)

    Enforce the rule

  • uninstall (Boolean) (defaults to: true)

    Switch to select if package shoul be uninstalled or service should be masked



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'manifests/rules/nfs_utils.pp', line 26

class cis_security_hardening::rules::nfs_utils (
  Boolean $enforce = false,
  Boolean $uninstall = true,
) {
  if $enforce {
    if $uninstall {
      case $facts['os']['name'].downcase() {
        'sles': {
          ensure_packages(['nfs-utils', 'nfs-kernel-server'], {
              ensure => absent,
          })
        }
        'rocky', 'almalinux': {
          ensure_packages(['nfs-utils'], {
              ensure => absent,
          })
        }
        default: {
          ensure_resource('service', 'nfs-server', {
              ensure => stopped,
              enable => false,
          })
          ensure_packages(['nfs-utils'], {
              ensure => absent,
          })
        }
      }
    } else {
      ensure_resource('service', 'nfs-server', {
          ensure => stopped,
          enable => false,
      })
      exec { 'mask nfs-server service':
        command => 'systemctl --now mask nfs-server',
        path    => ['/usr/bin', '/bin'],
        unless  => 'test "$(systemctl is-enabled nfs-server)" = "masked"',
      }
    }
  }
}