2022-01-07 09:06:18 +00:00
|
|
|
---
|
|
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured"
|
2022-01-07 09:06:18 +00:00
|
|
|
block:
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured | INPUT Loopback ACCEPT"
|
2022-01-07 09:06:18 +00:00
|
|
|
iptables:
|
|
|
|
|
action: append
|
|
|
|
|
chain: INPUT
|
|
|
|
|
in_interface: lo
|
|
|
|
|
jump: ACCEPT
|
|
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured | OUTPUT Loopback ACCEPT"
|
2022-01-07 09:06:18 +00:00
|
|
|
iptables:
|
|
|
|
|
action: append
|
|
|
|
|
chain: OUTPUT
|
|
|
|
|
out_interface: lo
|
|
|
|
|
jump: ACCEPT
|
|
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.1 | PATCH | Ensure iptables loopback traffic is configured | INPUT Loopback 127.0.0.0/8"
|
2022-01-07 09:06:18 +00:00
|
|
|
iptables:
|
|
|
|
|
action: append
|
|
|
|
|
chain: INPUT
|
|
|
|
|
source: 127.0.0.0/8
|
|
|
|
|
jump: DROP
|
|
|
|
|
when:
|
2022-03-30 16:18:11 +01:00
|
|
|
- rhel9cis_rule_3_4_3_2_1
|
2022-01-07 09:06:18 +00:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
2022-03-30 16:18:11 +01:00
|
|
|
- automated
|
2022-01-07 09:06:18 +00:00
|
|
|
- patch
|
2022-03-30 16:18:11 +01:00
|
|
|
- iptables
|
|
|
|
|
- rule_3.4.3.2.1
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.2 | PATCH | Ensure iptables outbound and established connections are configured"
|
2022-01-07 09:06:18 +00:00
|
|
|
iptables:
|
|
|
|
|
action: append
|
|
|
|
|
chain: '{{ item.chain }}'
|
|
|
|
|
protocol: '{{ item.protocol }}'
|
|
|
|
|
match: state
|
|
|
|
|
ctstate: '{{ item.ctstate }}'
|
|
|
|
|
jump: ACCEPT
|
|
|
|
|
with_items:
|
|
|
|
|
- { chain: OUTPUT, protocol: tcp, ctstate: 'NEW,ESTABLISHED' }
|
|
|
|
|
- { chain: OUTPUT, protocol: udp, ctstate: 'NEW,ESTABLISHED' }
|
|
|
|
|
- { chain: OUTPUT, protocol: icmp, ctstate: 'NEW,ESTABLISHED' }
|
|
|
|
|
- { chain: INPUT, protocol: tcp, ctstate: ESTABLISHED }
|
|
|
|
|
- { chain: INPUT, protocol: udp, ctstate: ESTABLISHED }
|
|
|
|
|
- { chain: INPUT, protocol: icmp, ctstate: ESTABLISHED }
|
|
|
|
|
when:
|
2022-03-30 16:18:11 +01:00
|
|
|
- rhel9cis_rule_3_4_3_2_2
|
2022-01-07 09:06:18 +00:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
2022-03-30 16:18:11 +01:00
|
|
|
- manual
|
2022-01-07 09:06:18 +00:00
|
|
|
- patch
|
2022-03-30 16:18:11 +01:00
|
|
|
- iptables
|
|
|
|
|
- rule_3.4.3.2.2
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.3 | PATCH | Ensure iptables rules exist for all open ports"
|
2022-01-07 09:06:18 +00:00
|
|
|
block:
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.3 | AUDIT | Ensure iptables rules exist for all open ports | Get list of TCP open ports"
|
2022-01-07 09:06:18 +00:00
|
|
|
shell: netstat -ant |grep "tcp.*LISTEN" | awk '{ print $4 }'| sed 's/.*://'
|
|
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
2022-03-30 16:18:11 +01:00
|
|
|
register: rhel9cis_3_4_3_2_3_otcp
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.3 | AUDIT | Ensure iptables rules exist for all open ports | Get the list of udp open ports"
|
2022-01-07 09:06:18 +00:00
|
|
|
shell: netstat -ant |grep "udp.*LISTEN" | awk '{ print $4 }'| sed 's/.*://'
|
|
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
2022-03-30 16:18:11 +01:00
|
|
|
register: rhel9cis_3_4_3_2_3_oudp
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.3 | PATCH | Ensure iptables rules exist for all open ports | Adjust open tcp ports"
|
2022-01-07 09:06:18 +00:00
|
|
|
iptables:
|
|
|
|
|
action: append
|
|
|
|
|
chain: INPUT
|
|
|
|
|
protocol: tcp
|
|
|
|
|
destination_port: "{{ item }}"
|
|
|
|
|
match: state
|
|
|
|
|
ctstate: NEW
|
|
|
|
|
jump: ACCEPT
|
|
|
|
|
with_items:
|
2022-03-30 16:18:11 +01:00
|
|
|
- "{{ rhel9cis_3_4_3_2_3_otcp.stdout_lines }}"
|
|
|
|
|
when: rhel9cis_3_4_3_2_3_otcp.stdout is defined
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.3 | PATCH | Ensure iptables rules exist for all open ports | Adjust open udp ports"
|
2022-01-07 09:06:18 +00:00
|
|
|
iptables:
|
|
|
|
|
action: append
|
|
|
|
|
chain: INPUT
|
|
|
|
|
protocol: udp
|
|
|
|
|
destination_port: "{{ item }}"
|
|
|
|
|
match: state
|
|
|
|
|
ctstate: NEW
|
|
|
|
|
jump: ACCEPT
|
|
|
|
|
with_items:
|
2022-03-30 16:18:11 +01:00
|
|
|
- "{{ rhel9cis_3_4_3_2_3_oudp.stdout_lines }}"
|
|
|
|
|
when: rhel9cis_3_4_3_2_3_otcp.stdout is defined
|
|
|
|
|
when:
|
|
|
|
|
- rhel9cis_rule_3_4_3_2_3
|
|
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- automated
|
|
|
|
|
- patch
|
|
|
|
|
- iptables
|
|
|
|
|
- rule_3.4.3.2.3
|
|
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
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
|
2022-01-07 09:06:18 +00:00
|
|
|
when:
|
2022-03-30 16:18:11 +01:00
|
|
|
- rhel9cis_rule_3_4_3_2_5
|
2022-01-07 09:06:18 +00:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
2022-03-30 16:18:11 +01:00
|
|
|
- automated
|
2022-01-07 09:06:18 +00:00
|
|
|
- patch
|
2022-03-30 16:18:11 +01:00
|
|
|
- iptables
|
|
|
|
|
- rule_3.4.3.2.5
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2022-03-30 16:18:11 +01:00
|
|
|
- name: "3.4.3.2.6 | PATCH | Ensure iptables service is enabled and active"
|
2022-01-07 09:06:18 +00:00
|
|
|
service:
|
|
|
|
|
name: iptables
|
2022-03-30 16:18:11 +01:00
|
|
|
enabled: yes
|
2022-01-07 09:06:18 +00:00
|
|
|
state: started
|
|
|
|
|
when:
|
2022-03-30 16:18:11 +01:00
|
|
|
- rhel9cis_rule_3_4_3_2_6
|
2022-01-07 09:06:18 +00:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
2022-03-30 16:18:11 +01:00
|
|
|
- automated
|
2022-01-07 09:06:18 +00:00
|
|
|
- patch
|
2022-03-30 16:18:11 +01:00
|
|
|
- iptables
|
|
|
|
|
- rule_3.4.3.2.6
|