6.2.3.25 Ensure rename file deletion events by users are collected

Information

Monitor the use of system calls associated with the deletion or renaming of files and file attributes. This configuration statement sets up monitoring for:

- rename : rename a file
- renameat : rename a file attribute
- renameat2 : rename a file relative to directory file descriptors
system calls and tags them with the identifier "delete".

Monitoring these calls from non-privileged users could provide a system administrator with evidence that inappropriate removal of files and file attributes associated with protected files is occurring. While this audit option will look at all events, system administrators will want to look for specific privileged files that are being deleted or altered.

Solution

- Add the audit rule(s) for the rename, renameat, and renameat2 system calls. The procedure adds a rule for each audit ABI (b64/b32) the running kernel supports and skips any unsupported ABI or system call, so augenrules --load does not error. Run:

#!/usr/bin/env bash

{
UID_MIN="$(awk '/^[[:space:]]*UID_MIN/{print $2}' /etc/login.defs)"
for ARCH in b64 b32; do
CALLS=""; for C in rename renameat renameat2; do ausyscall "$ARCH" "$C" >/dev/null 2>&1 && CALLS="${CALLS:+$CALLS,}$C"; done
[ -n "$CALLS" ] && printf '%s\n' "-a always,exit -F arch=$ARCH -S $CALLS -F auid>=$UID_MIN -F auid!=unset -F key=delete"
done >> /etc/audit/rules.d/50-delete.rules
}

- Merge and load the rules into active configuration:

# augenrules --load

- Check if reboot is required:

# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot required to load rules\n"; fi

See Also

https://workbench.cisecurity.org/benchmarks/27891