You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
64 bit ChefClient ships with a 64 bit Ruby and behaves correctly when accessing the registry
64 bit ChefDK ships with a 32 bit Ruby and behaves incorrectly when accessing the registry
When a 32 bit process tries to access certain parts of the registry on 64 bit windows the access is transparently redirected to another location. Microsoft call this "Registry Reflection". For example:-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\... gets redirected to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\...
This causes both chef-client runs and Inspec to access the wrong branch of the registry when using ChefDK. For Inspec in particular, a large number of inspec tests incorrectly report compliance failures during profile development.
The problem is not currently referenced in the Inspec documentation.
ChefDK Version
2.0.26 and 1.5.0
Platform Version
Windows 2012R2 x86_64
Possible fix
Upgrade ChefDK to a 64 bit Ruby
Replication Case
Use regedit to create a REG_SZ key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon with a value '0'
Create an inspec profile containing a control like this:-
title 'Problem with Registry Keys'
control 'WinLogon' do
impact 0.7
title 'AutoLogin'
desc 'Check the AutoLogin property'
describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon') do # The actual test
it { should have_property 'AutoAdminLogon' }
its('AutoAdminLogon') { should eq '0' }
end
end
Execute it locally with inspec exec my_test_profile and see it fail
Execute it locally with a 64bit ruby and see it pass.
Execute it against the local machine over WinRM (which launches a remote 64 bit process) and see it pass inspec exec -t winrm://user:pass@localhost
Proving the point with pure ruby/powershell
Inspec shells out to Powershell to get registry entries. We can do the same.
Run the following Ruby code using the ChefDK 32 bit ruby and repeat with a 64 bit ruby
Description
64 bit ChefClient ships with a 64 bit Ruby and behaves correctly when accessing the registry
64 bit ChefDK ships with a 32 bit Ruby and behaves incorrectly when accessing the registry
When a 32 bit process tries to access certain parts of the registry on 64 bit windows the access is transparently redirected to another location. Microsoft call this "Registry Reflection". For example:-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\...
gets redirected toHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\...
This causes both chef-client runs and Inspec to access the wrong branch of the registry when using ChefDK. For Inspec in particular, a large number of inspec tests incorrectly report compliance failures during profile development.
The problem for Chef client runs is partially referenced in Chef documentation at https://docs.chef.io/resource_registry_key.html
The problem is not currently referenced in the Inspec documentation.
ChefDK Version
2.0.26 and 1.5.0
Platform Version
Windows 2012R2 x86_64
Possible fix
Upgrade ChefDK to a 64 bit Ruby
Replication Case
Use regedit to create a REG_SZ key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
with a value'0'
Create an inspec profile containing a control like this:-
Execute it locally with
inspec exec my_test_profile
and see it failExecute it locally with a 64bit ruby and see it pass.
Execute it against the local machine over WinRM (which launches a remote 64 bit process) and see it pass
inspec exec -t winrm://user:pass@localhost
Proving the point with pure ruby/powershell
Inspec shells out to Powershell to get registry entries. We can do the same.
Run the following Ruby code using the ChefDK 32 bit ruby and repeat with a 64 bit ruby
Note the difference in values/properties returned.
Results from ChefDK 32bit Ruby
Returns 5 values/properties from the redirected key
Results from 64 bit Ruby
Returns 23 values/properties from the real key
The text was updated successfully, but these errors were encountered: