mirror of
https://github.com/ansible-lockdown/RHEL9-CIS.git
synced 2025-12-27 15:33:06 +00:00
added uid discovery and usage
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
375847536b
commit
113d422dd4
5 changed files with 49 additions and 22 deletions
|
|
@ -546,8 +546,12 @@ rhel9cis_pam_password:
|
||||||
minlen: "14"
|
minlen: "14"
|
||||||
minclass: "4"
|
minclass: "4"
|
||||||
|
|
||||||
# Starting GID for interactive users
|
# UID settings for interactive users
|
||||||
rhel9cis_int_gid: 1000
|
# These are discovered via logins.def is set true
|
||||||
|
discover_int_uid: false
|
||||||
|
min_int_uid: 1000
|
||||||
|
max_int_uid: 65533
|
||||||
|
|
||||||
|
|
||||||
# RHEL-09-5.4.5
|
# RHEL-09-5.4.5
|
||||||
# Session timeout setting file (TMOUT setting can be set in multiple files)
|
# Session timeout setting file (TMOUT setting can be set in multiple files)
|
||||||
|
|
|
||||||
|
|
@ -190,3 +190,26 @@
|
||||||
tags:
|
tags:
|
||||||
- rule_1.2.2
|
- rule_1.2.2
|
||||||
- skip_ansible_lint
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: "PRELIM | AUDIT | Discover Interactive UID MIN and MIN from logins.def"
|
||||||
|
block:
|
||||||
|
- name: "PRELIM | AUDIT | Capture UID_MIN information from logins.def"
|
||||||
|
shell: grep -w "^UID_MIN" /etc/login.defs | awk '{print $NF}'
|
||||||
|
register: uid_min_id
|
||||||
|
|
||||||
|
- name: "PRELIM | AUDIT | Capture UID_MAX information from logins.def"
|
||||||
|
shell: grep -w "^UID_MAX" /etc/login.defs | awk '{print $NF}'
|
||||||
|
register: uid_max_id
|
||||||
|
|
||||||
|
- name: "PRELIM | AUDIT | Capture GID_MIN information from logins.def"
|
||||||
|
shell: grep -w "^GID_MIN" /etc/login.defs | awk '{print $NF}'
|
||||||
|
register: gid_min_id
|
||||||
|
|
||||||
|
- name: "PRELIM | AUDIT | set_facts for interactive uid/gid"
|
||||||
|
set_fact:
|
||||||
|
min_int_uid: uid_min_id.stdout
|
||||||
|
max_int_uid: uid_max_id.stdout
|
||||||
|
|
||||||
|
when:
|
||||||
|
- not discover_int_uid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
- item.id != "sync"
|
- item.id != "sync"
|
||||||
- item.id != "shutdown"
|
- item.id != "shutdown"
|
||||||
- item.id != "halt"
|
- item.id != "halt"
|
||||||
- item.gid < rhel9cis_int_gid
|
- item.gid < min_int_uid
|
||||||
- item.shell != " /bin/false"
|
- item.shell != " /bin/false"
|
||||||
- item.shell != " /usr/sbin/nologin"
|
- item.shell != " /usr/sbin/nologin"
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
- item.id != "shutdown"
|
- item.id != "shutdown"
|
||||||
- item.id != "sync"
|
- item.id != "sync"
|
||||||
- item.id != "root"
|
- item.id != "root"
|
||||||
- item.gid < rhel9cis_int_gid
|
- item.gid < min_int_uid
|
||||||
- item.shell != " /bin/false"
|
- item.shell != " /bin/false"
|
||||||
- item.shell != " /usr/sbin/nologin"
|
- item.shell != " /usr/sbin/nologin"
|
||||||
when:
|
when:
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@
|
||||||
- name: "6.2.7 | L1 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive"
|
- name: "6.2.7 | L1 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive"
|
||||||
stat:
|
stat:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', rhel9cis_int_gid) | selectattr('uid', '!=', 65534) | map(attribute='dir') | list }}"
|
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid) | selectattr('uid', '!=', max_int_uid) | map(attribute='dir') | list }}"
|
||||||
register: rhel_09_6_2_7_audit
|
register: rhel_09_6_2_7_audit
|
||||||
|
|
||||||
- name: "6.2.7 | L1 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive"
|
- name: "6.2.7 | L1 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive"
|
||||||
|
|
@ -204,7 +204,7 @@
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ rhel9cis_passwd_label }}"
|
label: "{{ rhel9cis_passwd_label }}"
|
||||||
when:
|
when:
|
||||||
- item.uid >= rhel9cis_int_gid
|
- item.uid >= min_int_uid
|
||||||
- rhel9cis_rule_6_2_8
|
- rhel9cis_rule_6_2_8
|
||||||
tags:
|
tags:
|
||||||
- skip_ansible_lint # settings found on 6_2_7
|
- skip_ansible_lint # settings found on 6_2_7
|
||||||
|
|
@ -500,7 +500,7 @@
|
||||||
stat:
|
stat:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
register: rhel_09_6_2_20_audit
|
register: rhel_09_6_2_20_audit
|
||||||
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', rhel9cis_int_gid) | selectattr('uid', '!=', 65534) | map(attribute='dir') | list }}"
|
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid) | selectattr('uid', '!=', max_int_uid) | map(attribute='dir') | list }}"
|
||||||
|
|
||||||
- name: "6.2.20 | L1 | AUDIT | Ensure all users' home directories exist"
|
- name: "6.2.20 | L1 | AUDIT | Ensure all users' home directories exist"
|
||||||
shell: find -H {{ item.0 | quote }} -not -type l -perm /027
|
shell: find -H {{ item.0 | quote }} -not -type l -perm /027
|
||||||
|
|
|
||||||
|
|
@ -32,18 +32,18 @@
|
||||||
-w /etc/sysconfig/network -p wa -k system-locale
|
-w /etc/sysconfig/network -p wa -k system-locale
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rhel9cis_rule_4_1_9 %}
|
{% if rhel9cis_rule_4_1_9 %}
|
||||||
-a always,exit -F arch=b32 -S chmod -S fchmod -S fchmodat -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k perm_mod
|
-a always,exit -F arch=b32 -S chmod -S fchmod -S fchmodat -F auid>={{ min_int_uid }} -F auid!=4294967295 -k perm_mod
|
||||||
-a always,exit -F arch=b32 -S chown -S fchown -S fchownat -S lchown -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k perm_mod
|
-a always,exit -F arch=b32 -S chown -S fchown -S fchownat -S lchown -F auid>={{ min_int_uid }} -F auid!=4294967295 -k perm_mod
|
||||||
-a always,exit -F arch=b32 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k perm_mod
|
-a always,exit -F arch=b32 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -F auid>={{ min_int_uid }} -F auid!=4294967295 -k perm_mod
|
||||||
-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k perm_mod
|
-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -F auid>={{ min_int_uid }} -F auid!=4294967295 -k perm_mod
|
||||||
-a always,exit -F arch=b64 -S chown -S fchown -S fchownat -S lchown -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k perm_mod
|
-a always,exit -F arch=b64 -S chown -S fchown -S fchownat -S lchown -F auid>={{ min_int_uid }} -F auid!=4294967295 -k perm_mod
|
||||||
-a always,exit -F arch=b64 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k perm_mod
|
-a always,exit -F arch=b64 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -F auid>={{ min_int_uid }} -F auid!=4294967295 -k perm_mod
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rhel9cis_rule_4_1_10 %}
|
{% if rhel9cis_rule_4_1_10 %}
|
||||||
-a always,exit -F arch=b32 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EACCES -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -F key=access
|
-a always,exit -F arch=b32 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EACCES -F auid>={{ min_int_uid }} -F auid!=4294967295 -F key=access
|
||||||
-a always,exit -F arch=b32 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EPERM -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -F key=access
|
-a always,exit -F arch=b32 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EPERM -F auid>={{ min_int_uid }} -F auid!=4294967295 -F key=access
|
||||||
-a always,exit -F arch=b64 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EACCES -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -F key=access
|
-a always,exit -F arch=b64 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EACCES -F auid>={{ min_int_uid }} -F auid!=4294967295 -F key=access
|
||||||
-a always,exit -F arch=b64 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EPERM -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -F key=access
|
-a always,exit -F arch=b64 -S creat,open,openat,open_by_handle_at,truncate,ftruncate -F exit=-EPERM -F auid>={{ min_int_uid }} -F auid!=4294967295 -F key=access
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rhel9cis_rule_4_1_11 %}
|
{% if rhel9cis_rule_4_1_11 %}
|
||||||
-w /etc/group -p wa -k identity
|
-w /etc/group -p wa -k identity
|
||||||
|
|
@ -53,17 +53,17 @@
|
||||||
-w /etc/security/opasswd -p wa -k identity
|
-w /etc/security/opasswd -p wa -k identity
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rhel9cis_rule_4_1_12 %}
|
{% if rhel9cis_rule_4_1_12 %}
|
||||||
-a always,exit -F arch=b32 -S mount -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k mounts
|
-a always,exit -F arch=b32 -S mount -F auid>={{ min_int_uid }} -F auid!=4294967295 -k mounts
|
||||||
-a always,exit -F arch=b64 -S mount -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k mounts
|
-a always,exit -F arch=b64 -S mount -F auid>={{ min_int_uid }} -F auid!=4294967295 -k mounts
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rhel9cis_rule_4_1_13 %}
|
{% if rhel9cis_rule_4_1_13 %}
|
||||||
{% for proc in priv_procs.stdout_lines -%}
|
{% for proc in priv_procs.stdout_lines -%}
|
||||||
-a always,exit -F path={{ proc }} -F perm=x -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -k privileged
|
-a always,exit -F path={{ proc }} -F perm=x -F auid>={{ min_int_uid }} -F auid!=4294967295 -k privileged
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rhel9cis_rule_4_1_14 %}
|
{% if rhel9cis_rule_4_1_14 %}
|
||||||
-a always,exit -F arch=b32 -S rmdir,unlink,unlinkat,rename -S renameat -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -F key=delete
|
-a always,exit -F arch=b32 -S rmdir,unlink,unlinkat,rename -S renameat -F auid>={{ min_int_uid }} -F auid!=4294967295 -F key=delete
|
||||||
-a always,exit -F arch=b64 -S rmdir,unlink,unlinkat,rename -S renameat -F auid>={{ rhel9cis_int_gid }} -F auid!=4294967295 -F key=delete
|
-a always,exit -F arch=b64 -S rmdir,unlink,unlinkat,rename -S renameat -F auid>={{ min_int_uid }} -F auid!=4294967295 -F key=delete
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rhel9cis_rule_4_1_15 %}
|
{% if rhel9cis_rule_4_1_15 %}
|
||||||
-w /usr/sbin/insmod -p x -k modules
|
-w /usr/sbin/insmod -p x -k modules
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue