Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Audit related rules in RHEL 10 #12359

Merged
merged 21 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
667048a
modify the OVAL check which checks if auditctl is used to load rules
vojtapolasek Sep 2, 2024
be0890d
modify the check which checks if augenrules is used
vojtapolasek Sep 3, 2024
afc8792
add new macro file for test scenarios
vojtapolasek Sep 4, 2024
a3d68f8
align tests for audit_rules_privileged_commands template
vojtapolasek Sep 3, 2024
3c7c1c9
modify template of audit_login_events
vojtapolasek Sep 3, 2024
7d20a05
align rule audit_rules_login_events_faillock
vojtapolasek Sep 4, 2024
359693b
align template audit_rules_usergroup_modification
vojtapolasek Sep 3, 2024
000c061
align template audit_rules_watch
vojtapolasek Sep 3, 2024
db5c5f8
align test scenarios for directory_access_var_log_audit
vojtapolasek Sep 3, 2024
9de6099
align test scenarios for audit_rules_unsuccessful_file_modification
vojtapolasek Sep 3, 2024
1beb448
align rule audit_rules_kernel_module_loading
vojtapolasek Sep 3, 2024
401161e
align rule audit_rules_privileged_commands
vojtapolasek Sep 3, 2024
cd37466
align test scenarios for rule audit_rules_privileged_commands_modprobe
vojtapolasek Sep 4, 2024
7cf4583
align test scenarios of audit_rules_immutable
vojtapolasek Sep 4, 2024
56a28f3
align test scenarios for rule audit_rules_mac_modification
vojtapolasek Sep 4, 2024
5537d58
align test scenarios of audit_rules_mac_modification_usr_share
vojtapolasek Sep 4, 2024
b880544
align test scenarios of audit_rules_networkconfig_modification
vojtapolasek Sep 4, 2024
e3dd9be
align test scenarios of audit_rules_session_events
vojtapolasek Sep 4, 2024
9733067
align test scenarios for audit_rules_usergroup_modification
vojtapolasek Sep 4, 2024
6368458
remove setup of augenrules-like environment in audit_rules_privileged…
vojtapolasek Sep 4, 2024
daeb8e7
align mentions of auditd.service within the auditing group description
vojtapolasek Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading