Configure AIDE to Send Its Reports to Syslog

Description

AIDE writes the report of every check to each destination that a report_url line of /etc/aide.conf names. Make sure that at least one of them is the system log, for example:

report_url=syslog:LOG_LOCAL0

Other destinations, such as report_url=file:/var/log/aide/aide.log, may stay.

Rationale

A report in the system log reaches the log collection and the remote log servers of the site, where an alert on a changed file is raised and kept out of reach of whoever changed it.

Remediation

Shell script

The following script can be run on the host to remediate the issue.

#!/bin/bash

# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel-core && { rpm --quiet -q aide; }; then

aide_conf="/etc/aide.conf"
if ! grep -qE '^[[:space:]]*report_url[[:space:]]*=[[:space:]]*syslog:' "$aide_conf"; then
    if grep -qE '^[[:space:]]*report_url[[:space:]]*=' "$aide_conf"; then
        sed -i '0,/^[[:space:]]*report_url[[:space:]]*=.*/s//&\nreport_url=syslog:LOG_LOCAL0/' "$aide_conf"
    else
        echo "report_url=syslog:LOG_LOCAL0" >> "$aide_conf"
    fi
fi

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi

Ansible playbook

The following playbook can be run with Ansible to remediate the issue.

- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - CCE-88331-4
  - aide_report_url_syslog
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - restrict_strategy

- name: Configure AIDE to Send Its Reports to Syslog - Find a syslog report_url
  ansible.builtin.lineinfile:
    path: /etc/aide.conf
    regexp: '^\s*report_url\s*=\s*syslog:'
    state: absent
  check_mode: true
  changed_when: false
  register: aide_report_url_syslog
  when:
  - '"kernel-core" in ansible_facts.packages'
  - '"aide" in ansible_facts.packages'
  tags:
  - CCE-88331-4
  - aide_report_url_syslog
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - restrict_strategy

- name: Configure AIDE to Send Its Reports to Syslog - Add a syslog report_url
  ansible.builtin.lineinfile:
    path: /etc/aide.conf
    line: report_url=syslog:LOG_LOCAL0
    insertafter: ^\s*report_url\s*=
  when:
  - '"kernel-core" in ansible_facts.packages'
  - '"aide" in ansible_facts.packages'
  - aide_report_url_syslog.found == 0
  tags:
  - CCE-88331-4
  - aide_report_url_syslog
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - restrict_strategy