I resorted to using Powershell to sort through our issue. Hopefully pasting the logic here maintains the formatting. I do not see a way to add it into a script-block. This script will only modify the Current Owner scope from "This key and Subkeys" to "Subkeys Only" - as required by DISA STIG.
#####################################################################
##Server 2022 HKLM/System Registry Permissions Fix for Current Owner for STIG
#####################################################################
# Define the SID for Creator Owner
$sidCreatorOwner = New-Object System.Security.Principal.SecurityIdentifier("S-1-3-0")
# Define the registry rights for Subkeys Only
$permissionsSubkeysOnly = System.Security.AccessControl.RegistryRights::CreateLink -bor `
# Create an access rule for Creator Owner with Subkeys Only permissions
$ruleCreatorOwner = New-Object System.Security.AccessControl.RegistryAccessRule($sidCreatorOwner, $permissionsSubkeysOnly, "None", "None", "Allow")
# Get the current ACL
$acl = Get-Acl -Path "HKLM:\System"
# Remove existing Creator Owner rules (if any)
$acl.Access | Where-Object { $_.IdentityReference -eq $sidCreatorOwner } | ForEach-Object {
$acl.RemoveAccessRule($_)
}
# Add the new Creator Owner access rule for Subkeys Only
$acl.AddAccessRule($ruleCreatorOwner)
# Apply the modified security descriptor to the registry key
Set-Acl -Path "HKLM:\System" -AclObject $acl
If you attempted to use GPO and removed the SID from the ACL, you will have trouble adding it back and having a clean STIG scan. I used the below logic to re-add the SID and set the appropriate permissions.
###########################################################
##Server 2022 HKLM/System Registry Permissions Fix for SID
###########################################################
# Define the SID you want to add
$sid = New-Object System.Security.Principal.SecurityIdentifier("S-1-15-3-1024-1065365936-1281604716-3511738428-1654721687-432734479-3232135806-4053264122-3456934681")
# Define the registry rights for 'Read' permission
$permissions = System.Security.AccessControl.RegistryRights::ReadKey -bor `
# Get the current ACL for HKLM\System
$acl = Get-Acl -Path "HKLM:\System"
# Create a new access rule for the SID and 'Read' permission
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($sid, $permissions, "ContainerInherit, ObjectInherit", "None", "Allow")
# Add the access rule to the security descriptor
$acl.AddAccessRule($rule)
# Set the "Applies to" field to "this key and subkeys"
$acl.SetAccessRuleProtection($true, $false) # Protect the key, not the subkeys
# Apply the modified security descriptor to the registry key
Set-Acl -Path "HKLM:\System" -AclObject $acl