-
Notifications
You must be signed in to change notification settings - Fork 164
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
Harden windows security module v.0.2.6 #158
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Removed -NoNewLine from 2 colors that shouldn't have had that param
Instead of using the bcdedit, using the new PowerShell cmdlets. This allows the NX bit value detection to work with any locale and system language. previously this detection only worked with EN-US locales.
Added Svchost.exe security mitigation removal to the Unprotect-WindowsSecurity cmdlet It's a tattooed policy so simply setting it to not configured won't revert it.
The controlled folder access is now properly navigated when using Confirm-SystemCompliance cmdlet. The new method of BCD NX value verification and detection causes Controlled Folder Access to show notification about pwsh.exe getting blocked so the new change prevents this from happening by dynamically adding pwsh.exe exe to the exclusion list before running the function and then restoring the exclusion list back to exactly how it was at the end of the operation. This is safely done to ensure that even if user press ctrl + c to prematurely exit the operation or if there is an error, the exclusion list restoration will still happen.
Removed the unnecessary artificial wait time that was introduced in the BitLocker category to add powercfg.exe to Controlled folder access exclusion list and then removing it after the command. Now it's added to the exclusion list at the beginning so that by the time the BitLocker category is being processes, enough time will have been passed for it to run without causing any errors or showing notification about it being blocked. At the end of the execution or when execution is prematurely terminated, it will be removed like the rest of the PowerShell executables and the CFA's exclusion list will be restored.
Variable type definitions improving code consistency
When running BitLocker category, the encryption method of each drive will be checked and if it's not XTSAES256 which is currently the most secure type, a warning will be displayed. The module/script doesn't do anything else. But if you like to fix that, you will need to manually decrypt each drive, wait for it to be fully decrypted, and then run the BitLocker category again to encrypt them with the most secure algorithm.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's Changed
Bcdedit
, using the new PowerShell cmdlets. This allows the NX bit value detection to work with any locale and system language. Previously this detection only worked with EN-US locales.Confirm-SystemCompliance
cmdlet. The new method of BCD NX value verification and detection causes Controlled Folder Access to show notification about pwsh.exe getting blocked so the new change prevents this from happening by dynamically adding pwsh.exe exe to the exclusion list before running the function and then restoring the exclusion list back to exactly how it was at the end of the operation. This is safely done to ensure that even if user pressedctrl + c
to prematurely exit the operation or if there is an error, the exclusion list restoration will still happen.Svchost.exe
security mitigation removal to theUnprotect-WindowsSecurity
cmdlet. It's a tattooed policy so simply setting it to not configured won't revert it.XTSAES256
which is currently the most secure type, a warning will be displayed. The module/script doesn't do anything else, but if you like to fix that, you will need to manually decrypt each drive, wait for it to be fully decrypted, and then run the BitLocker category again to encrypt them with the most secure algorithm. Your OS or non-OS drive that is BitLocker encrypted might be using a less secure encryption method if you didn't encrypt it properly. Another potential cause is if your SSD is SED (Self Encrypting Drive) and uses Opal 2, in this case it might automatically pick a different algorithm such asXTSAES128
. The Harden Windows Security module always usesXTSAES256
until a more secure encryption method becomes available.Important Notes
I'm going to explain 2 known issues in Windows that are not related to the Harden Windows Security module or script, nevertheless, I want to make you aware of them because they can cause complications. You might not be affected by them at all. I've found these issues through long debugging sessions.
Svchost.exe security mitigations policy
In the Miscellaneous category, there is a policy called svchost.exe mitigations., it applies process mitigations for
Svchost.exe
process, you can read more about what it does in the linked page but the most important thing is that it requires all binaries loaded inSvchost.exe
process to be signed by Microsoft.So far so good, right? so where is the problem?
There is a file located at:
It's part of the Windows OS but it hasn't been digitally signed for about 2 months now. It was signed before but since about 2 months ago it was released as an unsigned dll.
When you use the Miscellaneous category and you have at least Windows 11 pro for workstation edition, that security policy prevents
gameplatformservices.dll
from loading and as a result of that, Code Integrity Operational logs begin to generate in an unprecedented rate, sometimes up to 500 logs every 10 seconds. They essentially pollute that important event category and also cause high CPU usage. Microsoft Store is one of the triggers of this problem. When it checks for app updates or if you manually check for app updates, the problem starts happening, CPU usage goes up and Microsoft Store gets stuck at checking for updates forever. Using Xbox apps and services can potentially help this problem manifest itself better or faster.Smart App Control also detects this file as unsigned and blocks it. I've reported this in Feedback hub multiple times (1 - 2 - 3) but so far no changes have been made.
As a workaround, you can manually turn off this policy if you are affected by this issue. It's a tattooed policy, meaning it's not enough to simply set it to "Not Configured" state, you need to change or delete the registry key related to that policy too.
Screenshots 📸
BitLocker encryption, OneDrive Personal Vault and ReFS volumes, an interesting trio
Based on my findings, there is a potential issue when you try to use BitLocker, OneDrive Personal Vault and ReFS volume at the same time.
If your OS volume is BitLocker encrypted and you have at least one ReFS volume that is also BitLocker encrypted then OneDrive's Personal Vault fails when you try to unlock or initialize it.
It fails by getting stuck at step 12 and when that happens, some normal operations of the OS get stuck and stop functioning.
This only happens if the ReFS volume is unlocked. If the ReFS volume is BitLocker encrypted but locked when you try to unlock OneDrive's personal vault, then this problem won't happen.
It doesn't matter how many other BitLocker encrypted ReFS, NTFS or non-BitLocker encrypted volumes are available on the system.
The ReFS volume can have recovery password, auto unlock or password key protector, either way this problem is reproducible.
Screenshots 📸