Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing issue 38 #41

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9add2e8
Update ChangeLog and Typo Fix
frederickw082922 Feb 20, 2024
a99532e
Update 18.3.5 and 18.3.6 var Fix
frederickw082922 Feb 21, 2024
761cc16
Typo fix on 5.1|5.2 tag
frederickw082922 Feb 21, 2024
08bf9b6
Added missing GUID on 18.10.43.6.1.2
frederickw082922 Feb 21, 2024
9be1a1b
#27 Update correct reg value 18.6.4.3
frederickw082922 Feb 21, 2024
fed12f5
#28 update reg value fix for 18.10.43.10.2
frederickw082922 Feb 21, 2024
b4e91fd
Update ChangeLog
frederickw082922 Feb 21, 2024
604d05c
Update correct reg value for 18.7.10|11
frederickw082922 Feb 21, 2024
6984fda
Update ChangeLog based on PR26 by ai13f
frederickw082922 Feb 21, 2024
3de68cc
18.7.x Tag fixes
frederickw082922 Mar 12, 2024
b20e15c
Update cloud_lockout logic
frederickw082922 Mar 14, 2024
827a411
Update section 19 with loop and change_requires_reboot
frederickw082922 Mar 14, 2024
2e231ce
Update handeler name to change_requires_reboot
frederickw082922 Mar 15, 2024
59bdd87
Fix 18.9.7.2 title and var
frederickw082922 Mar 15, 2024
5753ed9
Fix 18.10.89.2.2 reg value
frederickw082922 Mar 15, 2024
45ef655
Update meta
frederickw082922 Mar 18, 2024
3ab4ad9
defaults main var update
frederickw082922 Mar 18, 2024
f6db5a1
update section5 with handeler name chance
frederickw082922 Mar 18, 2024
5346645
update win_skip_for_test withe latest controls
frederickw082922 Mar 18, 2024
07db42a
update changelog
frederickw082922 Mar 19, 2024
df54e82
Update ChangeLog with @Mr.Steve81
frederickw082922 Mar 19, 2024
84cd0bb
Typo Fixes
frederickw082922 Mar 19, 2024
edf3099
Only applies to Azure
mfortin Mar 21, 2024
03c757c
Update control 1.1.6
mfortin Mar 25, 2024
511f0b9
Fixing controls stated in issue 38
mfortin Mar 26, 2024
5f5fe3e
revert
mfortin Mar 26, 2024
b757f92
Addressing issue #36
mfortin Mar 26, 2024
a19e2be
test
mfortin Mar 26, 2024
731b9c2
test
mfortin Mar 26, 2024
ffa0705
Fix from #32
frederickw082922 Apr 1, 2024
243e901
Update ChangeLog with fix for #32
frederickw082922 Apr 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# ChangeLog

## Release 1.0.0
## Release 2.0.1

April 2024 Update
Thank you @RomainPisters
- Fix from Issue #32

March 2024 Update
Thank you @MrSteve81 for the enhancements to this release!
- Improved 19.x section logic for Windows local user SIDs and HKU support.
- Reboot handler and logic Improvement with skip_reboot var feature.
- win_skip_for_test var update with additional description and supported controls of 2.2.20, 2.2.25, and 2.2.26.
- Mislabeled control fix for win22cis_rule_18_9_7_2
- Improved logic for win22cis_cloud_based_system 1.2.x controls.

February 2024 Update
- Issues Addressed:
- [#27](https://github.com/ansible-lockdown/Windows-2022-CIS/issues/27) - Thank you @SwaffelSmurf
- [#28](https://github.com/ansible-lockdown/Windows-2022-CIS/issues/28) - Thank you @natilik-mikeguy
- [PR26](https://github.com/ansible-lockdown/Windows-2022-CIS/pull/26) - Thank you @ai13f
- Typo and bug fixes

## Release 2.0.0

September 2023
- This Release is based on CIS Benchmark v2.0.0
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 MindPoint Group / Lockdown Enterprise
Copyright (c) 2024 MindPoint Group / Lockdown Enterprise

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
48 changes: 30 additions & 18 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,11 @@ min_ansible_version: "2.10"
# may fail in some cases.
complexity_high: true

# Show "changed" for complex items not remediated per complexity-high setting
# to make them stand out. "changed" items on a second run of the role would
# indicate items requiring manual review.
audit_complex: true

# We've defined disruption-high to indicate items that are likely to cause
# disruption in a normal workflow. These items can be remediated automatically
# but are disabled by default to avoid disruption.
disruption_high: false

# Show "changed" for disruptive items not remediated per disruption-high
# setting to make them stand out.
audit_disruptive: false

# Tweak role to run in a non-privileged container
system_is_container: false

Expand All @@ -60,16 +51,23 @@ long_running: false
# win_skip_for_test is used in the playbook to skip over WINRM-based controls that
# may cause WINRM Basic Connection Type to be disabled.
# Setting win_skip_for_test to 'false' will enable Secure Connection types only.
# win22cis_rule_2_3_1_4
# win22cis_rule_9_3_5
# win22cis_rule_18_10_89_1_1
# win22cis_rule_18_10_89_1_2
# win22cis_rule_18_10_89_2_1
# win22cis_rule_18_10_89_2_2
# win22cis_rule_18_10_89_2_3
# win22cis_rule_18_10_90_1
# win22cis_rule_2_2_25 - Breaks Local Admin Connection
# win22cis_rule_2_2_26 - Breaks Local Admin Connection
# win22cis_rule_2_3_1_4 - Rename default administrator account
# win22cis_rule_9_3_5 - Enables Firewall Public Rules *Breaks Reboot*
# win22cis_rule_18_10_89_1_1 - Disables WinRM Allow Client Basic Auth
# win22cis_rule_18_10_89_1_2 - Disables Client Ensure Allow unencrypted traffic is set to Disabled Control.
# win22cis_rule_18_10_89_2_1 - Disables WinRM Allow Service Basic Auth
# win22cis_rule_18_10_89_2_2 - Disables Remote Server Management through WinRM
# win22cis_rule_18_10_89_2_3 - Disables Service Ensure Allow unencrypted traffic is set to Disabled Control.
# win22cis_rule_18_10_90_1 - Disables Remote Shell Access
win_skip_for_test: true

# Changes will be made that will require a system reboot.
# The following option will allow whether or not to skip the reboot.
# Default: true
skip_reboot: true

# These variables correspond with the CIS Rule IDs defined in the CIS and allow you to enable/disable specific rules.
# PLEASE NOTE: These work in coordination with the level1 and level2 group variables. You must enable an entire group
# in order for the variables below to take effect.
Expand Down Expand Up @@ -118,6 +116,8 @@ win22cis_rule_2_2_21: true
win22cis_rule_2_2_22: true
win22cis_rule_2_2_23: true
win22cis_rule_2_2_24: true
# Setting win22cis_rule_2_2_25 and win22cis_rule_2_2_26 Control To True Will Break Ansible Connection
# Setting win_skip_for_test: true -- will skip the controls here even if they are set to true.
win22cis_rule_2_2_25: true
win22cis_rule_2_2_26: true
win22cis_rule_2_2_27: true
Expand Down Expand Up @@ -355,7 +355,7 @@ win22cis_rule_18_9_5_4: true
win22cis_rule_18_9_5_5: true
win22cis_rule_18_9_5_6: true
win22cis_rule_18_9_5_7: true
win22cis_rule_18_8_7_2: true
win22cis_rule_18_9_7_2: true
win22cis_rule_18_9_13_1: true
win22cis_rule_18_9_19_2: true
win22cis_rule_18_9_19_3: true
Expand Down Expand Up @@ -709,6 +709,18 @@ win22cis_public_firewall_log_size: 16384

# Section 18 Variables

# 18.3.5
# win22cis_laps_password_length is the LAPS tool password length.
# The recommended state for this setting is: Enabled: 15 or more.
# Default: 15
win22cis_laps_password_length: 15

# 18.3.6
# win22cis_laps_password_age_days is the LAPS tool password age in days.
# The recommended state for this setting is: Enabled: 30 or fewer.
# Default: 30
win22cis_laps_password_age_days: 30

# 18.4.6
# win22cis_netbt_nodetype is the node type value in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters:NodeType
# Options are a B-node value of 1, P-node value of 2, M-node value of 4, and H-node value of 8. P-node is the recommended setting from CIS
Expand Down
8 changes: 5 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---

- name: reboot_windows
ansible.windows.win_reboot:
reboot_timeout: 3600
- name: change_requires_reboot
ansible.builtin.set_fact:
reboot_host: true
tags:
- always
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

galaxy_info:
author: "George Nalen, Mark Bolwell, Stephen Williams, Frederick Witty Jr."
author: "Stephen Williams, Frederick Witty Jr."
description: "Ansible role to apply Windows Server 2022 CIS Benchmark"
company: "MindPoint Group"
license: MIT
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
ansible.builtin.import_tasks:
file: section18.yml
when:
- win22cis_section17
- win22cis_section18
tags:
- section18

Expand Down
36 changes: 36 additions & 0 deletions tasks/post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---

- name: "POST | Flush Handlers"
ansible.builtin.meta: flush_handlers
tags:
- always

- name: "POST | Reboot System Options"
block:
- name: "POST | Rebooting System................. Skip Reboot Has Been Set To: False"
ansible.windows.win_reboot:
reboot_timeout: 3600
when:
- reboot_host
- not skip_reboot

- name: "POST | Warning A Reboot Is Required, Skip Reboot Has Been Set"
ansible.builtin.debug:
msg:
- "Warning!! Changes Have Been Made That Require A Reboot To Be Implemented Manually."
- "Skip Reboot Was Set To: True - This Can Affect Compliance Check Results."
changed_when: true
when:
- reboot_host
- skip_reboot

- name: "POST | Warning A Reboot Is Required, Skip Reboot Has Been Set | Warning Count"
ansible.builtin.import_tasks:
file: warning_facts.yml
when:
- reboot_host
- skip_reboot
vars:
warn_control_id: Reboot_Required
tags:
- always
38 changes: 38 additions & 0 deletions tasks/prelim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
ansible.builtin.set_fact:
win22cis_cloud_based_system: true
when:
- ansible_system_vendor == 'Microsoft Corporation'
- ansible_virtualization_type == 'Hyper-V' or
ansible_virtualization_type == 'hvm' or
ansible_virtualization_type == 'kvm'
Expand All @@ -49,3 +50,40 @@
windows_installation_type: "{{ get_windows_installation_type.value | default('') }}"
tags:
- always


- name: PRELIM | Retrieve Default NTUSER and All Local User Hive Data
block:
- name: PRELIM | Load Default User Hive (Account That All New Users Get Created From Profile)
ansible.windows.win_shell: REG LOAD HKU\DEFAULT C:\Users\Default\NTUSER.DAT
changed_when: false
failed_when: false

- name: PRELIM | Pull All Username and SIDs
ansible.windows.win_shell: Get-CimInstance -Class Win32_UserAccount -Filter "SID LIKE 'S-1-5-%'" | ForEach-Object { $_.Name + " " + $_.SID }
changed_when: false
failed_when: false
register: all_users

- name: PRELIM | Create Results List Fact For Username And SIDs
ansible.builtin.set_fact:
username_and_sid_results_list: "{{ all_users.stdout_lines | map('split', ' ') | list }}"

- name: PRELIM | Load All User Hives From Username And SIDs List
ansible.windows.win_shell: REG LOAD HKU\{{ item.1 }} C:\Users\{{ item.0 }}\NTUSER.DAT
changed_when: false
failed_when: false
loop: "{{ username_and_sid_results_list }}"

- name: PRELIM | Retrieve Current Users SIDs from HKEY_USERS
ansible.windows.win_shell: (Get-ChildItem "REGISTRY::HKEY_USERS").name | Where-Object {$_ -notlike "*_classes"}
changed_when: false
failed_when: false
register: current_users_loaded_hku

- name: PRELIM | Create List Fact For Current Users SIDs from HKEY_USERS
ansible.builtin.set_fact:
hku_loaded_list: "{{ current_users_loaded_hku.stdout | regex_replace('HKEY_USERS\\\\','') | split }}"
when: win22cis_section19
tags:
- always
30 changes: 11 additions & 19 deletions tasks/section01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@
- password

- name: "1.1.6 | PATCH | Ensure Relax minimum password length limits is set to Enabled."
community.windows.win_security_policy:
section: System Access
key: RelaxMinimumPasswordLengthLimits
value: 1
ansible.windows.win_regedit:
path: HKLM:\System\CurrentControlSet\Control\SAM
name: RelaxMinimumPasswordLengthLimits
data: 1
type: dword
when:
- win22cis_rule_1_1_6
tags:
Expand Down Expand Up @@ -190,9 +191,7 @@
ansible.builtin.import_tasks:
file: section01_cloud_lockout_order.yml
when:
- win22cis_cloud_based_system or
win2022cis_is_domain_controller or
win2022cis_is_domain_member
- win22cis_cloud_based_system
tags:
- section01_cloud_lockout_order

Expand Down Expand Up @@ -228,9 +227,7 @@
- win22cis_bad_login_lockout_count > 0
when:
- win22cis_rule_1_2_2
- not win22cis_cloud_based_system or
win2022cis_is_domain_controller or
win2022cis_is_domain_member
- not win22cis_cloud_based_system
tags:
- level1-domaincontroller
- level1-memberserver
Expand All @@ -245,9 +242,8 @@
value: "{{ win22cis_allow_admin_account_lockout }}"
when:
- win22cis_rule_1_2_3
- not win22cis_cloud_based_system or
win2022cis_is_domain_controller or
win2022cis_is_domain_member
- win2022cis_is_domain_member
- not win22cis_cloud_based_system
tags:
- level1-memberserver
- rule_1.2.3
Expand Down Expand Up @@ -284,9 +280,7 @@
- win22cis_account_lockout_counter_reset <= win22cis_account_lockout_duration
when:
- win22cis_rule_1_2_4
- not win22cis_cloud_based_system or
win2022cis_is_domain_controller or
win2022cis_is_domain_member
- not win22cis_cloud_based_system
tags:
- level1-domaincontroller
- level1-memberserver
Expand Down Expand Up @@ -318,9 +312,7 @@
when: win22cis_account_lockout_duration >= 15
when:
- win22cis_rule_1_2_1
- not win22cis_cloud_based_system or
win2022cis_is_domain_controller or
win2022cis_is_domain_member
- not win22cis_cloud_based_system
tags:
- level1-domaincontroller
- level1-memberserver
Expand Down
1 change: 1 addition & 0 deletions tasks/section01_cloud_lockout_order.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
value: "{{ win22cis_allow_admin_account_lockout }}"
when:
- win22cis_rule_1_2_3
- win2022cis_is_domain_member
tags:
- level1-memberserver
- rule_1.2.3
Expand Down
3 changes: 3 additions & 0 deletions tasks/section02.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@
when:
- win22cis_rule_2_2_20
- win2022cis_is_domain_controller
- not win_skip_for_test
tags:
- level1-domaincontroller
- rule_2.2.20
Expand Down Expand Up @@ -378,6 +379,7 @@
when:
- win22cis_rule_2_2_25
- win2022cis_is_domain_controller
- not win_skip_for_test
tags:
- level1-domaincontroller
- rule_2.2.25
Expand All @@ -394,6 +396,7 @@
when:
- win22cis_rule_2_2_26
- win2022cis_is_domain_member
- not win_skip_for_test
tags:
- level1-memberserver
- rule_2.2.26
Expand Down
4 changes: 2 additions & 2 deletions tasks/section05.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
start_mode: disabled
state: stopped
when: spooler_service_info.exists
notify: reboot_windows
notify: change_requires_reboot
when:
- win22cis_rule_5_1 or
win22cis_rule_5_2
tags:
- level1-domaincontroller
- level2-domainmember
- level2-memberserver
- rule_5.1
- rule_5.2
- patch
Expand Down
Loading
Loading