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

Adjust two filesystem permission rules to 600 #12737

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -22,7 +22,7 @@
path: "{{ item }}"
create: True
line: "-e 2"
mode: o-rwx
mode: g-rwx,o-rwx
loop:
- "/etc/audit/audit.rules"
- "/etc/audit/rules.d/immutable.rules"
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ do
echo '# Reboot is required to change audit rules once this setting is applied' >> $AUDIT_FILE
echo '-e 2' >> $AUDIT_FILE
chmod o-rwx $AUDIT_FILE
chmod g-rwx $AUDIT_FILE
done
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
path: '/etc/audit/audit.rules'
line: '--loginuid-immutable'
regexp: '^\s*--loginuid-immutable\s*$'
mode: '0600'
create: true
when: auditctl_used is defined and auditctl_used.matched >= 1

Expand All @@ -33,6 +34,7 @@
path: '/etc/audit/rules.d/immutable.rules'
line: '--loginuid-immutable'
regexp: '^\s*--loginuid-immutable\s*$'
mode: '0600'
create: true
when: immutable_found_in_rules_d is defined and immutable_found_in_rules_d.matched == 0
when: auditctl_used is defined and auditctl_used.matched == 0
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
path: /etc/audit/rules.d/privileged.rules
line: "{{ item.rule }}"
regexp: "{{ item.regex }}"
mode: "0600"
create: yes
when:
- ('"auditd.service" in ansible_facts.services' or
- ('"auditd.service" in ansible_facts.services' or
'"augenrules.service" in ansible_facts.services')
register: augenrules_audit_rules_privilege_function_update_result
with_items: "{{ suid_audit_rules }}"
Expand All @@ -57,7 +58,7 @@
regexp: "{{ item.regex }}"
create: yes
when:
- ('"auditd.service" in ansible_facts.services' or
- ('"auditd.service" in ansible_facts.services' or
'"augenrules.service" in ansible_facts.services')
register: auditctl_audit_rules_privilege_function_update_result
with_items: "{{ suid_audit_rules }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
lineinfile:
path: "{{ item }}"
create: True
mode: "0600"
line: "-f {{ var_audit_failure_mode }}"
loop:
- "/etc/audit/audit.rules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ documentation_complete: true
title: 'Verify Permissions on /etc/audit/rules.d/*.rules'

description: |-
{{{ describe_file_permissions(file="/etc/audit/rules.d/*.rules", perms="0640") }}}
{{{ describe_file_permissions(file="/etc/audit/rules.d/*.rules", perms="0600") }}}


rationale: |-
Expand Down Expand Up @@ -32,20 +32,20 @@ references:
stigid@ubuntu2004: UBTU-20-010133
stigid@ubuntu2204: UBTU-22-653065

ocil_clause: '{{{ ocil_clause_file_permissions(file="/etc/audit/rules.d/*.rules", perms="-rw-r-----") }}}'
ocil_clause: '{{{ ocil_clause_file_permissions(file="/etc/audit/rules.d/*.rules", perms="-rw-------") }}}'

ocil: |-
{{{ ocil_file_permissions(file="/etc/audit/rules.d/*.rules", perms="-rw-r-----") }}}
{{{ ocil_file_permissions(file="/etc/audit/rules.d/*.rules", perms="-rw-------") }}}

fixtext: |-
{{{ describe_file_permissions(file="/etc/audit/rules.d/*.rules", perms="0640") }}}
{{{ describe_file_permissions(file="/etc/audit/rules.d/*.rules", perms="0600") }}}

srg_requirement: '{{{ srg_requirement_file_permission(file="/etc/audit/rules.d/*.rules", mode="0640") }}}'
srg_requirement: '{{{ srg_requirement_file_permission(file="/etc/audit/rules.d/*.rules", mode="0600") }}}'

template:
name: file_permissions
vars:
filepath: /etc/audit/rules.d/
file_regex: ^.*rules$
allow_stricter_permissions: "true"
filemode: '0640'
filemode: '0600'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ documentation_complete: true
title: 'Verify Permissions on /var/log/messages File'

description: |-
{{{ describe_file_permissions(file="/var/log/messages", perms="0640") }}}
{{{ describe_file_permissions(file="/var/log/messages", perms="0600") }}}

rationale: |-
The <tt>/var/log/messages</tt> file contains logs of error messages in
Expand All @@ -22,18 +22,18 @@ references:
stigid@ol8: OL08-00-010210
stigid@rhel8: RHEL-08-010210

ocil_clause: '{{{ ocil_clause_file_permissions(file="/var/log/messages", perms="-rw-r-----") }}}'
ocil_clause: '{{{ ocil_clause_file_permissions(file="/var/log/messages", perms="-rw-------") }}}'

ocil: |-
{{{ ocil_file_permissions(file="/var/log/messages", perms="-rw-r-----") }}}
{{{ ocil_file_permissions(file="/var/log/messages", perms="-rw-------") }}}

template:
name: file_permissions
vars:
filepath: /var/log/messages
filemode: '0640'
filemode: '0600'

fixtext: |-
{{{ fixtext_file_permissions("/var/log/messages", "0640") | indent(4) }}}

srg_requirement: '{{{ srg_requirement_file_permission("/var/log/messages", "0640") }}}'
srg_requirement: '{{{ srg_requirement_file_permission("/var/log/messages", "0600") }}}'
8 changes: 4 additions & 4 deletions shared/macros/10-ansible.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ The following macro remediates one audit watch rule in :code:`/etc/audit/rules.d
path: "{{ all_files[0] }}"
line: "-w {{{ path }}} -p {{{ permissions }}} -k {{{ key }}}"
create: yes
mode: '0640'
mode: '0600'
when: find_existing_watch_rules_d.matched is defined and find_existing_watch_rules_d.matched == 0
{{%- endmacro %}}

Expand Down Expand Up @@ -484,7 +484,7 @@ The following macro remediates one audit watch rule in :code:`/etc/audit/audit.r
state: present
dest: /etc/audit/audit.rules
create: yes
mode: '0640'
mode: '0600'
when: find_existing_watch_audit_rules.matched is defined and find_existing_watch_audit_rules.matched == 0
{{%- endmacro %}}

Expand Down Expand Up @@ -577,7 +577,7 @@ The macro requires following parameters:
path: '{{ audit_file }}'
line: "{{{ action_arch_filters }}}{{{ syscall_flag }}}{{ syscalls | join(',') }}{{{ other_filters }}}{{{ auid_filters}}} -F key={{{ key }}}"
create: true
mode: o-rwx
mode: g-rwx,o-rwx
state: present
when: syscalls_found | length == 0
{{%- endmacro %}}
Expand Down Expand Up @@ -654,7 +654,7 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
path: '{{ audit_file }}'
line: "{{{ action_arch_filters }}}{{{ syscall_flag }}}{{ syscalls | join(',') }}{{{ other_filters }}}{{{ auid_filters}}} -F key={{{ key }}}"
create: true
mode: o-rwx
mode: g-rwx,o-rwx
state: present
when: syscalls_found | length == 0
{{%- endmacro %}}
Expand Down
4 changes: 2 additions & 2 deletions shared/macros/10-bash.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ then
if [ ! -e "$key_rule_file" ]
then
touch "$key_rule_file"
chmod 0640 "$key_rule_file"
chmod 0600 "$key_rule_file"
fi
files_to_inspect+=("$key_rule_file")
fi
Expand Down Expand Up @@ -1748,7 +1748,7 @@ then
if [ ! -e "$file_to_inspect" ]
then
touch "$file_to_inspect"
chmod 0640 "$file_to_inspect"
chmod 0600 "$file_to_inspect"
fi
fi
{{%- endif %}}
Expand Down
6 changes: 3 additions & 3 deletions shared/templates/audit_file_contents/ansible.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)
}}}

- name: Remove any permissions from other group
file:
- name: {{{ rule_title }}} - Remove any permissions from group and other
ansible.builtin.file:
path: {{{ FILEPATH }}}
mode: o-rwx
mode: g-rwx,o-rwx
Loading