项目作者: robertdebock

项目描述 :
Apply and/or check recommendations from the CIS benchmarks.
高级语言:
项目地址: git://github.com/robertdebock/ansible-role-cis.git
创建时间: 2020-07-26T19:45:35Z
项目社区:https://github.com/robertdebock/ansible-role-cis

开源协议:Apache License 2.0

下载


Ansible role cis

Apply and/or check recommendations from the CIS benchmarks.

GitHub GitLab Downloads Version
github gitlab downloads Version

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

  1. ---
  2. - name: Converge
  3. hosts: all
  4. become: true
  5. gather_facts: true
  6. vars_files:
  7. - defaults.yml
  8. roles:
  9. - role: robertdebock.cis

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

  1. ---
  2. - name: Prepare
  3. hosts: all
  4. become: true
  5. gather_facts: false
  6. roles:
  7. - role: robertdebock.bootstrap
  8. - role: robertdebock.cron
  9. - role: robertdebock.update

Also see a full explanation and example on how to use these roles.

Role Variables

The default values for the variables are set in defaults/main.yml:

  1. ---
  2. # defaults file for cis
  3. # The CIS guidelines determines many settings of a system. The values used in
  4. # this file will make a system compliant to the CIS specifications.
  5. # There are many reasons why you do not want to adhere to one or more specific
  6. # rules. You can overwrite values in you group_vars, host_vars, inventory or
  7. # playbook.
  8. # 1.1.1.1 Ensure mounting of cramfs filesystems is disabled (Scored)
  9. cis_cramfs_disabled: true
  10. # 1.1.1.2 Ensure mounting of vFAT filesystems is limited (Not Scored)
  11. cis_vfat_disabled: true
  12. # 1.1.1.3 Ensure mounting of squashfs filesystems is disabled (Scored)
  13. cis_squashfs_disabled: true
  14. # 1.1.1.4 Ensure mounting of udf filesystems is disabled (Scored)
  15. cis_udf_disabled: true
  16. # 1.1.2 Ensure /tmp is configured (Scored)
  17. cis_tmp_configured: true
  18. # 1.1.3 Ensure nodev option set on /tmp partition (Scored)
  19. cis_tmp_nodev: true
  20. # 1.1.4 Ensure nosuid option set on /tmp partition (Scored)
  21. cis_tmp_nosuid: true
  22. # 1.1.5 Ensure noexec option set on /tmp partition (Scored)
  23. cis_tmp_noexec: true
  24. # 1.1.6 Ensure separate partition exists for /var (Scored)
  25. cis_var_partition: true
  26. # 1.1.7 Ensure separate partition exists for /var/tmp (Scored)
  27. cis_var_tmp_partition: true
  28. # 1.1.8 Ensure nodev option set on /var/tmp partition (Scored)
  29. cis_var_tmp_nodev: true
  30. # 1.1.9 Ensure nosuid option set on /var/tmp partition (Scored)
  31. cis_var_tmp_nosuid: true
  32. # 1.1.10 Ensure noexec option set on /var/tmp partition (Scored)
  33. cis_var_tmp_noexec: true
  34. # 1.1.11 Ensure separate partition exists for /var/log (Scored)
  35. cis_var_log_partition: true
  36. # 1.1.12 Ensure separate partition exists for /var/log/audit (Scored)
  37. cis_var_log_audit_partition: true
  38. # 1.1.13 Ensure separate partition exists for /home (Scored)
  39. cis_home_partition: true
  40. # 1.1.14 Ensure nodev option set on /home partition (Scored)
  41. cis_home_nodev: true
  42. # 1.1.15 Ensure nodev option set on /dev/shm partition (Scored)
  43. cis_dev_shm_nodev: true
  44. # 1.1.16 Ensure nosuid option set on /dev/shm partition (Scored)
  45. cis_dev_shm_nosuid: true
  46. # 1.1.17 Ensure noexec option set on /dev/shm partition (Scored)
  47. cis_dev_shm_noexec: true
  48. # 1.1.18 Ensure nodev option set on removable media partitions (Not Scored)
  49. cis_removable_media_nodev: true
  50. # 1.1.19 Ensure nosuid option set on removable media partitions (Not Scored)
  51. cis_removable_media_nosuid: true
  52. # 1.1.20 Ensure noexec option set on removable media partitions (Not Scored)
  53. cis_removable_media_noexec: true
  54. # 1.1.21 Ensure sticky bit is set on all world-writable directories (Scored)
  55. cis_fix_sticky_bit: true
  56. # 1.1.22 Disable Automounting
  57. cis_disable_automount: true
  58. # 1.1.23 Disable USB Storage (Scored)
  59. cis_usb_storage_disabled: true
  60. # 1.2.1 Ensure GPG keys are configured (Not Scored)
  61. cis_gpg_keys_configured: true
  62. # 1.2.2 Ensure gpgcheck is globally activated (Scored)
  63. cis_gpgcheck_enabled: true
  64. # 1.2.3 Ensure package manager repositories are configured (Not Scored)
  65. cis_repositories_configured: true
  66. # 1.3.1 Ensure sudo is installed (Scored)
  67. cis_sudo_installed: true
  68. # 1.3.2 Ensure sudo commands use pty (Scored)
  69. cis_sudo_use_pty: true
  70. # 1.3.3 Ensure sudo log file exists (Scored)
  71. cis_sudo_logfile: true
  72. # 1.4.1 Ensure AIDE is installed (Scored)
  73. cis_aide_installed: true
  74. # 1.4.2 Ensure filesystem integrity is regularly checked (Scored)
  75. cis_filesystem_integrity_checked: true
  76. # 1.5.1 Ensure permissions on bootloader config are configured (Scored)
  77. cis_permissions_bootloader: true
  78. # 1.5.2 Ensure bootloader password is set (Scored)
  79. cis_bootloader_password_set: true
  80. cis_bootloader_password: changeme
  81. # 1.5.3 Ensure authentication required for single user mode (Scored)
  82. cis_authentication_single_user_mode: true
  83. # 1.6.1 Ensure core dumps are restricted (Scored)
  84. cis_core_dumps_restricted: true
  85. # 1.6.2 Ensure address space layout randomization (ASLR) is enabled (Scored)
  86. cis_aslr_enabled: true
  87. # 1.7.1.1 Ensure SELinux is installed (Scored)
  88. cis_selinux_installed: true
  89. # 1.7.1.2 Ensure SELinux is not disabled in bootloader configuration (Scored)
  90. cis_selinux_not_disabled: true
  91. # 1.7.1.3 Ensure SELinux policy is configured (Scored)
  92. cis_selinux_policy_configured: true
  93. cis_selinux_policy: targeted
  94. # 1.7.1.4 Ensure the SELinux state is enforcing (Scored)
  95. cis_selinux_state_enforcing: true
  96. # 1.7.1.5 Ensure no unconfined services exist (Scored)
  97. cis_no_unconfined_services: true
  98. # 1.7.1.6 Ensure SETroubleshoot is not installed (Scored)
  99. cis_setroubleshoot_not_installed: true
  100. # 1.7.1.7 Ensure the MCS Translation Service (mcstrans) is not installed (Scored)
  101. cis_mcs_translation_service_not_installed: true
  102. # 1.8.1.1 Ensure message of the day is configured properly (Scored)
  103. cis_message_of_the_day_configured: true
  104. cis_message_of_the_day: |
  105. UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED
  106. You must have explicit, authorized permission to access or configure this device. Unauthorized attempts and actions to access or use this system may result in civil and/or criminal penalties. All activities performed on this device are logged and monitored.
  107. # 1.8.1.2 Ensure local login warning banner is configured properly (Scored)
  108. cis_local_login_banner_configured: true
  109. # 1.8.1.3 Ensure remote login warning banner is configured properly (Scored)
  110. cis_remote_login_banner_configured: true
  111. # 1.8.1.4 Ensure permissions on /etc/motd are configured (Scored)
  112. cis_permissions_etc_motd: true
  113. # 1.8.1.5 Ensure permissions on /etc/issue are configured (Scored)
  114. cis_permissions_etc_issue: true
  115. # 1.8.1.6 Ensure permissions on /etc/issue.net are configured (Scored)
  116. cis_permissions_etc_issue_net: true
  117. # 1.8.2 Ensure GDM login banner is configured (Scored)
  118. cis_gdm_login_banner_configured: true
  119. # 1.9 Ensure updates, patches, and additional security software are installed (Not Scored)
  120. cis_updates_installed: true
  121. # 1.10 Ensure system-wide crypto policy is not legacy (Scored)
  122. cis_crypto_policy_not_legacy: true
  123. cis_crypto_policy: FIPS
  124. # 1.11 Ensure system-wide crypto policy is FUTURE or FIPS (Scored)
  125. cis_ensure_crypto_policy: true
  126. # 2.1.1 Ensure xinetd is not installed (Scored)
  127. cis_xinet_not_installed: true
  128. # 2.2.1.1 Ensure time synchronization is in use (Not Scored)
  129. cis_time_synchronization: true
  130. # 2.2.1.2 Ensure chrony is configured (Scored)
  131. cis_chrony_configured: true
  132. cis_chrony_servers: []
  133. cis_chrony_pools:
  134. - name: "2.fedora.pool.ntp.org"
  135. options: iburst
  136. # 2.2.2 Ensure X Window System is not installed (Scored)
  137. cis_x_windows_system_not_installed: true
  138. # 2.2.3 Ensure rsync service is not enabled (Scored)
  139. cis_rsync_service_not_enabled: true
  140. # 2.2.4 Ensure Avahi Server is not enabled (Scored)
  141. cis_avahi_server_not_enabled: true
  142. # 2.2.5 Ensure SNMP Server is not enabled (Scored)
  143. cis_snmp_server_not_enabled: true
  144. # 2.2.6 Ensure HTTP Proxy Server is not enabled (Scored)
  145. cis_http_proxy_server_not_enabled: true
  146. # 2.2.7 Ensure Samba is not enabled (Scored)
  147. cis_samba_server_not_enabled: true
  148. # 2.2.8 Ensure IMAP and POP3 server is not enabled (Scored)
  149. cis_imap_and_pop3_server_not_enabled: true
  150. # 2.2.9 Ensure HTTP server is not enabled (Scored)
  151. cis_http_server_not_enabled: true
  152. # 2.2.10 Ensure FTP Server is not enabled (Scored)
  153. cis_ftp_server_not_enabled: true
  154. # 2.2.11 Ensure DNS Server is not enabled (Scored)
  155. cis_dns_server_not_enabled: true
  156. # 2.2.12 Ensure NFS is not enabled (Scored)
  157. cis_nfs_server_not_enabled: true
  158. # 2.2.13 Ensure RPC is not enabled (Scored)
  159. cis_rpc_not_enabled: true
  160. # 2.2.14 Ensure LDAP server is not enabled (Scored)
  161. cis_ldap_server_not_enabled: true
  162. # 2.2.15 Ensure DHCP Server is not enabled (Scored)
  163. cis_dhcp_server_not_enabled: true
  164. # 2.2.16 Ensure CUPS is not enabled (Scored)
  165. cis_cups_not_enabled: true
  166. # 2.2.17 Ensure NIS Server is not enabled (Scored)
  167. cis_nis_server_not_enabled: true
  168. # 2.2.18 Ensure mail transfer agent is configured for local-only mode (Scored)
  169. cis_mta_local_only_mode: true
  170. # 2.3.1 Ensure NIS Client is not installed (Scored)
  171. cis_nis_client_not_installed: true
  172. # 2.3.2 Ensure telnet client is not installed (Scored)
  173. cis_telnet_client_not_installed: true
  174. # 2.3.3 Ensure LDAP client is not installed (Scored)
  175. cis_ldap_client_not_installed: true
  176. # 3.1.1 Ensure IP forwarding is disabled (Scored)
  177. cis_ip_forwarding_disabled: true
  178. # 3.1.2 Ensure packet redirect sending is disabled (Scored)
  179. cis_packet_redirect_sending_disabled: true
  180. # 3.2.1 Ensure source routed packets are not accepted (Scored)
  181. cis_source_routed_packets_not_accepted: true
  182. # 3.2.2 Ensure ICMP redirects are not accepted (Scored)
  183. cis_icmp_redirects_not_accepted: true
  184. # 3.2.3 Ensure secure ICMP redirects are not accepted (Scored)
  185. cis_secure_icmp_redirects_not_accepted: true
  186. # 3.2.4 Ensure suspicious packets are logged (Scored)
  187. cis_suspicious_packets_logged: true
  188. # 3.2.5 Ensure broadcast ICMP requests are ignored (Scored)
  189. cis_broadcast_icmp_requests_ignored: true
  190. # 3.2.6 Ensure bogus ICMP responses are ignored (Scored)
  191. cis_bogus_icmp_responses_ignored: true
  192. # 3.2.7 Ensure Reverse Path Filtering is enabled (Scored)
  193. cis_reverse_path_filtering: true
  194. # 3.2.8 Ensure TCP SYN Cookies is enabled (Scored)
  195. cis_tcp_syn_cookies_enabled: true
  196. # 3.2.9 Ensure IPv6 router advertisements are not accepted (Scored)
  197. cis_ipv6_router_advertisements_not_accepted: true
  198. # 3.3.1 Ensure DCCP is disabled (Scored)
  199. cis_dccp_disabled: true
  200. # 3.3.2 Ensure SCTP is disabled (Scored)
  201. cis_sctp_disabled: true
  202. # 3.3.3 Ensure RDS is disabled (Scored)
  203. cis_rds_disabled: true
  204. # 3.3.4 Ensure TIPC is disabled (Scored)
  205. cis_tipc_disabled: true
  206. # 3.4.1.1 Ensure a Firewall package is installed (Scored)
  207. cis_firewall_package_installed: true
  208. cis_firewall_package: firewalld
  209. # 3.4.2.1 Ensure firewalld service is enabled and running (Scored)
  210. cis_firewalld_enabled_and_running: true
  211. # 3.4.2.2 Ensure nftables is not enabled (Scored)
  212. cis_nftables_not_enabled: true
  213. # 3.4.2.3 Ensure default zone is set (Scored)
  214. cis_default_zone_set: true
  215. cis_default_zone: public
  216. # 3.4.2.4 Ensure network interfaces are assigned to appropriate zone (Not Scored)
  217. cis_firewalld_network_interface_assigned_zones: true
  218. cis_firewalld_zone_interface_mapping:
  219. - zone: public
  220. interface: eth0
  221. # 3.4.2.5 Ensure unnecessary services and ports are not accepted (Not Scored)
  222. cis_unnecessary_services_ports_not_accepted: true
  223. cis_unnecessary_services:
  224. - cockpit
  225. cis_unnecessary_ports:
  226. - 12345/tcp
  227. # 3.4.2.6 Ensure iptables is not enabled (Scored)
  228. cis_iptables_not_enabled: true
  229. # 3.4.3 Configure nftables
  230. # This section and all the subsection under 3.4.3 is skipped because section
  231. # 3.4.2 (Configure firewalld) and this section 3.4.3 (Configure nftables) are
  232. # mutually exclusive and firewalld is the default, which uses nft as a backend.
  233. # 3.4.4 Configure iptables
  234. # This section and all the subsection under 3.4.4 is skipped because section
  235. # 3.4.2 (Configure firewalld) and this section 3.4.4 (Configure iptables) are
  236. # mutually exclusive and firewalld is the default, which uses nft as a backend.
  237. # 3.5 Ensure wireless interfaces are disabled (Scored)
  238. cis_wireless_interface_disabled: true
  239. # 3.6 Disable IPv6 (Not Scored)
  240. cis_disable_ipv6: true
  241. # 4.1.1.1 Ensure auditd is installed (Scored)
  242. cis_auditd_installed: true
  243. # 4.1.1.2 Ensure auditd service is enabled (Scored)
  244. cis_auditd_service_enabled: true
  245. # 4.1.1.3 Ensure auditing for processes that start prior to auditd is enabled (Scored)
  246. cis_auditing_processes_prior_start: true
  247. # 4.1.1.4 Ensure audit_backlog_limit is sufficient (Scored)
  248. cis_audit_backlog_limit_sufficient: true
  249. # 4.1.2.1 Ensure audit log storage size is configured (Scored)
  250. cis_audit_log_storage_size_configured: true
  251. cis_audit_log_storage_size: 128
  252. # 4.1.2.2 Ensure audit logs are not automatically deleted (Scored)
  253. cis_audit_logs_no_automatically_deleted: true
  254. # 4.1.2.3 Ensure system is disabled when audit logs are full (Scored)
  255. cis_system_disabled_audit_logs_full: true
  256. # 4.1.3 Ensure changes to system administration scope (sudoers) is collected (Scored)
  257. cis_changed_to_system_administrator_scope_collected: true
  258. # 4.1.4 Ensure login and logout events are collected (Scored)
  259. cis_login_and_login_events_collected: true
  260. # 4.1.5 Ensure session initiation information is collected (Scored)
  261. cis_session_initiation_information_collected: true
  262. # 4.1.6 Ensure events that modify date and time information are collected (Scored)
  263. cis_events_modify_time_and_date_collected: true
  264. # 4.1.7 Ensure events that modify the system's Mandatory Access Controls are collected (Scored)
  265. cis_events_modifying_mac_collected: true
  266. # 4.1.8 Ensure events that modify the system's network environment are collected (Scored)
  267. cis_events_modifying_systems_network_collected: true
  268. # 4.1.9 Ensure discretionary access control permission modification events are collected (Scored)
  269. cis_dac_permission_modification_collected: true
  270. # 4.1.10 Ensure unsuccessful unauthorized file access attempts are collected (Scored)
  271. cis_unsuccessful_files_access_collected: true
  272. # 4.1.11 Ensure events that modify user/group information are collected (Scored)
  273. cis_events_modifying_user_group_collected: true
  274. # 4.1.12 Ensure successful file system mounts are collected (Scored)
  275. cis_successful_mounts_collected: true
  276. # 4.1.13 Ensure use of privileged commands is collected (Scored)
  277. cis_privileged_commands_collected: true
  278. # A list of partitions that will be checked. Extend this with all partitions
  279. # that could contain executables.
  280. cis_privileged_commands_collected_partitions:
  281. - /
  282. # 4.1.14 Ensure file deletion events by users are collected (Scored)
  283. cis_file_deletion_users_collected: true
  284. # 4.1.15 Ensure kernel module loading and unloading is collected (Scored)
  285. cis_kernel_module_loading_unloading_collected: true
  286. # 4.1.16 Ensure system administrator actions (sudolog) are collected (Scored)
  287. cis_system_administrator_actions_collected: true
  288. # 4.1.17 Ensure the audit configuration is immutable (Scored)
  289. cis_audit_configuration_immutable: true
  290. # 4.2.1.1 Ensure rsyslog is installed (Scored)
  291. cis_syslog_installed: true
  292. # 4.2.1.2 Ensure rsyslog Service is enabled (Scored)
  293. cis_rsyslog_enabled: true
  294. # 4.2.1.3 Ensure rsyslog default file permissions configured (Scored)
  295. cis_rsyslog_file_permissions_configured: true
  296. # 4.2.1.4 Ensure logging is configured (Not Scored)
  297. cis_logging_configured: true
  298. cis_logging_site_policy:
  299. - rule: |-
  300. '*.emerg'
  301. destination: |-
  302. ':omusrmsg:*'
  303. - rule: 'auth,authpriv.*'
  304. destination: '/var/log/secure'
  305. - rule: |-
  306. 'mail.*'
  307. destination: '-/var/log/mail'
  308. - rule: 'mail.info'
  309. destination: '-/var/log/mail.info'
  310. - rule: 'mail.warning'
  311. destination: '-/var/log/mail.warn'
  312. - rule: 'mail.err'
  313. destination: '/var/log/mail.err'
  314. - rule: 'news.crit'
  315. destination: '-/var/log/news/news.crit'
  316. - rule: 'news.err'
  317. destination: '-/var/log/news/news.err'
  318. - rule: 'news.notice'
  319. destination: '-/var/log/news/news.notice'
  320. - rule: |-
  321. '*.=warning;*.=err'
  322. destination: '-/var/log/warn'
  323. - rule: |-
  324. '*.crit'
  325. destination: '/var/log/warn'
  326. - rule: |-
  327. '*.*;mail.none;news.none'
  328. destination: '-/var/log/messages'
  329. - rule: |-
  330. 'local0,local1.*'
  331. destination: '-/var/log/localmessages'
  332. - rule: 'local2,local3.*'
  333. destination: '-/var/log/localmessages'
  334. - rule: |-
  335. 'local4,local5.*'
  336. destination: '-/var/log/localmessages'
  337. - rule: |-
  338. 'local6,local7.*'
  339. destination: '-/var/log/localmessages'
  340. # 4.2.1.5 Ensure rsyslog is configured to send logs to a remote log host (Scored)
  341. cis_rsyslog_configured_remote_log_host: true
  342. # 4.2.1.5 Ensure rsyslog is configured to send logs to a remote log host (Scored)
  343. cis_rsyslog_site_policy_host: loghost.example.com
  344. # 4.2.1.6 Ensure remote rsyslog messages are only accepted on designated log hosts. (Not Scored)
  345. # This item is not implemented because it would need to run on another host.
  346. # 4.2.2.1 Ensure journald is configured to send logs to rsyslog (Scored)
  347. cis_journald_send_to_rsyslog: true
  348. # 4.2.2.2 Ensure journald is configured to compress large log files (Scored)
  349. cis_journald_compless_log_files: true
  350. # 4.2.2.3 Ensure journald is configured to write logfiles to persistent disk (Scored)
  351. cis_journald_write_logfiles_to_disk: true
  352. # 4.2.3 Ensure permissions on all logfiles are configured (Scored)
  353. cis_permissions_on_logfiles: true
  354. # 4.3 Ensure logrotate is configured (Not Scored)
  355. cis_logrotate_configured: true
  356. cis_logrotate_policy:
  357. - name: dnf
  358. # 5.1.1 Ensure cron daemon is enabled (Scored)
  359. cis_cron_enabled: true
  360. # 5.1.2 Ensure permissions on /etc/crontab are configured (Scored)
  361. cis_cron_permissions_configured: true
  362. # 5.1.3 Ensure permissions on /etc/cron.hourly are configured (Scored)
  363. cis_cron_hourly_permissions_configured: true
  364. # 5.1.4 Ensure permissions on /etc/cron.daily are configured (Scored)
  365. cis_cron_daily_permissions_configured: true
  366. # 5.1.5 Ensure permissions on /etc/cron.weekly are configured (Scored)
  367. cis_cron_weekly_permissions_configured: true
  368. # 5.1.6 Ensure permissions on /etc/cron.monthly are configured (Scored)
  369. cis_cron_monthly_permissions_configured: true
  370. # 5.1.7 Ensure permissions on /etc/cron.d are configured (Scored)
  371. cis_cron_d_permissions_configured: true

Requirements

State of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab
robertdebock.bootstrap Build Status GitHub Build Status GitLab
robertdebock.cron Build Status GitHub Build Status GitLab
robertdebock.update Build Status GitHub Build Status GitLab

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles:
dependencies

Compatibility

This role has been tested on these container images:

container tags
EL 9

The minimum version of Ansible required is 2.12, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub.

License

Apache-2.0.

Author Information

robertdebock

Please consider sponsoring me.