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

Fixing issue https://github.com/ansible-lockdown/UBUNTU22-CIS/issues/180 #181

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
973ef95
Fixing issue https://code.siemens.com/infosec-pss-gov/security-crafte…
DianaMariaDDM Nov 22, 2023
0c06607
missing grub check fails when using sysctl
dderemiah Nov 30, 2023
c250141
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 4, 2023
dbb9528
Fixes a typo that keeps Chr0ny from working
dderemiah Dec 21, 2023
d05773a
Merge pull request #183 from dderemiah/fix-3.1.1
uk-bolly Dec 21, 2023
d2a78e5
Merge pull request #187 from dderemiah/typo_2.1.2.1
uk-bolly Dec 21, 2023
7ec71ab
Changed regex to account for different whitespace and grouping all th…
dderemiah Dec 27, 2023
00f9662
Merge pull request #185 from ansible-lockdown/pre-commit-ci-update-co…
georgenalen Dec 28, 2023
e1a80a7
Merge pull request #188 from dderemiah/regex-5.3.x
georgenalen Dec 28, 2023
ab6f9da
improves command collection to match CIS bench
dderemiah Jan 17, 2024
808b154
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jan 22, 2024
65870d3
Merge pull request #189 from dderemiah/improve_4.1.3
uk-bolly Jan 24, 2024
71ac3d9
Merge pull request #192 from ansible-lockdown/pre-commit-ci-update-co…
uk-bolly Jan 24, 2024
504eb15
Respect ipv6_disable mechanism
joshavant Jan 26, 2024
6328cf2
Merge pull request #191 from joshavant/respect-ipv6_disable-mechanism
uk-bolly Jan 26, 2024
6bd6371
Fixing issue https://code.siemens.com/infosec-pss-gov/security-crafte…
DianaMariaDDM Nov 22, 2023
2a7da70
Merge branch 'siemens/feat/rule_5_4_3_pamd_configuration' of github.c…
DianaMariaDDM Jan 26, 2024
e8aabea
Fixing issue https://code.siemens.com/infosec-pss-gov/security-crafte…
DianaMariaDDM Nov 22, 2023
8fdf840
Fixing issue https://code.siemens.com/infosec-pss-gov/security-crafte…
DianaMariaDDM Nov 22, 2023
64b58d3
Merge branch 'siemens/feat/rule_5_4_3_pamd_configuration' of github.c…
DianaMariaDDM Jan 26, 2024
a80de3a
Removing some trailing whitespaces
DianaMariaDDM Jan 29, 2024
b14f750
Merge branch 'siemens/feat/rule_5_4_3_pamd_configuration' of github.c…
DianaMariaDDM Jan 29, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
args: ['--baseline-path', '.config/.gitleaks-report.json']

- repo: https://github.com/ansible-community/ansible-lint
rev: v6.22.0
rev: v6.22.2
hooks:
- id: ansible-lint
name: Ansible-lint
Expand Down
4 changes: 2 additions & 2 deletions tasks/section_2/cis_2.1.2.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
owner: root
group: root
loop:
- etc/chrony/sources.d/pool.source
- etc/chrony/sources.d/server.source
- etc/chrony/sources.d/pool.sources
- etc/chrony/sources.d/server.sources
notify: Restart timeservice

- name: "2.1.2.1 | PATCH | Ensure chrony is configured with authorized timeserver | load sources"
Expand Down
1 change: 1 addition & 0 deletions tasks/section_3/cis_3.1.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
line: '\1 ipv6.disable=1"'
backrefs: true
when:
- ubtu22cis_ipv6_disable == 'grub'
- ipv6disable_replaced is not changed
- "'ipv6.disable' not in ubtu22cis_3_1_1_cmdline_settings.stdout"
notify: Grub update
Expand Down
1 change: 1 addition & 0 deletions tasks/section_3/cis_3.2.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
state: present
reload: true
ignoreerrors: true
when: ubtu22cis_ipv6_disable == 'sysctl'
notify:
- Flush ipv6 route table

Expand Down
2 changes: 2 additions & 0 deletions tasks/section_3/cis_3.3.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
state: present
reload: true
ignoreerrors: true
when: ubtu22cis_ipv6_disable == 'sysctl'
with_items:
- net.ipv6.conf.all.accept_source_route
- net.ipv6.conf.default.accept_source_route
Expand Down Expand Up @@ -66,6 +67,7 @@
state: present
reload: true
ignoreerrors: true
when: ubtu22cis_ipv6_disable == 'sysctl'
with_items:
- net.ipv6.conf.all.accept_redirects
- net.ipv6.conf.default.accept_redirects
Expand Down
2 changes: 1 addition & 1 deletion tasks/section_4/cis_4.1.3.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
- name: "4.1.3.6 | PATCH | Ensure use of privileged commands is collected"
block:
- name: "4.1.3.6 | AUDIT | Ensure use of privileged commands is collected | Get list of privileged programs"
ansible.builtin.shell: for i in $(df | grep '^/dev' | awk '{ print $NF }'); do find $i -xdev -type f -perm -4000 -o -type f -perm -2000 2>/dev/null; done
ansible.builtin.shell: for i in $(findmnt -n -l -k -it $(awk '/nodev/ { print $2 }' /proc/filesystems | paste -sd,) | grep -Pv "noexec|nosuid" | awk '{print $1}'); do find $i -xdev -type f -perm -4000 -o -type f -perm -2000 2>/dev/null; done
register: priv_procs
changed_when: false
check_mode: false
Expand Down
13 changes: 7 additions & 6 deletions tasks/section_5/cis_5.3.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
- name: "5.3.2 | PATCH | Ensure sudo commands use pty"
ansible.builtin.lineinfile:
path: /etc/sudoers
regexp: '^Defaults use_'
regexp: '^Defaults\s+use_'
line: 'Defaults use_pty'
insertafter: '^Defaults'
insertafter: '^\s*Defaults'
when:
- ubtu22cis_rule_5_3_2
tags:
Expand All @@ -33,9 +33,9 @@
- name: "5.3.3 | PATCH | Ensure sudo log file exists"
ansible.builtin.lineinfile:
path: /etc/sudoers
regexp: '^Defaults logfile'
regexp: '^Defaults\s+logfile'
line: 'Defaults logfile="{{ ubtu22cis_sudo_logfile }}"'
insertafter: '^Defaults'
insertafter: '^\s*Defaults'
when:
- ubtu22cis_rule_5_3_3
tags:
Expand Down Expand Up @@ -89,8 +89,9 @@
- name: "5.3.6 | PATCH | Ensure sudo authentication timeout is configured correctly | Set value if no results"
ansible.builtin.lineinfile:
path: /etc/sudoers
regexp: 'Defaults timestamp_timeout='
line: "Defaults timestamp_timeout={{ ubtu22cis_sudo_timestamp_timeout }}"
regexp: '^\s*Defaults/s+timestamp_timeout='
line: "Defaults timestamp_timeout={{ ubtu22cis_sudo_timestamp_timeout }}"
insertafter: '^\s*Defaults'
validate: '/usr/sbin/visudo -cf %s'
when: ubtu22cis_5_3_6_timeout_files.stdout | length == 0

Expand Down
32 changes: 24 additions & 8 deletions tasks/section_5/cis_5.4.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,30 @@
- pam
- notimplemented

- name: 5.4.3 | PATCH | Ensure password reuse is limited"
community.general.pamd:
name: common-password
type: password
control: '[success=1 default=ignore]'
module_path: pam_unix.so
module_arguments: "remember={{ ubtu22cis_pamd_pwhistory_remember }}"
state: args_present
- name: "5.4.3 | PATCH | Ensure password reuse is limited"
block:
- name: "5.4.3 | PATCH | Ensure password reuse is limited | Add pam_unix or edit it accordingly"
community.general.pamd:
name: common-password
type: password
control: '[success=1 default=ignore]'
module_path: pam_unix.so
module_arguments: 'obscure
yescrypt'
state: args_present

- name: "5.4.3 | PATCH | Ensure password reuse is limited| Set remember value after adding pam unix"
community.general.pamd:
name: common-password
type: password
control: '[success=1 default=ignore]'
module_path: pam_unix.so
new_type: password
new_module_path: pam_pwhistory.so
new_control: required
module_arguments: 'use_authtok
remember={{ ubtu22cis_pamd_pwhistory_remember }}'
state: before
when:
- ubtu22cis_rule_5_4_3
tags:
Expand Down