forked from ansible-lockdown/RHEL9-CIS
updated
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
398bc5bd0c
commit
c6caa90059
36 changed files with 2584 additions and 2078 deletions
|
|
@ -128,16 +128,16 @@
|
|||
- patch
|
||||
- rule_3.3.8
|
||||
|
||||
- name: "3.3.9 | L2 | PATCH | Ensure IPv6 router advertisements are not accepted"
|
||||
- name: "3.3.9 | PATCH | Ensure IPv6 router advertisements are not accepted"
|
||||
block:
|
||||
- name: "3.3.9 | L2 | PATCH | Ensure IPv6 router advertisements are not accepted"
|
||||
- name: "3.3.9 | PATCH | Ensure IPv6 router advertisements are not accepted"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/99-sysctl.conf"
|
||||
notify:
|
||||
- update sysctl
|
||||
- sysctl flush ipv4 route table
|
||||
|
||||
- name: "3.3.9 | L2 | PATCH | Ensure IPv6 router advertisements are not accepted"
|
||||
- name: "3.3.9 | PATCH | Ensure IPv6 router advertisements are not accepted"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/99-sysctl.conf"
|
||||
notify:
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
---
|
||||
|
||||
- name: "3.4.1.1 | L1 | PATCH | Ensure a Firewall package is installed"
|
||||
package:
|
||||
name: "{{ rhel9cis_firewall }}"
|
||||
state: present
|
||||
when:
|
||||
- rhel9cis_rule_3_4_1_1
|
||||
- not system_is_container
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.1.1
|
||||
138
tasks/section_3/cis_3.4.1.x.yml
Normal file
138
tasks/section_3/cis_3.4.1.x.yml
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
---
|
||||
|
||||
- name: "3.4.1.1 | PATCH | Ensure firewalld is installed"
|
||||
package:
|
||||
name:
|
||||
- firewalld
|
||||
- iptables
|
||||
state: present
|
||||
when:
|
||||
- rhel9cis_rule_3_4_1_1
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- firewalld
|
||||
- rule_3.4.1.1
|
||||
|
||||
- name: "3.4.1.2 | PATCH | Ensure iptables-services not installed with firewalld"
|
||||
block:
|
||||
- name: "3.4.1.2 | PATCH | Ensure iptables-services not installed with firewalld | Stop running services"
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: false
|
||||
masked: true
|
||||
with_items:
|
||||
- iptables
|
||||
- ip6tables
|
||||
when: item in ansible_facts.packages
|
||||
|
||||
- name: "3.4.1.2 | PATCH | Ensure iptables-services not installed with firewalld | Remove IPTables"
|
||||
package:
|
||||
name: iptables-services
|
||||
state: absent
|
||||
when:
|
||||
- rhel9cis_rule_3_4_1_2
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- firewalld
|
||||
- rule_3.4.1.2
|
||||
|
||||
- name: "3.4.1.3 | PATCH | Ensure nftables either not installed or masked with firewalld"
|
||||
systemd:
|
||||
name: nftables
|
||||
state: stopped
|
||||
masked: yes
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_rule_3_4_1_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- firewalld
|
||||
- rule_3_4_1_3
|
||||
|
||||
- name: "3.4.1.4 | PATCH | Ensure firewalld service is enabled and running"
|
||||
systemd:
|
||||
name: firewalld
|
||||
state: started
|
||||
enabled: yes
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_rule_3_4_1_4
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- firewalld
|
||||
- rule_3_4_1_4
|
||||
|
||||
- name: "3.4.1.5 | PATCH | Ensure firewalld default zone is set"
|
||||
command: firewall-cmd --set-default-zone="{{ rhel9cis_default_zone }}"
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_rule_3_4_1_5
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- firewalld
|
||||
- rule_3.4.1.5
|
||||
|
||||
- name: "3.4.1.6 | AUDIT | Ensure network interfaces are assigned to appropriate zone"
|
||||
block:
|
||||
- name: "3.4.1.6 | AUDIT | Ensure network interfaces are assigned to appropriate zone | Get list of interfaces and polocies"
|
||||
shell: "nmcli -t connection show | awk -F: '{ if($4){print $4} }' | while read INT; do firewall-cmd --get-active-zones | grep -B1 $INT; done"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: no
|
||||
register: rhel9cis_3_4_1_6_interfacepolicy
|
||||
|
||||
- name: "3.4.1.6 | AUDIT | Ensure network interfaces are assigned to appropriate zone | Get list of interfaces and polocies | Show the interface to policy"
|
||||
debug:
|
||||
msg:
|
||||
- "The items below are the policies tied to the interfaces, please correct as needed"
|
||||
- "{{ rhel9cis_3_4_1_6_interfacepolicy.stdout_lines }}"
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_rule_3_4_1_6
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- manual
|
||||
- audit
|
||||
- rule_3.4.1.6
|
||||
|
||||
- name: "3.4.1.7 | AUDIT | Ensure firewalld drops unnecessary services and ports"
|
||||
block:
|
||||
- name: "3.4.1.7 | AUDIT | Ensure firewalld drops unnecessary services and ports | Get list of services and ports"
|
||||
shell: "firewall-cmd --get-active-zones | awk '!/:/ {print $1}' | while read ZN; do firewall-cmd --list-all --zone=$ZN; done"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: no
|
||||
register: rhel9cis_3_4_1_7_servicesport
|
||||
|
||||
- name: "3.4.1.7 | AUDIT | Ensure firewalld drops unnecessary services and ports | Show services and ports"
|
||||
debug:
|
||||
msg:
|
||||
- "The items below are the services and ports that are accepted, please correct as needed"
|
||||
- "{{ rhel9cis_3_4_1_7_servicesport.stdout_lines }}"
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_rule_3_4_1_7
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- manual
|
||||
- audit
|
||||
- rule_3.4.1.7
|
||||
|
|
@ -1,108 +1,344 @@
|
|||
---
|
||||
|
||||
- name: "3.4.2.1 | L1 | PATCH | Ensure firewalld service is enabled and running"
|
||||
service:
|
||||
name: firewalld
|
||||
state: started
|
||||
enabled: true
|
||||
- name: "3.4.2.1 | PATCH | Ensure nftables is installed"
|
||||
package:
|
||||
name: nftables
|
||||
state: present
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_1
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3_4_2_1
|
||||
- nftables
|
||||
- rule_3.4.2.1
|
||||
|
||||
- name: "3.4.2.2 | L1 | PATCH | Ensure iptables is not enabled with firewalld"
|
||||
systemd:
|
||||
name: iptables
|
||||
masked: true
|
||||
# The control allows the service it be masked or not installed
|
||||
# We have chosen not installed
|
||||
- name: "3.4.2.2 | PATCH | Ensure firewalld is either not installed or masked with nftables"
|
||||
package:
|
||||
name: firewalld
|
||||
state: absent
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- "'iptables' in ansible_facts.packages"
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_2
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3_4_2_2
|
||||
- nftables
|
||||
- rule_3.4.2.2
|
||||
|
||||
- name: "3.4.2.3 | L1 | PATCH | Ensure nftables is not enabled with firewalld"
|
||||
systemd:
|
||||
name: nftables
|
||||
enabled: false
|
||||
masked: true
|
||||
- name: "3.4.2.3 | PATCH | Ensure iptables-services not installed with nftables"
|
||||
block:
|
||||
- name: "3.4.2.3 | PATCH | Ensure iptables-services not installed with nftables | Stop services"
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: false
|
||||
masked: true
|
||||
ignore_errors: true
|
||||
with_items:
|
||||
- iptables
|
||||
- ip6tables
|
||||
|
||||
- name: "3.4.2.3 | PATCH | Ensure iptables-services not installed with nftables | Remove IPTables"
|
||||
package:
|
||||
name: iptables-service
|
||||
state: absent
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- "'nftables' in ansible_facts.packages"
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3_4_2_3
|
||||
- nftables
|
||||
- rule_3.4.2.3
|
||||
|
||||
- name: "3.4.2.4 | L1 | PATCH | Ensure default zone is set"
|
||||
shell: firewall-cmd --set-default-zone="{{ rhel9cis_default_zone }}"
|
||||
args:
|
||||
warn: false
|
||||
- name: "3.4.2.4 | PATCH | Ensure iptables are flushed with nftables"
|
||||
block:
|
||||
- name: "3.4.2.4 | PATCH | Ensure iptables are flushed with nftables | IPv4"
|
||||
command: iptables -F
|
||||
|
||||
- name: "3.4.2.4 | PATCH | Ensure iptables are flushed with nftables | IPv6"
|
||||
command: ip6tables -F
|
||||
when: rhel9cis_ipv6_required
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_rule_3_4_2_4
|
||||
- rhel9cis_firewall != "firewalld"
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- manual
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.2.4
|
||||
|
||||
- name: "3.4.2.5 | L1 | AUDIT | Ensure network interfaces are assigned to appropriate zone"
|
||||
- name: "3.4.2.5 | AUDIT | Ensure an nftables table exists"
|
||||
block:
|
||||
- name: "3.4.2.5 | L1 | AUDIT | Ensure network interfaces are assigned to appropriate zone | Get list of interfaces and polocies"
|
||||
shell: "nmcli -t connection show | awk -F: '{ if($4){print $4} }' | while read INT; do firewall-cmd --get-active-zones | grep -B1 $INT; done"
|
||||
args:
|
||||
warn: false
|
||||
- name: "3.4.2.5 | AUDIT | Ensure a table exists | Check for tables"
|
||||
command: nft list tables
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
register: rhel9cis_3_4_2_5_interfacepolicy
|
||||
register: rhel9cis_3_4_2_5_nft_tables
|
||||
|
||||
- name: "3.4.2.5 | L1 | AUDIT | Ensure network interfaces are assigned to appropriate zone | Get list of interfaces and polocies | Show the interface to policy"
|
||||
- name: "3.4.2.5 | AUDIT | Ensure an nftables table exists | Show existing tables"
|
||||
debug:
|
||||
msg:
|
||||
- "The items below are the policies tied to the interfaces, please correct as needed"
|
||||
- "{{ rhel9cis_3_4_2_5_interfacepolicy.stdout_lines }}"
|
||||
- "Below are the current nft tables, please review"
|
||||
- "{{ rhel9cis_3_4_2_5_nft_tables.stdout_lines }}"
|
||||
when: rhel9cis_3_4_2_5_nft_tables.stdout | length > 0
|
||||
|
||||
- name: "3.4.2.5 | AUDIT | Ensure an nftables table exists | Alert on no tables"
|
||||
debug:
|
||||
msg:
|
||||
- "Warning! You currently have no nft tables, please review your setup"
|
||||
- 'Use the command "nft create table inet <table name>" to create a new table'
|
||||
when:
|
||||
- rhel9cis_3_4_2_5_nft_tables.stdout | length == 0
|
||||
- not rhel9cis_nft_tables_autonewtable
|
||||
|
||||
- name: "3.4.2.5 | PATCH | Ensure a table exists | Create table if needed"
|
||||
command: nft create table inet "{{ rhel9cis_nft_tables_tablename }}"
|
||||
failed_when: no
|
||||
when: rhel9cis_nft_tables_autonewtable
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_5
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- audit
|
||||
- automated
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.2.5
|
||||
|
||||
- name: "3.4.2.6 | L1 | AUDIT | Ensure firewalld drops unnecessary services and ports"
|
||||
- name: "3.4.2.6 | PATCH | Ensure nftables base chains exist"
|
||||
block:
|
||||
- name: "3.4.2.6 | L1 | AUDIT | Ensure firewalld drops unnecessary services and ports | Get list of services and ports"
|
||||
shell: "firewall-cmd --get-active-zones | awk '!/:/ {print $1}' | while read ZN; do firewall-cmd --list-all --zone=$ZN; done"
|
||||
args:
|
||||
warn: false
|
||||
- name: "3.4.2.6 | AUDIT | Ensure nftables base chains exist | Get current chains for INPUT"
|
||||
shell: nft list ruleset | grep 'hook input'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
register: rhel9cis_3_4_2_6_servicesport
|
||||
register: rhel9cis_3_4_2_6_input_chains
|
||||
|
||||
- name: "3.4.2.6 | L1 | AUDIT | Ensure firewalld drops unnecessary services and ports | Show services and ports"
|
||||
- name: "3.4.2.6 | AUDIT | Ensure nftables base chains exist | Get current chains for FORWARD"
|
||||
shell: nft list ruleset | grep 'hook forward'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_2_6_forward_chains
|
||||
|
||||
- name: "3.4.2.6 | AUDIT | Ensure nftables base chains exist | Get current chains for OUTPUT"
|
||||
shell: nft list ruleset | grep 'hook output'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_2_6_output_chains
|
||||
|
||||
- name: "3.4.2.6 | AUDIT | Ensure nftables base chains exist | Display chains for review"
|
||||
debug:
|
||||
msg:
|
||||
- "The items below are the services and ports that are accepted, please correct as needed"
|
||||
- "{{ rhel9cis_3_4_2_6_servicesport.stdout_lines }}"
|
||||
- "Below are the current INPUT chains"
|
||||
- "{{ rhel9cis_3_4_2_6_input_chains.stdout_lines }}"
|
||||
- "Below are the current FORWARD chains"
|
||||
- "{{ rhel9cis_3_4_2_6_forward_chains.stdout_lines }}"
|
||||
- "Below are teh current OUTPUT chains"
|
||||
- "{{ rhel9cis_3_4_2_6_output_chains.stdout_lines }}"
|
||||
when: not rhel9cis_nft_tables_autochaincreate
|
||||
|
||||
- name: "3.4.2.6 | PATCH | Ensure nftables base chains exist | Create chains if needed"
|
||||
shell: "{{ item }}"
|
||||
args:
|
||||
warn: no
|
||||
failed_when: no
|
||||
with_items:
|
||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" input { type filter hook input priority 0 \; }
|
||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { type filter hook forward priority 0 \; }
|
||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" output { type filter hook output priority 0 \; }
|
||||
when: rhel9cis_nft_tables_autochaincreate
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_6
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- audit
|
||||
- automate
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.2.6
|
||||
|
||||
- name: "3.4.2.7 | PATCH | Ensure nftables loopback traffic is configured"
|
||||
block:
|
||||
- name: "3.4.2.7 | AUDIT | Ensure nftables loopback traffic is configured | Gather iif lo accept existence"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep 'iif "lo" accept'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_2_7_iiflo
|
||||
|
||||
- name: "3.4.2.7 | AUDIT | Ensure nftables loopback traffic is configured | Gather ip saddr existence"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep 'ip saddr'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_2_7_ipsaddr
|
||||
|
||||
- name: "3.4.2.7 | AUDIT | Ensure nftables loopback traffic is configured | Gather ip6 saddr existence"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep 'ip6 saddr'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_2_7_ip6saddr
|
||||
|
||||
- name: "3.4.2.7 | PATCH | Ensure nftables loopback traffic is configured | Set iif lo accept rule"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input iif lo accept
|
||||
when: '"iif \"lo\" accept" not in rhel9cis_3_4_2_7_iiflo.stdout'
|
||||
|
||||
- name: "3.4.2.7 | PATCH | Ensure nftables loopback traffic is configured | Set ip sddr rule"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip saddr 127.0.0.0/8 counter drop
|
||||
when: '"ip saddr 127.0.0.0/8 counter packets 0 bytes 0 drop" not in rhel9cis_3_4_2_7_ipsaddr.stdout'
|
||||
|
||||
- name: "3.4.2.7 | PATCH | Ensure nftables loopback traffic is configured | Set ip6 saddr rule"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip6 saddr ::1 counter drop
|
||||
when: '"ip6 saddr ::1 counter packets 0 bytes 0 drop" not in rhel9cis_3_4_2_7_ip6saddr.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_7
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.2.7
|
||||
|
||||
- name: "3.4.2.8 | PATCH | Ensure nftables outbound and established connections are configured"
|
||||
block:
|
||||
- name: "3.4.2.8 | AUDIT | Ensure nftables outbound and established connections are configured | Gather incoming connection rules"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep -E 'ip protocol (tcp|udp|icmp) ct state'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_2_8_inconnectionrule
|
||||
|
||||
- name: "3.4.2.8| AUDIT | Ensure nftables outbound and established connections are configured | Gather outbound connection rules"
|
||||
shell: nft list ruleset | awk '/hook output/,/}/' | grep -E 'ip protocol (tcp|udp|icmp) ct state'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_2_8_outconnectionrule
|
||||
|
||||
- name: "3.4.2.8| PATCH | Ensure nftables outbound and established connections are configured | Add input tcp established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol tcp ct state established accept
|
||||
when: '"ip protocol tcp ct state established accept" not in rhel9cis_3_4_2_8_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.2.8 | PATCH | Ensure nftables outbound and established connections are configured | Add input udp established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol udp ct state established accept
|
||||
when: '"ip protocol udp ct state established accept" not in rhel9cis_3_4_2_8_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.2.8 | PATCH | Ensure nftables outbound and established connections are configured | Add input icmp established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol icmp ct state established accept
|
||||
when: '"ip protocol icmp ct state established accept" not in rhel9cis_3_4_2_8_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.2.8 | PATCH | Ensure nftables outbound and established connections are configured | Add output tcp new, related, established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol tcp ct state new,related,established accept
|
||||
when: '"ip protocol tcp ct state established,related,new accept" not in rhel9cis_3_4_2_8_outconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.2.8 | PATCH | Ensure nftables outbound and established connections are configured | Add output udp new, related, established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol udp ct state new,related,established accept
|
||||
when: '"ip protocol udp ct state established,related,new accept" not in rhel9cis_3_4_2_8_outconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.2.8 | PATCH | Ensure nftables outbound and established connections are configured | Add output icmp new, related, established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol icmp ct state new,related,established accept
|
||||
when: '"ip protocol icmp ct state established,related,new accept" not in rhel9cis_3_4_2_8_outconnectionrule.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_8
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.3.5
|
||||
|
||||
- name: "3.4.2.9 | PATCH | Ensure nftables default deny firewall policy"
|
||||
block:
|
||||
- name: "3.4.2.9 | AUDIT | Ensure nftables default deny firewall policy | Check for hook input deny policy"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'hook input'
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_2_9_inputpolicy
|
||||
|
||||
- name: "3.4.2.9 | AUDIT | Ensure nftables default deny firewall policy | Check for hook forward deny policy"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'hook forward'
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_2_9_forwardpolicy
|
||||
|
||||
- name: "3.4.2.9 | AUDIT | Ensure nftables default deny firewall policy | Check for hook output deny policy"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'hook output'
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_2_9_outputpolicy
|
||||
|
||||
- name: "3.4.2.9 | AUDIT | Ensure nftables default deny firewall policy | Check for SSH allow"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'ssh'
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_2_9_sshallowcheck
|
||||
|
||||
- name: "3.4.2.9 | PATCH | Ensure nftables default deny firewall policy | Enable SSH traffic"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input tcp dport ssh accept
|
||||
when: '"tcp dport ssh accept" not in rhel9cis_3_4_2_9_sshallowcheck.stdout'
|
||||
|
||||
- name: "3.4.2.9 | PATCH | Ensure nftables default deny firewall policy | Set hook input deny policy"
|
||||
command: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" input { policy drop \; }
|
||||
when: '"type filter hook input priority 0; policy drop;" not in rhel9cis_3_4_2_9_inputpolicy.stdout'
|
||||
|
||||
- name: "3.4.2.9 | PATCH | Ensure nftables default deny firewall policy | Create hook forward deny policy"
|
||||
command: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { policy drop \; }
|
||||
when: '"type filter hook forward priority 0; policy drop;" not in rhel9cis_3_4_2_9_forwardpolicy.stdout'
|
||||
|
||||
- name: "3.4.2.9 | PATCH | Ensure nftables default deny firewall policy | Create hook output deny policy"
|
||||
command: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" output { policy drop \; }
|
||||
when: '"type filter hook output priority 0; policy drop;" not in rhel9cis_3_4_2_9_outputpolicy.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_9
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.2.9
|
||||
|
||||
- name: "3.4.2.10 | PATCH | Ensure nftables service is enabled"
|
||||
service:
|
||||
name: nftables
|
||||
enabled: yes
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_10
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.3.7
|
||||
|
||||
- name: "3.4.2.11 | PATCH | Ensure nftables rules are permanent"
|
||||
lineinfile:
|
||||
path: /etc/sysconfig/nftables.conf
|
||||
state: present
|
||||
insertafter: EOF
|
||||
line: include "/etc/nftables/inet-{{ rhel9cis_nft_tables_tablename }}"
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_2_11
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- nftables
|
||||
- rule_3.4.2.11
|
||||
|
|
|
|||
50
tasks/section_3/cis_3.4.3.1.x.yml
Normal file
50
tasks/section_3/cis_3.4.3.1.x.yml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
|
||||
- name: "3.4.3.1.1 | PATCH | Ensure iptables packages are installed"
|
||||
package:
|
||||
name:
|
||||
- iptables
|
||||
- iptables-services
|
||||
state: present
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_3_1_1
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- iptables
|
||||
- rule_3.4.3.1.1
|
||||
|
||||
- name: "3.4.3.1.2 | PATCH | Ensure nftables is not installed with iptables"
|
||||
package:
|
||||
name: nftables
|
||||
state: absent
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_3_1_2
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- iptables
|
||||
- rule_3.4.3.1.2
|
||||
|
||||
# The control allows the service it be masked or not installed
|
||||
# We have chosen not installed
|
||||
- name: "3.4.3.1.3 | PATCH | Ensure firewalld is either not installed or masked with iptables"
|
||||
package:
|
||||
name: firewalld
|
||||
state: absent
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_3_1_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- iptables
|
||||
- rule_3.4.3.1.3
|
||||
|
|
@ -1,48 +1,22 @@
|
|||
---
|
||||
|
||||
- name: "3.4.4.1.1 | L1 | PATCH | Ensure iptables default deny firewall policy"
|
||||
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured"
|
||||
block:
|
||||
- name: "3.4.4.1.1 | L1 | PATCH | Ensure iptables default deny firewall policy | Configure ssh to be allowed"
|
||||
iptables:
|
||||
chain: INPUT
|
||||
protocol: tcp
|
||||
destination_port: "22"
|
||||
jump: ACCEPT
|
||||
|
||||
- name: "3.4.4.1.1 | L1 | PATCH | Ensure iptables default deny firewall policy | Set drop items"
|
||||
iptables:
|
||||
policy: DROP
|
||||
chain: "{{ item }}"
|
||||
with_items:
|
||||
- INPUT
|
||||
- FORWARD
|
||||
- OUTPUT
|
||||
when:
|
||||
- rhel9cis_rule_3_4_4_1_1
|
||||
- rhel9cis_firewall == "iptables"
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.4.1.1
|
||||
|
||||
- name: "3.4.4.1.2 | L1 | PATCH | Ensure iptables loopback traffic is configured"
|
||||
block:
|
||||
- name: "3.4.4.1.2 | L1 | Ensure iptables loopback traffic is configured | INPUT Loopback ACCEPT"
|
||||
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured | INPUT Loopback ACCEPT"
|
||||
iptables:
|
||||
action: append
|
||||
chain: INPUT
|
||||
in_interface: lo
|
||||
jump: ACCEPT
|
||||
|
||||
- name: "3.4.4.1.2 | L1 | PATCH | Ensure iptables loopback traffic is configured | OUTPUT Loopback ACCEPT"
|
||||
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured | OUTPUT Loopback ACCEPT"
|
||||
iptables:
|
||||
action: append
|
||||
chain: OUTPUT
|
||||
out_interface: lo
|
||||
jump: ACCEPT
|
||||
|
||||
- name: "3.4.4.1.2 | L1 | PATCH | Ensure iptables loopback traffic is configured | INPUT Loopback 127.0.0.0/8"
|
||||
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured | INPUT Loopback 127.0.0.0/8"
|
||||
iptables:
|
||||
action: append
|
||||
chain: INPUT
|
||||
|
|
@ -50,14 +24,16 @@
|
|||
jump: DROP
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_1_2
|
||||
- rhel9cis_rule_3_4_3_2_1
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3.4.4.1.2
|
||||
- iptables
|
||||
- rule_3.4.3.2.1
|
||||
|
||||
- name: "3.4.4.1.3 | L1 | PATCH | Ensure iptables outbound and established connections are configured"
|
||||
- name: "3.4.3.2.2 | PATCH | Ensure iptables outbound and established connections are configured"
|
||||
iptables:
|
||||
action: append
|
||||
chain: '{{ item.chain }}'
|
||||
|
|
@ -74,32 +50,30 @@
|
|||
- { chain: INPUT, protocol: icmp, ctstate: ESTABLISHED }
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_1_3
|
||||
- rhel9cis_rule_3_4_3_2_2
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- manual
|
||||
- patch
|
||||
- rule_3.4.4.1.3
|
||||
- iptables
|
||||
- rule_3.4.3.2.2
|
||||
|
||||
- name: "3.4.4.1.4 | L1 | PATCH | Ensure iptables firewall rules exist for all open ports"
|
||||
- name: "3.4.3.2.3 | PATCH | Ensure iptables rules exist for all open ports"
|
||||
block:
|
||||
- name: "3.4.4.1.4 | L1 | AUDIT | Ensure iptables firewall rules exist for all open ports | Get list of TCP open ports"
|
||||
- name: "3.4.3.2.3 | AUDIT | Ensure iptables rules exist for all open ports | Get list of TCP open ports"
|
||||
shell: netstat -ant |grep "tcp.*LISTEN" | awk '{ print $4 }'| sed 's/.*://'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_4_1_4_otcp
|
||||
register: rhel9cis_3_4_3_2_3_otcp
|
||||
|
||||
- name: "3.4.4.1.4 | L1 | AUDIT | Ensure iptables firewall rules exist for all open ports | Get the list of udp open ports"
|
||||
- name: "3.4.3.2.3 | AUDIT | Ensure iptables rules exist for all open ports | Get the list of udp open ports"
|
||||
shell: netstat -ant |grep "udp.*LISTEN" | awk '{ print $4 }'| sed 's/.*://'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_4_1_4_oudp
|
||||
register: rhel9cis_3_4_3_2_3_oudp
|
||||
|
||||
- name: "3.4.4.1.4 | L1 | PATCH | Ensure iptables firewall rules exist for all open ports | Adjust open tcp ports"
|
||||
- name: "3.4.3.2.3 | PATCH | Ensure iptables rules exist for all open ports | Adjust open tcp ports"
|
||||
iptables:
|
||||
action: append
|
||||
chain: INPUT
|
||||
|
|
@ -109,10 +83,10 @@
|
|||
ctstate: NEW
|
||||
jump: ACCEPT
|
||||
with_items:
|
||||
- "{{ rhel9cis_3_4_4_1_4_otcp.stdout_lines }}"
|
||||
when: rhel9cis_3_4_4_1_4_otcp.stdout is defined
|
||||
- "{{ rhel9cis_3_4_3_2_3_otcp.stdout_lines }}"
|
||||
when: rhel9cis_3_4_3_2_3_otcp.stdout is defined
|
||||
|
||||
- name: "3.4.4.1.4 | L1 | PATCH | Ensure iptables firewall rules exist for all open ports | Adjust open udp ports"
|
||||
- name: "3.4.3.2.3 | PATCH | Ensure iptables rules exist for all open ports | Adjust open udp ports"
|
||||
iptables:
|
||||
action: append
|
||||
chain: INPUT
|
||||
|
|
@ -122,27 +96,74 @@
|
|||
ctstate: NEW
|
||||
jump: ACCEPT
|
||||
with_items:
|
||||
- "{{ rhel9cis_3_4_4_1_4_oudp.stdout_lines }}"
|
||||
when: rhel9cis_3_4_4_1_4_otcp.stdout is defined
|
||||
- "{{ rhel9cis_3_4_3_2_3_oudp.stdout_lines }}"
|
||||
when: rhel9cis_3_4_3_2_3_otcp.stdout is defined
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_1_4
|
||||
- rhel9cis_rule_3_4_3_2_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3.4.4.1.4
|
||||
- iptables
|
||||
- rule_3.4.3.2.3
|
||||
|
||||
- name: "3.4.4.1.5 | L1 | PATCH | Ensure iptables service is enabled and active | Check if iptables is enabled"
|
||||
- name: "3.4.3.2.4 | PATCH | Ensure iptables default deny firewall policy"
|
||||
block:
|
||||
- name: "3.4.3.2.4 | PATCH | Ensure iptables default deny firewall policy | Configure ssh to be allowed"
|
||||
iptables:
|
||||
chain: INPUT
|
||||
protocol: tcp
|
||||
destination_port: "22"
|
||||
jump: ACCEPT
|
||||
|
||||
- name: "3.4.3.2.4 | PATCH | Ensure iptables default deny firewall policy | Set drop items"
|
||||
iptables:
|
||||
policy: DROP
|
||||
chain: "{{ item }}"
|
||||
with_items:
|
||||
- INPUT
|
||||
- FORWARD
|
||||
- OUTPUT
|
||||
when:
|
||||
- rhel9cis_rule_3_4_3_2_4
|
||||
- rhel9cis_firewall == "iptables"
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- iptables
|
||||
- rule_3.4.3.2.4
|
||||
|
||||
- name: "3.4.3.2.5 | PATCH | Ensure iptables rules are saved"
|
||||
iptables_state:
|
||||
state: saved
|
||||
path: /etc/sysconfig/iptables
|
||||
when:
|
||||
- rhel9cis_rule_3_4_3_2_5
|
||||
- rhel9cis_firewall == "iptables"
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- iptables
|
||||
- rule_3.4.3.2.5
|
||||
|
||||
- name: "3.4.3.2.6 | PATCH | Ensure iptables service is enabled and active"
|
||||
service:
|
||||
name: iptables
|
||||
enabled: true
|
||||
enabled: yes
|
||||
state: started
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_1_5
|
||||
- rhel9cis_rule_3_4_3_2_6
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3.4.4.1.5
|
||||
- iptables
|
||||
- rule_3.4.3.2.6
|
||||
|
|
@ -1,37 +1,8 @@
|
|||
---
|
||||
|
||||
- name: "3.4.4.2.1 | L1 | PATCH | Ensure ip6tables default deny firewall policy"
|
||||
- name: "3.4.3.3.1 | PATCH | Ensure ip6tables loopback traffic is configured"
|
||||
block:
|
||||
- name: "3.4.4.2.1 | L1 | Ensure ip6tables default deny firewall policy | Configure ssh to be allowed"
|
||||
iptables:
|
||||
chain: INPUT
|
||||
protocol: tcp
|
||||
destination_port: "22"
|
||||
jump: ACCEPT
|
||||
ip_version: ipv6
|
||||
|
||||
- name: "3.4.4.2.1 | L1 | PATCH | Ensure ip6tables default deny firewall policy | Set drop items"
|
||||
iptables:
|
||||
policy: DROP
|
||||
chain: "{{ item }}"
|
||||
ip_version: ipv6
|
||||
with_items:
|
||||
- INPUT
|
||||
- FORWARD
|
||||
- OUTPUT
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_2_1
|
||||
- rhel9cis_ipv6_required
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.4.2.1
|
||||
|
||||
- name: "3.4.4.2.2 | L1 | PATCH | Ensure ip6tables loopback traffic is configured"
|
||||
block:
|
||||
- name: "3.4.4.2.2 | L1 | PATCH | Ensure ip6tables loopback traffic is configured | INPUT Loopback ACCEPT"
|
||||
- name: "3.4.3.3.1 | PATCH | Ensure ip6tables loopback traffic is configured | INPUT Loopback ACCEPT"
|
||||
iptables:
|
||||
action: append
|
||||
chain: INPUT
|
||||
|
|
@ -39,7 +10,7 @@
|
|||
jump: ACCEPT
|
||||
ip_version: ipv6
|
||||
|
||||
- name: "3.4.4.2.2 | L1 | PATCH | Ensure ip6tables loopback traffic is configured | OUTPUT Loopback ACCEPT"
|
||||
- name: "3.4.3.3.1 | PATCH | Ensure ip6tables loopback traffic is configured | OUTPUT Loopback ACCEPT"
|
||||
iptables:
|
||||
action: append
|
||||
chain: OUTPUT
|
||||
|
|
@ -47,7 +18,7 @@
|
|||
jump: ACCEPT
|
||||
ip_version: ipv6
|
||||
|
||||
- name: "3.4.4.2.2 | L1 | PATCH | Ensure ip6tables loopback traffic is configured | INPUT Loopback 127.0.0.0/8"
|
||||
- name: "3.4.3.3.1 | PATCH | Ensure ip6tables loopback traffic is configured | INPUT Loopback 127.0.0.0/8"
|
||||
iptables:
|
||||
action: append
|
||||
chain: INPUT
|
||||
|
|
@ -56,15 +27,17 @@
|
|||
ip_version: ipv6
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_2_2
|
||||
- rhel9cis_rule_3_4_3_3_1
|
||||
- rhel9cis_ipv6_required
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3.4.4.2.2
|
||||
- ip6tables
|
||||
- rule_3.4.3.3.1
|
||||
|
||||
- name: "3.4.4.2.3 | L1 | PATCH | Ensure ip6tables outbound and established connections are configured"
|
||||
- name: "3.4.3.3.2 | PATCH | Ensure ip6tables outbound and established connections are configured"
|
||||
iptables:
|
||||
action: append
|
||||
chain: '{{ item.chain }}'
|
||||
|
|
@ -82,23 +55,25 @@
|
|||
- { chain: INPUT, protocol: icmp, ctstate: ESTABLISHED }
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_2_3
|
||||
- rhel9cis_rule_3_4_3_3_2
|
||||
- rhel9cis_ipv6_required
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- manual
|
||||
- patch
|
||||
- rule_3.4.4.2.3
|
||||
- ip6tables
|
||||
- rule_3.4.3.3.2
|
||||
|
||||
- name: "3.4.4.2.4 | L1 | PATCH | Ensure ip6tables firewall rules exist for all open ports"
|
||||
- name: "3.4.3.3.3 | PATCH | Ensure ip6tables firewall rules exist for all open ports"
|
||||
block:
|
||||
- name: "3.4.4.2.4 | L1 | AUDIT | Ensure ip6tables firewall rules exist for all open ports | Get list of TCP6 open ports"
|
||||
- name: "3.4.3.3.3 | AUDIT | Ensure ip6tables firewall rules exist for all open ports | Get list of TCP6 open ports"
|
||||
shell: netstat -ant |grep "tcp6.*LISTEN" | awk '{ print $4 }'| sed 's/.*://'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_4_2_4_otcp
|
||||
register: rhel9cis_3_4_3_3_3_otcp
|
||||
|
||||
- name: "3.4.4.2.4 | L1 | PATCH |Ensure ip6tables firewall rules exist for all open ports| Adjust open tcp6 ports"
|
||||
- name: "3.4.3.3.3 | PATCH |Ensure ip6tables firewall rules exist for all open ports| Adjust open tcp6 ports"
|
||||
iptables:
|
||||
action: append
|
||||
chain: INPUT
|
||||
|
|
@ -109,28 +84,80 @@
|
|||
jump: ACCEPT
|
||||
ip_version: ipv6
|
||||
with_items:
|
||||
- "{{ rhel9cis_3_4_4_2_4_otcp.stdout_lines }}"
|
||||
when: rhel9cis_3_4_4_2_4_otcp.stdout is defined
|
||||
- "{{ rhel9cis_3_4_3_3_3_otcp.stdout_lines }}"
|
||||
when: rhel9cis_3_4_3_3_3_otcp.stdout is defined
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_2_4
|
||||
- rhel9cis_rule_3_4_3_3_3
|
||||
- rhel9cis_ipv6_required
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3.4.4.2.4
|
||||
- ip6tables
|
||||
- rule_3.4.3.3.3
|
||||
|
||||
- name: "3.4.4.2.5 | L1 | PATCH | Ensure ip6tables service is enabled and active | Check if ip6tables is enabled"
|
||||
service:
|
||||
name: ip6tables
|
||||
enabled: true
|
||||
state: started
|
||||
- name: "3.4.3.3.4 | PATCH | Ensure ip6tables default deny firewall policy"
|
||||
block:
|
||||
- name: "3.4.3.3.4 | PATCH | Ensure ip6tables default deny firewall policy | Configure ssh to be allowed"
|
||||
iptables:
|
||||
chain: INPUT
|
||||
protocol: tcp
|
||||
destination_port: "22"
|
||||
jump: ACCEPT
|
||||
ip_version: ipv6
|
||||
|
||||
- name: "3.4.3.3.4 | PATCH | Ensure ip6tables default deny firewall policy | Set drop items"
|
||||
iptables:
|
||||
policy: DROP
|
||||
chain: "{{ item }}"
|
||||
ip_version: ipv6
|
||||
with_items:
|
||||
- INPUT
|
||||
- FORWARD
|
||||
- OUTPUT
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_4_2_5
|
||||
- rhel9cis_rule_3_4_3_3_4
|
||||
- rhel9cis_ipv6_required
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- rule_3.4.4.2.5
|
||||
- ip6tables
|
||||
- rule_3.4.3.3.4
|
||||
|
||||
- name: "3.4.3.3.5 | PATCH | Ensure ip6tables rules are saved"
|
||||
iptables_state:
|
||||
state: saved
|
||||
path: /etc/sysconfig/ip6tables
|
||||
ip_version: ipv6
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_ipv6_required
|
||||
- rhel9cis_rule_3_4_3_3_5
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- ip6tables
|
||||
- rule_3.4.3.3.5
|
||||
|
||||
- name: "3.4.3.3.6 | PATCH | Ensure ip6tables service is enabled and active"
|
||||
service:
|
||||
name: ip6tables
|
||||
enabled: yes
|
||||
state: started
|
||||
when:
|
||||
- rhel9cis_firewall == "iptables"
|
||||
- rhel9cis_rule_3_4_3_3_6
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- automated
|
||||
- patch
|
||||
- ip6tables
|
||||
- rule_3.4.3.3.6
|
||||
|
|
@ -1,320 +0,0 @@
|
|||
---
|
||||
|
||||
- name: "3.4.3.1 | L1 | PATCH | Ensure iptables are flushed with nftables"
|
||||
shell: ip6tables -F
|
||||
args:
|
||||
warn: false
|
||||
when:
|
||||
- rhel9cis_rule_3_4_3_1
|
||||
- rhel9cis_firewall != "iptables"
|
||||
- rhel9cis_ipv6_required
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.1
|
||||
|
||||
- name: "3.4.3.2 | L1 | AUDIT | Ensure an nftables table exists"
|
||||
block:
|
||||
- name: "3.4.3.2 | L1 | AUDIT | Ensure a table exists | Check for tables"
|
||||
shell: nft list tables
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_2_nft_tables
|
||||
|
||||
- name: "3.4.3.2 | L1 | AUDIT | Ensure an nftables table exists | Show existing tables"
|
||||
debug:
|
||||
msg:
|
||||
- "Below are the current nft tables, please review"
|
||||
- "{{ rhel9cis_3_4_3_2_nft_tables.stdout_lines }}"
|
||||
when: rhel9cis_3_4_3_2_nft_tables.stdout | length > 0
|
||||
|
||||
- name: "3.4.3.2 | L1 | AUDIT | Ensure an nftables table exists | Alert on no tables"
|
||||
debug:
|
||||
msg:
|
||||
- "Warning! You currently have no nft tables, please review your setup"
|
||||
- 'Use the shell "nft create table inet <table name>" to create a new table'
|
||||
when:
|
||||
- rhel9cis_3_4_3_2_nft_tables.stdout | length == 0
|
||||
- not rhel9cis_nft_tables_autonewtable
|
||||
|
||||
- name: "3.4.3.2 | L1 | PATCH | Ensure a table exists | Create table if needed"
|
||||
shell: nft create table inet "{{ rhel9cis_nft_tables_tablename }}"
|
||||
args:
|
||||
warn: false
|
||||
failed_when: false
|
||||
when: rhel9cis_nft_tables_autonewtable
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_3_2
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.2
|
||||
|
||||
- name: "3.4.3.3 | L1 | PATCH | Ensure nftables base chains exist"
|
||||
block:
|
||||
- name: "3.4.3.3 | L1 | Ensure nftables base chains exist | Get current chains for INPUT"
|
||||
shell: nft list ruleset | grep 'hook input'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_3_input_chains
|
||||
|
||||
- name: "3.4.3.3 | L1 | AUDIT | Ensure nftables base chains exist | Get current chains for FORWARD"
|
||||
shell: nft list ruleset | grep 'hook forward'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_3_forward_chains
|
||||
|
||||
- name: "3.4.3.3 | L1 | AUDIT | Ensure nftables base chains exist | Get current chains for OUTPUT"
|
||||
shell: nft list ruleset | grep 'hook output'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_3_output_chains
|
||||
|
||||
- name: "3.4.3.3 | L1 | AUDIT | Ensure nftables base chains exist | Display chains for review"
|
||||
debug:
|
||||
msg:
|
||||
- "Below are the current INPUT chains"
|
||||
- "{{ rhel9cis_3_4_3_3_input_chains.stdout_lines }}"
|
||||
- "Below are the current FORWARD chains"
|
||||
- "{{ rhel9cis_3_4_3_3_forward_chains.stdout_lines }}"
|
||||
- "Below are teh current OUTPUT chains"
|
||||
- "{{ rhel9cis_3_4_3_3_output_chains.stdout_lines }}"
|
||||
when: not rhel9cis_nft_tables_autochaincreate
|
||||
|
||||
- name: "3.4.3.3 | L1 | PATCH | Ensure nftables base chains exist | Create chains if needed"
|
||||
shell: "{{ item }}"
|
||||
args:
|
||||
warn: false
|
||||
failed_when: false
|
||||
with_items:
|
||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" input { type filter hook input priority 0 \; }
|
||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { type filter hook forward priority 0 \; }
|
||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" output { type filter hook output priority 0 \; }
|
||||
when: rhel9cis_nft_tables_autochaincreate
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_3_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.3
|
||||
|
||||
- name: "3.4.3.4 | L1 | PATCH | Ensure nftables loopback traffic is configured"
|
||||
block:
|
||||
- name: "3.4.3.4 | L1 | AUDIT | Ensure nftables loopback traffic is configured | Gather iif lo accept existence"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep 'iif "lo" accept'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_4_iiflo
|
||||
|
||||
- name: "3.4.3.4 | L1 | AUDIT | Ensure nftables loopback traffic is configured | Gather ip saddr existence"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep 'ip saddr'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_4_ipsaddr
|
||||
|
||||
- name: "3.4.3.4 | L1 | AUDIT | Ensure nftables loopback traffic is configured | Gather ip6 saddr existence"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep 'ip6 saddr'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_4_ip6saddr
|
||||
|
||||
- name: "3.4.3.4 | L1 | PATCH | Ensure nftables loopback traffic is configured | Set iif lo accept rule"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input iif lo accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"iif \"lo\" accept" not in rhel9cis_3_4_3_4_iiflo.stdout'
|
||||
|
||||
- name: "3.4.3.4 | L1 | PATCH | Ensure nftables loopback traffic is configured | Set ip sddr rule"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip saddr 127.0.0.0/8 counter drop
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip saddr 127.0.0.0/8 counter packets 0 bytes 0 drop" not in rhel9cis_3_4_3_4_ipsaddr.stdout'
|
||||
|
||||
- name: "3.4.3.4 | L1 | PATCH | Ensure nftables loopback traffic is configured | Set ip6 saddr rule"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip6 saddr ::1 counter drop
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip6 saddr ::1 counter packets 0 bytes 0 drop" not in rhel9cis_3_4_3_4_ip6saddr.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_3_4
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.4
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured"
|
||||
block:
|
||||
- name: "3.4.3.5 | L1 | AUDIT | Ensure nftables outbound and established connections are configured | Gather incoming connection rules"
|
||||
shell: nft list ruleset | awk '/hook input/,/}/' | grep -E 'ip protocol (tcp|udp|icmp) ct state'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_5_inconnectionrule
|
||||
|
||||
- name: "3.4.3.5 | L1 | AUDIT | Ensure nftables outbound and established connections are configured | Gather outbound connection rules"
|
||||
shell: nft list ruleset | awk '/hook output/,/}/' | grep -E 'ip protocol (tcp|udp|icmp) ct state'
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_5_outconnectionrule
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add input tcp established accept policy"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol tcp ct state established accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip protocol tcp ct state established accept" not in rhel9cis_3_4_3_5_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add input udp established accept policy"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol udp ct state established accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip protocol udp ct state established accept" not in rhel9cis_3_4_3_5_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add input icmp established accept policy"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol icmp ct state established accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip protocol icmp ct state established accept" not in rhel9cis_3_4_3_5_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add output tcp new, related, established accept policy"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol tcp ct state new,related,established accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip protocol tcp ct state established,related,new accept" not in rhel9cis_3_4_3_5_outconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add output udp new, related, established accept policy"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol udp ct state new,related,established accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip protocol udp ct state established,related,new accept" not in rhel9cis_3_4_3_5_outconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add output icmp new, related, established accept policy"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol icmp ct state new,related,established accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"ip protocol icmp ct state established,related,new accept" not in rhel9cis_3_4_3_5_outconnectionrule.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_3_5
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.5
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy"
|
||||
block:
|
||||
- name: "3.4.3.6 | L1 | AUDIT | Ensure nftables default deny firewall policy | Check for hook input deny policy"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'hook input'
|
||||
args:
|
||||
warn: false
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_3_6_inputpolicy
|
||||
|
||||
- name: "3.4.3.6 | L1 | AUDIT | Ensure nftables default deny firewall policy | Check for hook forward deny policy"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'hook forward'
|
||||
args:
|
||||
warn: false
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_3_6_forwardpolicy
|
||||
|
||||
- name: "3.4.3.6 | L1 | AUDIT | Ensure nftables default deny firewall policy | Check for hook output deny policy"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'hook output'
|
||||
args:
|
||||
warn: false
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_3_6_outputpolicy
|
||||
|
||||
- name: "3.4.3.6 | L1 | AUDIT | Ensure nftables default deny firewall policy | Check for SSH allow"
|
||||
shell: nft list table inet "{{ rhel9cis_nft_tables_tablename }}" | grep 'ssh'
|
||||
args:
|
||||
warn: false
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: rhel9cis_3_4_3_6_sshallowcheck
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Enable SSH traffic"
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input tcp dport ssh accept
|
||||
args:
|
||||
warn: false
|
||||
when: '"tcp dport ssh accept" not in rhel9cis_3_4_3_6_sshallowcheck.stdout'
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Set hook input deny policy"
|
||||
shell: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" input { policy drop \; }
|
||||
args:
|
||||
warn: false
|
||||
when: '"type filter hook input priority 0; policy drop;" not in rhel9cis_3_4_3_6_inputpolicy.stdout'
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Create hook forward deny policy"
|
||||
shell: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { policy drop \; }
|
||||
args:
|
||||
warn: false
|
||||
when: '"type filter hook forward priority 0; policy drop;" not in rhel9cis_3_4_3_6_forwardpolicy.stdout'
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Create hook output deny policy"
|
||||
shell: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" output { policy drop \; }
|
||||
args:
|
||||
warn: false
|
||||
when: '"type filter hook output priority 0; policy drop;" not in rhel9cis_3_4_3_6_outputpolicy.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_3_6
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.6
|
||||
|
||||
- name: "3.4.3.7 | L1 | PATCH | Ensure nftables service is enabled | Check if nftables is enabled"
|
||||
service:
|
||||
name: nftables
|
||||
enabled: true
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_3_7
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.7
|
||||
|
||||
- name: "3.4.3.8 | L1 | PATCH | Ensure nftables rules are permanent"
|
||||
lineinfile:
|
||||
path: /etc/sysconfig/nftables.conf
|
||||
state: present
|
||||
insertafter: EOF
|
||||
line: include "/etc/nftables/inet-{{ rhel9cis_nft_tables_tablename }}"
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
- rhel9cis_rule_3_4_3_8
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_3.4.3.8
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
---
|
||||
|
||||
- name: "3.5 | L1 | PATCH | Ensure wireless interfaces are disabled"
|
||||
block:
|
||||
- name: "3.5 | L1 | AUDIT | Ensure wireless interfaces are disabled | Check if wifi is enabled"
|
||||
shell: nmcli radio wifi
|
||||
args:
|
||||
warn: false
|
||||
register: rhel_09_wifi_enabled
|
||||
changed_when: rhel_09_wifi_enabled.stdout != "disabled"
|
||||
failed_when: false
|
||||
|
||||
- name: "3.5 | L1 | PATCH | Ensure wireless interfaces are disabled | Disable wifi if enabled"
|
||||
shell: nmcli radio all off
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: rhel_09_wifi_enabled is changed
|
||||
when:
|
||||
- '"NetworkManager" in ansible_facts.packages'
|
||||
- rhel9cis_rule_3_5
|
||||
tags:
|
||||
- level1-server
|
||||
- level2-workstation
|
||||
- patch
|
||||
- rule_3.5
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
|
||||
- name: "3.6 | L2 | PATCH | Disable IPv6"
|
||||
replace:
|
||||
dest: /etc/default/grub
|
||||
regexp: '(^GRUB_CMDLINE_LINUX\s*\=\s*)(?:")(.+)(?<!ipv6.disable=1)(?:")'
|
||||
replace: '\1"\2 ipv6.disable=1"'
|
||||
follow: true
|
||||
notify: grub2cfg
|
||||
when:
|
||||
- not rhel9cis_ipv6_required
|
||||
- rhel9cis_rule_3_6
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- patch
|
||||
- rule_3.6
|
||||
Loading…
Add table
Add a link
Reference in a new issue