Information
Monitor changes to file permissions, attributes, ownership and group. The parameters in this section track changes for system calls that affect file permissions and attributes. The following commands and system calls effect the permissions, ownership and various attributes of files.
- chown : changes the user and/or group ownership of each given file
- fchown : changes the ownership of the file referred to by the open file descriptor
- fchownat : change ownership of a file relative to a directory file descriptor
- lchown : change the owner and group of a file
In all cases, an audit record will only be written for non-system user ids and will ignore Daemon events. All audit records will be tagged with the identifier "perm_mod."
Monitoring for changes in file attributes could alert a system administrator to activity that could indicate intruder activity or policy violation.
Solution
- Add the audit rule(s) for the chown, fchown, lchown, and fchownat 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 chown fchown lchown fchownat; 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=perm_mod"
done >> /etc/audit/rules.d/50-perm_mod.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