2015-05-26 19:53:55 +00:00
|
|
|
---
|
2021-03-25 12:52:56 +00:00
|
|
|
- name: Remove suid/sgid bit from binaries in blacklist | os-06
|
2023-01-24 11:40:27 +00:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
mode: a-s
|
|
|
|
state: file
|
|
|
|
follow: true
|
2016-05-19 16:56:14 +00:00
|
|
|
failed_when: false
|
2022-08-26 11:44:51 +00:00
|
|
|
with_community.general.flattened:
|
2023-01-24 11:40:27 +00:00
|
|
|
- "{{ os_security_suid_sgid_system_blacklist }}"
|
|
|
|
- "{{ os_security_suid_sgid_blacklist }}"
|
2015-05-26 19:53:55 +00:00
|
|
|
|
2021-03-25 12:52:56 +00:00
|
|
|
- name: Find binaries with suid/sgid set | os-06
|
2023-01-24 11:40:27 +00:00
|
|
|
ansible.builtin.shell: find / -xdev \( -perm -4000 -o -perm -2000 \) -type f ! -path '/proc/*' -print 2>/dev/null
|
2015-05-31 15:51:57 +00:00
|
|
|
register: sbit_binaries
|
2019-06-06 09:45:04 +00:00
|
|
|
when: os_security_suid_sgid_remove_from_unknown | bool
|
2020-08-22 06:53:44 +00:00
|
|
|
changed_when: false
|
2015-05-31 15:51:57 +00:00
|
|
|
|
2021-03-25 12:52:56 +00:00
|
|
|
- name: Gather files from which to remove suids/sgids and remove system white-listed files | os-06
|
2023-01-24 11:40:27 +00:00
|
|
|
ansible.builtin.set_fact:
|
|
|
|
suid: "{{ sbit_binaries.stdout_lines | difference(os_security_suid_sgid_system_whitelist) }}"
|
2019-06-06 09:45:04 +00:00
|
|
|
when: os_security_suid_sgid_remove_from_unknown | bool
|
2015-05-31 15:51:57 +00:00
|
|
|
|
2021-03-25 12:52:56 +00:00
|
|
|
- name: Remove suid/sgid bit from all binaries except in system and user whitelist | os-06
|
2023-01-24 11:40:27 +00:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
mode: a-s
|
|
|
|
state: file
|
|
|
|
follow: true
|
2022-08-26 11:44:51 +00:00
|
|
|
with_community.general.flattened:
|
2023-01-24 11:40:27 +00:00
|
|
|
- "{{ suid | default([]) | difference(os_security_suid_sgid_whitelist) }}"
|
2019-06-06 09:45:04 +00:00
|
|
|
when: os_security_suid_sgid_remove_from_unknown | bool
|