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

May 24 updates #376

Merged
merged 5 commits into from
Jun 17, 2024
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
2 changes: 1 addition & 1 deletion tasks/prelim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
changed_when: false
failed_when: false
check_mode: false
register: discovered_sudoers_filess
register: discovered_sudoers_files

- name: "PRELIM | AUDIT | Check authselect package versions"
tags:
Expand Down
14 changes: 3 additions & 11 deletions tasks/section_4/cis_4.3.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
regexp: '^([^#|{% if system_is_ec2 %}ec2-user{% endif %}].*)NOPASSWD(.*)'
replace: '\1PASSWD\2'
validate: '/usr/sbin/visudo -cf %s'
loop: "{{ discovered_sudoers_filess.stdout_lines }}"
loop: "{{ discovered_sudoers_files.stdout_lines }}"

- name: "4.3.5 | PATCH | Ensure re-authentication for privilege escalation is not disabled globally"
when:
Expand All @@ -82,7 +82,7 @@
regexp: '^([^#].*)!authenticate(.*)'
replace: '\1authenticate\2'
validate: '/usr/sbin/visudo -cf %s'
loop: "{{ discovered_sudoers_filess.stdout_lines }}"
loop: "{{ discovered_sudoers_files.stdout_lines }}"

- name: "4.3.6 | PATCH | Ensure sudo authentication timeout is configured correctly"
when:
Expand Down Expand Up @@ -135,17 +135,9 @@
ansible.builtin.group:
name: "{{ rhel8cis_sugroup }}"
state: present
register: discovered_sugroup

- name: "4.3.7 | PATCH | Ensure access to the su command is restricted | remove users from group"
ansible.builtin.lineinfile:
path: /etc/group
regexp: '^{{ discovered_sugroup }}(:.:.*:).*$'
line: '{{ discovered_sugroup }}\g<1>'
backrefs: true

- name: "4.3.7 | PATCH | Ensure access to the su command is restricted | Setting pam_wheel to use_uid"
ansible.builtin.lineinfile:
path: /etc/pam.d/su
regexp: '^(#)?auth\s+required\s+pam_wheel\.so'
line: 'auth required pam_wheel.so use_uid group={{ discovered_sugroup }}'
line: 'auth required pam_wheel.so use_uid group={{ rhel8cis_sugroup }}'
3 changes: 2 additions & 1 deletion tasks/section_4/cis_4.4.3.2.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@
block:
- name: "4.4.3.2.6 | PATCH | Ensure password dictionary check is enabled | pwquality.conf"
ansible.builtin.lineinfile:
line: 'dictcheck = 1'
path: /etc/security/pwquality.conf
state: absent
regexp: '^(#|)\s*dictcheck\s*=\s*\d'
state: present

- name: "4.4.3.2.6 | PATCH | Ensure password dictionary check is enabled | pam_files"
when: not rhel8cis_allow_authselect_updates
Expand Down
9 changes: 5 additions & 4 deletions tasks/section_4/cis_4.4.3.4.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
- not rhel8cis_allow_authselect_updates
ansible.builtin.replace:
path: "/etc/pam.d/{{ item }}-auth"
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)nullok(.*$)
replace: \1\2\3
#regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)nullok(.*$)
regexp: nullok
replace: ''
loop:
- password
- system
Expand Down Expand Up @@ -107,8 +108,8 @@
- discovered_hash_state | length > 0
ansible.builtin.replace:
path: "/etc/pam.d/{{ item }}-auth"
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)(sha512|yescrypt)\s*=\s*\d+(.*$)
replace: \1\2\4 {{ discovered_hash_state.stdout }}
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)(sha512|yescrypt)(.*$)
replace: \1\2\4 {{ rhel8cis_pam_pwhash }}
loop:
- password
- system
Expand Down
12 changes: 6 additions & 6 deletions tasks/section_5/cis_5.3.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
path: /etc/aide.conf
marker: "# {mark} Audit tools - CIS benchmark - Ansible-lockdown"
block: |
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
validate: aide -D --config %s
2 changes: 1 addition & 1 deletion templates/etc/systemd/system/tmp.mount.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ After=swap.target
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,{% if rhel8cis_rule_1_1_2_2 %}nodev,{% endif %}{% if rhel8cis_rule_1_1_2_4 %}nosuid,{% endif %}{% if rhel8cis_rule_1_1_2_3 %}noexec{% endif %}
Options=mode=1777,strictatime,{% if rhel8cis_rule_1_1_2_1_2 %}nodev,{% endif %}{% if rhel8cis_rule_1_1_2_1_3 %}nosuid,{% endif %}{% if rhel8cis_rule_1_1_2_1_4 %}noexec{% endif %}

# Make 'systemctl enable tmp.mount' work:
[Install]
Expand Down