Skip to content

Commit

Permalink
Merge pull request #12359 from vojtapolasek/fix_audit_rhel10
Browse files Browse the repository at this point in the history
Fix Audit related rules in RHEL 10
  • Loading branch information
ggbecker authored Sep 10, 2024
2 parents ad62fc1 + daeb8e7 commit d80b25c
Show file tree
Hide file tree
Showing 87 changed files with 170 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# packages = audit
# remediation = bash

# Use auditctl, on RHEL7, default is to use augenrules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/rules.d/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# packages = audit
# remediation = bash

# Use auditctl, on RHEL7, default is to use augenrules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/rules.d/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
# packages = audit
# remediation = bash

# Use auditctl, on RHEL7, default is to use augenrules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/rules.d/*

# Delete everything that is not between "one per line" and "multiple per arg"
sed '/# one per line/,/# multiple per arg/!d' test_audit.rules > /etc/audit/audit.rules

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# packages = audit
# remediation = bash

rm -f /etc/audit/rules.d/*

# Deletes everything up do "one per line"
# Then deletes everything from "one per arg" until end of file
sed '/# one per line/,/# multiple per arg/d;/# one per arg/,$d' test_audit.rules > /etc/audit/rules.d/audit.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# packages = audit
# remediation = bash

rm -f /etc/audit/rules.d/*

# Delete everything that is between "one per line" and "one per arg"
sed '/# one per line/,/# one per arg/d' test_audit.rules > /etc/audit/rules.d/audit.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# packages = audit
# remediation = bash

rm -f /etc/audit/rules.d/*

# Delete everything that is not between "one per line" and "multiple per arg"
sed '/# one per line/,/# multiple per arg/!d' test_audit.rules > /etc/audit/rules.d/audit.rules
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
# packages = audit


# Use auditctl, on RHEL7, default is to use augenrules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/rules.d/*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
# packages = audit


# Use auditctl, on RHEL7, default is to use augenrules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/rules.d/*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
# packages = audit


# Use auditctl, on RHEL7, default is to use augenrules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/rules.d/*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
# packages = audit


# Use auditctl, on RHEL7, default is to use augenrules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/rules.d/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# packages = audit
# platform = multi_platform_all

{{{ setup_auditctl_environment() }}}

path="/var/log/faillock"
. $SHARED/audit_rules_login_events/auditctl_correct.pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# platform = Red Hat Enterprise Linux 8, Red Hat Enterprise Linux 9
# profiles = xccdf_org.ssgproject.content_profile_cis

{{{ setup_auditctl_environment() }}}

path="/var/run/faillock"
. $SHARED/audit_rules_login_events/auditctl_correct.pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# packages = audit
# platform = multi_platform_all

{{{ setup_auditctl_environment() }}}

path="/var/log/faillock"
. $SHARED/audit_rules_login_events/auditctl_correct_extra_permission.pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# platform = Red Hat Enterprise Linux 8, Red Hat Enterprise Linux 9
# profiles = xccdf_org.ssgproject.content_profile_cis

{{{ setup_auditctl_environment() }}}

path="/var/run/faillock"
. $SHARED/audit_rules_login_events/auditctl_correct_extra_permission.pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# packages = audit
# platform = multi_platform_all

{{{ setup_auditctl_environment() }}}

path="/var/log/faillock"
. $SHARED/audit_rules_login_events/auditctl_correct_without_key.pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# platform = Red Hat Enterprise Linux 8, Red Hat Enterprise Linux 9
# profiles = xccdf_org.ssgproject.content_profile_cis

{{{ setup_auditctl_environment() }}}

path="/var/run/faillock"
. $SHARED/audit_rules_login_events/auditctl_correct_without_key.pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# packages = audit
# platform = multi_platform_all

{{{ setup_auditctl_environment() }}}

. $SHARED/audit_rules_login_events/auditctl_remove_all_rules.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# platform = Red Hat Enterprise Linux 8, Red Hat Enterprise Linux 9
# profiles = xccdf_org.ssgproject.content_profile_cis

{{{ setup_auditctl_environment() }}}

path="/var/run/faillock"
. $SHARED/audit_rules_login_events/auditctl_remove_all_rules.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# packages = audit
# platform = multi_platform_all

{{{ setup_auditctl_environment() }}}

path="/var/log/faillock"
. $SHARED/audit_rules_login_events/auditctl_wrong_rule.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# platform = Red Hat Enterprise Linux 8, Red Hat Enterprise Linux 9
# profiles = xccdf_org.ssgproject.content_profile_cis

{{{ setup_auditctl_environment() }}}

path="/var/run/faillock"
. $SHARED/audit_rules_login_events/auditctl_wrong_rule.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# packages = audit
# platform = multi_platform_all

{{{ setup_auditctl_environment() }}}

path="/var/log/faillock"
. $SHARED/audit_rules_login_events/auditctl_wrong_rule_without_key.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# platform = Red Hat Enterprise Linux 8, Red Hat Enterprise Linux 9
# profiles = xccdf_org.ssgproject.content_profile_cis

{{{ setup_auditctl_environment() }}}

path="/var/run/faillock"
. $SHARED/audit_rules_login_events/auditctl_wrong_rule_without_key.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# packages = audit
# platform = multi_platform_fedora,multi_platform_rhel,Oracle Linux 7,Oracle Linux 8

sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# packages = audit
# platform = multi_platform_fedora,multi_platform_rhel,Oracle Linux 7,Oracle Linux 8

{{{ setup_auditctl_environment() }}}

./generate_privileged_commands_rule.sh {{{ uid_min }}} privileged /etc/audit/audit.rules
sed -i '/newgrp/d' /etc/audit/audit.rules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# packages = audit
# platform = multi_platform_fedora,multi_platform_rhel,Oracle Linux 7,Oracle Linux 8

{{{ setup_auditctl_environment() }}}

echo "-a always,exit -F path=/usr/bin/sudo -F perm=x -F auid>={{{ uid_min }}} -F auid!=unset -k privileged" >> /etc/audit/audit.rules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# packages = audit
# platform = multi_platform_fedora,multi_platform_rhel,Oracle Linux 7,Oracle Linux 8

{{{ setup_auditctl_environment() }}}

./generate_privileged_commands_rule.sh {{{ uid_min }}} privileged /etc/audit/audit.rules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# packages = audit
# platform = multi_platform_fedora,multi_platform_rhel,Oracle Linux 7,Oracle Linux 8

{{{ setup_auditctl_environment() }}}

./generate_privileged_commands_rule.sh {{{ uid_min }}} privileged /etc/audit/audit.rules
sed -i -E 's/^(.*path=[[:graph:]]+) -F perm=x(.*$)/\1\2/' /etc/audit/audit.rules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
# packages = audit

{{{ setup_auditctl_environment() }}}

echo "-w /sbin/modprobe -p x -k modules" >> /etc/audit/audit.rules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# packages = audit

{{{ setup_auditctl_environment() }}}

echo "-w /sbin/modprobe -p x" >> /etc/audit/audit.rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
# packages = audit

{{{ setup_auditctl_environment() }}}

rm -f /etc/audit/audit.rules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
# packages = audit

{{{ setup_auditctl_environment() }}}

echo "-w /sbin/something -p x -k modules" >> /etc/audit/audit.rules
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-e 2" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "some value" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-e 1" > /etc/audit/audit.rules

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-w /etc/selinux/ -p wa -k MAC-policy" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-w /etc/selinux/ -p wa" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "some value" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-w /etc/passwd -p w -k MAC-policy" > /etc/audit/audit.rules

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-w /usr/share/selinux/ -p wa -k MAC-policy" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-w /usr/share/selinux/ -p wa" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "some value" > /etc/audit/audit.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

echo "-w /etc/passwd -p w -k MAC-policy" > /etc/audit/audit.rules

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}


rm -rf /etc/audit/rules.d/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}


rm -rf /etc/audit/rules.d/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# packages = audit

# use auditctl
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/auditctl%" /usr/lib/systemd/system/auditd.service
{{{ setup_auditctl_environment() }}}

rm -rf /etc/audit/rules.d/*
rm /etc/audit/audit.rules
Expand Down
Loading

0 comments on commit d80b25c

Please sign in to comment.