Puppet Class: cis_security_hardening::rules::auditd_actions

Defined in:
manifests/rules/auditd_actions.pp

Summary

Ensure system administrator actions (sudolog) are collected

Overview

Monitor the sudo log file. If the system has been properly configured to disable the use of the su command and force all administrators to have to log in first and then use sudo to execute privileged commands, then all administrator commands will be logged to /var/log/sudo.log. Any time a command is executed, an audit event will be triggered as the /var/log/sudo.log file will be opened for write and the executed administration command will be written to the log.

Rationale: Changes in /var/log/sudo.log indicate that an administrator has executed a command or the log file itself has been tampered with. Administrators will want to correlate the events written to the audit trail with the records written to /var/log/sudo.log to verify if unauthorized commands have been executed.

Examples:

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

Parameters:

  • enforce (Boolean) (defaults to: false)

    Sets rule enforcement. If set to true, code will be exeuted to bring the system into a compliant state.



24
25
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'manifests/rules/auditd_actions.pp', line 24

class cis_security_hardening::rules::auditd_actions (
  Boolean $enforce                 = false,
) {
  if $enforce {
    $uid = fact('cis_security_hardening.auditd.uid_min') ? {
      undef => '1000',
      default => fact('cis_security_hardening.auditd.uid_min'),
    }
    case $facts['os']['name'].downcase() {
      'redhat', 'centos', 'almalinux', 'rocky': {
        if $facts['os']['release']['major'] >= '8' {
          concat::fragment { 'watch admin actions rule 1':
            order   => 21,
            target  => $cis_security_hardening::rules::auditd_init::rules_file,
            content => '-w /var/log/sudo.log -p wa -k actions',
          }
        } else {
          if  $facts['os']['architecture'] == 'x86_64' or $facts['os']['architecture'] == 'amd64' {
            concat::fragment { 'watch admin actions rule 1':
              order   => 21,
              target  => $cis_security_hardening::rules::auditd_init::rules_file,
              content => "-a exit,always -F arch=b64 -C euid!=uid -F euid=0 -F auid>=${uid} -F auid!=4294967295 -S execve -k actions",
            }
          }

          concat::fragment { 'watch admin actions rule 2':
            order   => 22,
            target  => $cis_security_hardening::rules::auditd_init::rules_file,
            content => "-a always,exit -F arch=b32 -S execve -C uid!=euid -F euid=0 -F auid>=${uid} -F auid!=-1 -F key=actions",
          }
        }
      }
      'ubuntu': {
        if $facts['os']['release']['major'] >= '20' {
          concat::fragment { 'watch admin actions rule 1':
            order   => 21,
            target  => $cis_security_hardening::rules::auditd_init::rules_file,
            content => '-w /var/log/sudo.log -p wa -k sudo_log_file',
          }
        } else {
          if  $facts['os']['architecture'] == 'x86_64' or $facts['os']['architecture'] == 'amd64' {
            concat::fragment { 'watch admin actions rule 1':
              order   => 21,
              target  => $cis_security_hardening::rules::auditd_init::rules_file,
              content => "-a exit,always -F arch=b64 -C euid!=uid -F euid=0 -F auid>=${uid} -F auid!=4294967295 -S execve -k actions",
            }
          }

          concat::fragment { 'watch admin actions rule 2':
            order   => 22,
            target  => $cis_security_hardening::rules::auditd_init::rules_file,
            content => "-a always,exit -F arch=b32 -S execve -C uid!=euid -F euid=0 -F auid>=${uid} -F auid!=-1 -F key=actions",
          }
        }
      }
      'debian', 'suse': {
        concat::fragment { 'watch admin actions rule 1':
          order   => 21,
          target  => $cis_security_hardening::rules::auditd_init::rules_file,
          content => '-w /var/log/sudo.log -p wa -k actions',
        }
      }
      default: {
        # nothing to do yet
      }
    }
  }
}