99 lines
3.6 KiB
YAML
99 lines
3.6 KiB
YAML
---
|
|
# CIS 4.1.x / DISA-STIG-aehnliche Audit-Regeln. Ueber die bereits vorhandene
|
|
# Ueberwachung des Jumphost-Datenverzeichnisses hinaus wird hier ein
|
|
# Standard-Ruleset fuer sicherheitsrelevante OS-Ereignisse ergaenzt:
|
|
# Identitaets-/Rechteaenderungen, privilegierte Kommandos, Zeit-/
|
|
# Netzwerkkonfigurationsaenderungen, Login-Ereignisse, Modulladen.
|
|
|
|
- name: auditd + audispd-plugins installieren
|
|
ansible.builtin.apt:
|
|
name:
|
|
- auditd
|
|
- audispd-plugins
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Bestehende auditd-Regeln fuer das Jumphost-Datenverzeichnis
|
|
ansible.builtin.copy:
|
|
dest: /etc/audit/rules.d/10-jumphost-app.rules
|
|
owner: root
|
|
group: root
|
|
mode: "0640"
|
|
content: |
|
|
-w {{ jumphost_data_dir }}/jumphost.db -p wa -k jumphost_db
|
|
-w {{ jumphost_home }} -p wa -k jumphost_app_files
|
|
-w /etc/jumphost -p wa -k jumphost_config
|
|
notify: restart auditd
|
|
|
|
- name: Erweiterte CIS/STIG-Audit-Regeln fuer das Basissystem
|
|
ansible.builtin.copy:
|
|
dest: /etc/audit/rules.d/20-cis-baseline.rules
|
|
owner: root
|
|
group: root
|
|
mode: "0640"
|
|
content: |
|
|
# Identitaets-/Rechteaenderungen (CIS 4.1.4)
|
|
-w /etc/passwd -p wa -k identity
|
|
-w /etc/group -p wa -k identity
|
|
-w /etc/shadow -p wa -k identity
|
|
-w /etc/gshadow -p wa -k identity
|
|
-w /etc/sudoers -p wa -k identity
|
|
-w /etc/sudoers.d/ -p wa -k identity
|
|
|
|
# Sudo-Nutzung protokollieren (ergaenzt Defaults logfile in
|
|
# sudo_logging.yml um eine auditd-seitige, manipulationsresistentere Spur)
|
|
-a always,exit -F arch=b64 -S execve -F euid=0 -F auid!=0 -F auid!=-1 -k privileged_sudo
|
|
|
|
# Zeitaenderungen (CIS 4.1.3)
|
|
-a always,exit -F arch=b64 -S adjtimex,settimeofday,clock_settime -k time_change
|
|
-w /etc/localtime -p wa -k time_change
|
|
|
|
# Netzwerkkonfiguration (CIS 4.1.7)
|
|
-w /etc/hosts -p wa -k network_config
|
|
-w /etc/network/ -p wa -k network_config
|
|
-w /etc/nftables.conf -p wa -k network_config
|
|
|
|
# Login/Logout-Ereignisse (CIS 4.1.5)
|
|
-w /var/log/faillog -p wa -k logins
|
|
-w /var/log/lastlog -p wa -k logins
|
|
-w /var/run/utmp -p wa -k session
|
|
-w /var/log/wtmp -p wa -k session
|
|
-w /var/log/btmp -p wa -k session
|
|
|
|
# Kernel-Modul-Laden/-Entladen (CIS 4.1.13)
|
|
-a always,exit -F arch=b64 -S init_module,delete_module -k kernel_modules
|
|
|
|
# SSH-Konfigurationsaenderungen des Jumphosts selbst
|
|
-w /etc/ssh/sshd_config -p wa -k sshd_config
|
|
-w /etc/ssh/sshd_config.d/ -p wa -k sshd_config
|
|
|
|
# Loeschungen durch Nutzer (CIS 4.1.14, exemplarisch fuer den eigenen UID-Bereich)
|
|
-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F auid>=1000 -F auid!=-1 -k file_deletion
|
|
notify: restart auditd
|
|
|
|
- name: auditd-Regeln als unveraenderlich markieren (STIG, optional)
|
|
ansible.builtin.copy:
|
|
dest: /etc/audit/rules.d/99-immutable.rules
|
|
owner: root
|
|
group: root
|
|
mode: "0640"
|
|
content: |
|
|
# ACHTUNG: nach Aktivierung sind Aenderungen an den Audit-Regeln erst
|
|
# nach einem Reboot wieder moeglich (auditctl -e 2 sperrt bis Neustart).
|
|
-e 2
|
|
when: os_hardening_auditd_immutable
|
|
notify: restart auditd
|
|
|
|
- name: auditd-Log-Rotation auf "keep_logs" setzen statt Ueberschreiben (CIS 4.1.2.3)
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/audit/auditd.conf
|
|
regexp: '^max_log_file_action\s*='
|
|
line: "max_log_file_action = keep_logs"
|
|
notify: restart auditd
|
|
|
|
- name: auditd bei vollem Log-Speicher anhalten statt Ereignisse zu verwerfen (CIS 4.1.2.4)
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/audit/auditd.conf
|
|
regexp: '^space_left_action\s*='
|
|
line: "space_left_action = email"
|