Bookmark this page

Lab: Recording System Events with Audit

Performance Checklist

In this lab, you will configure remote Audit logs, enable prepackaged STIG Audit rules, and audit TTY.

Outcomes

You should be able to:

  • Configure remote Audit logs.

  • Enable prepackaged Audit rules.

  • Enable auditing of TTY.

Verify that the workstation, servera, and serverb systems are started.

Log in to workstation as student using student as the password. On workstation, run lab audit-review setup to verify that the environment is ready.

[student@workstation ~]$ lab audit-review setup
  1. Configure the Audit service on servera to send audit messages to the Audit service on serverb.

    1. Log in to servera as student. No password is required.

      [student@workstation ~]$ ssh student@servera
      [student@servera ~]$ 
    2. Use the sudo -i command to switch identity to the root user. Use student as the password.

      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]# 
    3. Install the audispd-plugins package.

      [root@servera ~]# yum -y install audispd-plugins
    4. In the /etc/audisp/plugins.d/au-remote.conf file, set the value for the active variable to yes to enable remote logging.

      [root@servera ~]# vi /etc/audisp/plugins.d/au-remote.conf
      ...output omitted...
      active = yes
      ...output omitted...
    5. In the /etc/audisp/audisp-remote.conf file, set the remote_server variable to the IP address of the remote logging server in our environment, serverb.lab.example.com. Also, set the port to be used in the remote logging server, 60 by default.

      [root@servera ~]# vi /etc/audisp/audisp-remote.conf
      ...output omitted...
      remote_server = 172.25.250.11
      port = 60
      ...output omitted...
    6. Restart the auditd service to update its configuration. When done, log off from servera.

      [root@servera ~]# service auditd restart
      [root@servera ~]# logout
      [student@servera ~]$ logout
      [student@workstation ~]$ 
  2. Configure the Audit service on serverb to accept the audit messages from the Audit service on servera.

    1. Log in to serverb as student. No password is required.

      [student@workstation ~]$ ssh student@serverb
      [student@serverb ~]$ 
    2. Use the sudo -i command to switch identity to the root user. Use student as the password.

      [student@serverb ~]$ sudo -i
      [sudo] password for student: student
      [root@serverb ~]# 
    3. In the /etc/audit/auditd.conf file, uncomment the tcp_listen_port variable, and set its value to 60 so that the Audit service listens on TCP port 60.

      [root@serverb ~]# vi /etc/audit/auditd.conf
      ...output omitted...
      tcp_listen_port = 60
      ...output omitted...
    4. Open TCP port 60 to enable access to the Audit server.

      [root@serverb ~]# firewall-cmd --zone=public --add-port=60/tcp \
      > --permanent
      success
      [root@serverb ~]# firewall-cmd --reload
      success
    5. Restart the auditd service to update its configuration. When done, log off from serverb.

      [root@serverb ~]# service auditd restart
      [root@serverb ~]# logout
      [student@serverb ~]$ logout
      [student@workstation ~]$ 
  3. Log in to servera as student to verify that remote logging for Audit is working.

    1. Log in to servera as student. No password is required.

      [student@workstation ~]$ ssh student@servera
      [student@servera ~]$ 
    2. Use the sudo -i command to switch identity to the root user. Use student as the password. When done, log off from servera.

      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]# logout
      [student@servera ~]$ logout
      [student@workstation ~]$ 
    3. Log in to serverb as student. No password is required.

      [student@workstation ~]$ ssh student@serverb
      [student@serverb ~]$ 
    4. Use the sudo -i command to switch identity to the root user. Use student as the password.

      [student@serverb ~]$ sudo -i
      [sudo] password for student: student
      [root@serverb ~]# 
    5. Verify that new entry in the Audit log file exists for the message created on servera. When done, log off from serverb.

      [root@serverb ~]$ grep servera /var/log/audit/audit.log
      ...output omitted...
      node=servera.lab.example.com type=CRYPTO_KEY_USER msg=audit(1532102732.526:419): pid=2378 uid=0 auid=0 ses=28 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:67:d3:(...):87:9f direction=? spid=2378 suid=0  exe="/usr/sbin/sshd" hostname=servera.lab.example.com addr=? terminal=pts/1 res=success' UID="root" AUID="root" SUID="root"
      node=servera.lab.example.com type=CRYPTO_KEY_USER msg=audit(1532102732.526:420): pid=2378 uid=0 auid=0 ses=28 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:04:c7:(...):1d:12 direction=? spid=2378 suid=0  exe="/usr/sbin/sshd" hostname=servera.lab.example.com addr=? terminal=pts/1 res=success' UID="root" AUID="root" SUID="root"
      node=servera.lab.example.com type=CRYPTO_KEY_USER msg=audit(1532102732.526:421): pid=2378 uid=0 auid=0 ses=28 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:f6:bd:(...):12:82 direction=? spid=2378 suid=0  exe="/usr/sbin/sshd" hostname=servera.lab.example.com addr=? terminal=pts/1 res=success' UID="root" AUID="root" SUID="root"
      ...output omitted...
      [root@serverb ~]# logout
      [student@serverb ~]$ logout
      [student@workstation ~]$ 
  4. Enable the prepackaged STIG Audit rules on servera.

    1. Log in to servera as student. No password is required.

      [student@workstation ~]$ ssh student@servera
      [student@servera ~]$ 
    2. Use the sudo -i command to switch identity to the root user. Use student as the password.

      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]# 
    3. Copy the /usr/share/doc/audit-2.8.1/rules/30-stig.rules file with the STIG Audit rules into the /etc/audit/rules.d/ directory.

      [root@servera ~]# cp /usr/share/doc/audit-2.8.1/rules/30-stig.rules \
      > /etc/audit/rules.d/
    4. Load the STIG Audit rules with the augenrules --load command.

      [root@servera ~]# augenrules --load
      ...output omitted...
  5. On servera server create a new user called testuser to verify that the STIG Audit rules are working correctly.

    1. Verify the STIG Audit rules that use the identity key.

      [root@servera ~]# grep identity /etc/audit/rules.d/30-stig.rules
      ## Things that affect identity
      -w /etc/group -p wa -k identity
      -w /etc/passwd -p wa -k identity
      -w /etc/gshadow -p wa -k identity
      -w /etc/shadow -p wa -k identity
      -w /etc/security/opasswd -p wa -k identity
      
    2. Create a user called testuser to test the previous STIG Audit rules. The creation of a new user modifies the files associated with the rules that use the identity key, for example /etc/passwd, and triggers those STIG Audit rules.

      [root@servera ~]# useradd testuser
    3. Search the Audit log for the identity key to verify that the previous STIG Audit rules are active.

      [root@servera ~]# ausearch -k identity
      ...output omitted...
      time->Thu Jul 26 06:13:00 2018
      node=servera.lab.example.com type=CONFIG_CHANGE msg=audit(1532599980.002:3490): auid=0 ses=12 op=updated_rules path="/etc/passwd" key="identity" list=4 res=1
      ----
      ...output omitted...
      node=servera.lab.example.com type=SYSCALL msg=audit(1532599980.002:3491): arch=c000003e syscall=82 success=yes exit=0 a0=7fff50bdda70 a1=5596e239ece0 a2=7fff50bdd9e0 a3=5596e360bde0 items=5 ppid=1663 pid=1791 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=12 comm="useradd" exe="/usr/sbin/useradd" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="identity"
      ----
      time->Thu Jul 26 06:13:00 2018
      node=servera.lab.example.com type=CONFIG_CHANGE msg=audit(1532599980.004:3492): auid=0 ses=12 op=updated_rules path="/etc/shadow" key="identity" list=4 res=1
      ----
      ...output omitted...
      node=servera.lab.example.com type=SYSCALL msg=audit(1532599980.004:3493): arch=c000003e syscall=82 success=yes exit=0 a0=7fff50bdda70 a1=5596e239f620 a2=7fff50bdd9e0 a3=757431612f4d4875 items=5 ppid=1663 pid=1791 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=12 comm="useradd" exe="/usr/sbin/useradd" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="identity"
      ----
      time->Thu Jul 26 06:13:00 2018
      node=servera.lab.example.com type=CONFIG_CHANGE msg=audit(1532599980.005:3494): auid=0 ses=12 op=updated_rules path="/etc/group" key="identity" list=4 res=1
      ----
      ...output omitted...
      node=servera.lab.example.com type=SYSCALL msg=audit(1532599980.005:3495): arch=c000003e syscall=82 success=yes exit=0 a0=7fff50bdda70 a1=5596e239e840 a2=7fff50bdd9e0 a3=22 items=5 ppid=1663 pid=1791 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=12 comm="useradd" exe="/usr/sbin/useradd" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="identity"
      ----
      time->Thu Jul 26 06:13:00 2018
      node=servera.lab.example.com type=CONFIG_CHANGE msg=audit(1532599980.007:3496): auid=0 ses=12 op=updated_rules path="/etc/gshadow" key="identity" list=4 res=1
      ----
      ...output omitted...
      node=servera.lab.example.com type=SYSCALL msg=audit(1532599980.007:3497): arch=c000003e syscall=82 success=yes exit=0 a0=7fff50bdda70 a1=5596e239f180 a2=7fff50bdd9e0 a3=2 items=5 ppid=1663 pid=1791 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=12 comm="useradd" exe="/usr/sbin/useradd" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="identity"
      ----
      ...output omitted...
  6. Configure the pam_tty_audit PAM module to enable auditing of TTY for the student user on servera.

    1. Edit the /etc/pam.d/system-auth and the /etc/pam.d/password-auth files to enable the auditing of TTY for the student user with the pam_tty_audit PAM module.

      [root@servera ~]# vi /etc/pam.d/system-auth
      ...output omitted...
      session    required     pam_tty_audit.so disable=* enable=student
      [root@servera ~]# vi /etc/pam.d/password-auth
      ...output omitted...
      session    required     pam_tty_audit.so disable=* enable=student
    2. Log in to servera as student and run the ls /tmp command to test that auditing of TTY is working. When done, log in to servera as root.

      [student@workstation ~]$ ssh student@servera
      [student@servera ~]$ ls /tmp
      ...output omitted...
      [student@servera ~]$ logout
      [student@workstation ~]$ ssh root@servera

      Note

      Type these commands in full; do not use tab completion. This ensures that you correctly log the keystrokes for the ls /tmp and the logout commands.

    3. Verify the Audit logs for the previous commands with the aureport --tty command. When done, log off from servera.

      [root@servera ~]# aureport --tty
      
      TTY Report
      ===============================================
      # date time event auid term sess comm data
      ===============================================
      ...output omitted...
      2. 26/07/18 06:36:58 3750 1000 ? 22 bash "ls /tmp",<ret>,"logout",<ret>
      [root@servera ~]# logout
      [student@workstation ~]$ 

Evaluation

On workstation, run the lab audit-review grade command to confirm success of this exercise.

[student@workstation ~]$ lab audit-review grade

Cleanup

On workstation, run the lab audit-review cleanup script to clean up this exercise.

[student@workstation ~]$ lab audit-review cleanup

This concludes the lab.

Revision: rh415-7.5-813735c