Giter VIP home page Giter VIP logo

windows-baseline's Introduction

windows-baseline

Build Status Supermarket

This Baseline ensures, that all hardening projects keep the same quality.

Description

This InSpec compliance profile is inspired by CIS Windows 2012R2 and 2016 Benchmark and implements such rules in an automated way to provide security best-practice tests around Windows Servers in a production environment.

Implements:

  • CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018
  • CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018

InSpec is an open-source run-time framework and rule language used to specify compliance, security, and policy requirements for testing any node in your infrastructure.

Requirements

  • at least InSpec Version 3.0.0
  • WinRM activated (for inspec remote usage)

Platform

  • Windows 2012R2
  • Windows 2016
  • Windows 2019

Attributes

We use a yml attribute file to steer the configuration, the following options are available:

  • level_1_or_2 define which CIS Benchmark Level (1 or 2) you want to execute

  • ms_or_dc define if you want to execute the profile in the context of a Member Server (MS) or Domain Controller (DC)

  • password_history_size define password history size

  • maximum_password_age define MaximumPasswordAge

  • se_network_logon_right define which users are allowed to access this computer from the network

  • se_interactive_logon_right define which users are allowed to log on locally

  • se_remote_interactive_logon_right define which users are allowed to log on through Remote Desktop Services

  • se_backup_privilege define which users are allowed to backup files and directories

  • se_systemtime_privilege define which users are allowed to change system time

  • se_time_zone_privilege define which users are allowed to change system time zone

  • se_create_symbolic_link_privilege define which users are allowed to create symbolic links

  • se_deny_network_logon_right define which users are not allowed to access this computer from the network

  • se_deny_remote_interactive_logon_right define which users are not allowed to log on through Remote Desktop Services

  • se_enable_delegation_privilege define which users are allowed to enable computer and user accounts to be trusted

  • se_impersonate_privilege define which users are allowed to impersonate a client after authentication

  • se_load_driver_privilege define which users are allowed to load and unload device drivers

  • se_batch_logon_right define which users are allowed to log on as a batch job

  • se_security_privilege define which users are allowed to manage auditing and security logs

  • se_assign_primary_token_privilege define which users are allowed to replace a process level token

  • se_restore_privilege define which users are allowed to restore files and directories

Usage

InSpec makes it easy to run your tests wherever you need. More options listed here: InSpec cli

# run profile locally and directly from Github
$ inspec exec https://github.com/dev-sec/windows-baseline

# run profile locally
$ git clone https://github.com/dev-sec/windows-baseline
$ inspec exec windows-baseline

# run profile on remote host via WinRM
inspec exec windows-baseline -t winrm://<ip-address>:5985 --user=<username> --password=<password>

# run profile on remote host via WinRM and define attribute value
inspec exec windows-baseline -t winrm://<ip-address>:5985 --user=<username> --password=<password> --attrs sample_attributes.yml

# run profile direct from inspec supermarket
inspec supermarket exec dev-sec/windows-baseline -t winrm://<ip-address>:5985 --user=<username> --password=<password>

Run individual controls

In order to verify individual controls, just provide the control ids to InSpec:

inspec exec windows-baseline --controls 'windows-001'

ToDo

  • adjust the inspec attributes according to the profile (Member Server or Domain Controller), because for the Domain Controller some attributes are different from a Member Server

Contributors + Kudos

License and Author

Author: Patrick Muench [email protected]
Author: Torsten Loebner [email protected]
Copyright: 2019 SVA System Vertrieb Alexander GmbH
Copyright: 2019 Lichtblick SE
Copyright: 2015-2016, Chef Software, Inc
Copyright: DevSec Hardening Framework Team
License: Apache License Version 2.0

windows-baseline's People

Contributors

alexpop avatar arlimus avatar artem-sidorenko avatar atomic111 avatar chris-rock avatar grdnrio avatar hannah-radish avatar imjoseangel avatar matttunny avatar micheelengronne avatar renovate[bot] avatar rndmh3ro avatar schurzi avatar spencer-cdw avatar srenatus avatar staggerlee011 avatar wer-sce avatar yvovandoorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-baseline's Issues

Target a specific version of Windows

In a new w2019 server, im having many errors because of w10, w2012 issues (mainly Windos Registry stuff). So im having 500 errors, 944 passed.

Describe the solution you'd like
I´d like to be able to configure the version of WIndows im targeting

The baseline should be organized by components

Files in are organized in:

tree controls 
controls
├── 01_password_policy_spec.rb
├── 02_account_lockout_spec.rb
├── 03_user_rights_spec.rb
├── 04_audit_spec.rb
├── 05_ie_spec.rb
├── 07_rdp_spec.rb
└── 08_access_spec.rb

Instead we should organize them by components and remove the prefix numbers.

The 'should include' does not check for unwanted accounts

The 'should include' doesn't check that unwanted accounts are not present so this control is invalid.

control 'cis-adjust-memory-quotas-2.2.5' do
impact 0.7
title '2.2.5 Set Adust memory quotas for a process to Administrators, LOCAL SERVICE, NETWORK SERVICE'
desc 'Set Adust memory quotas for a process to Administrators, LOCAL SERVICE, NETWORK SERVICE'
describe security_policy do
its('SeIncreaseQuotaPrivilege') { should include 'S-1-5-19' }
its('SeIncreaseQuotaPrivilege') { should include 'S-1-5-20' }
its('SeIncreaseQuotaPrivilege') { should include 'S-1-5-32-544' }
end
end

I suggest the following. This will work only if the returned array is always sorted which I think is true.
Otherwise we need to check no other account is added.

control 'cis-adjust-memory-quotas-2.2.5' do
impact 0.7
title '2.2.5 Set Adust memory quotas for a process to Administrators, LOCAL SERVICE, NETWORK SERVICE'
desc 'Set Adust memory quotas for a process to Administrators, LOCAL SERVICE, NETWORK SERVICE'
describe security_policy do
its('SeIncreaseQuotaPrivilege') { should eq ['S-1-5-19','S-1-5-20','S-1-5-32-544'] }
end
end

windows-011 array order failure

Description

Window-011 check is failing due to an array ordering problem

Screenshot 2022-11-15 at 12 57 17 PM

It is looking for expected: ["S-1-5-9", "S-1-5-32-544"] but is finding got: ["S-1-5-32-544", "S-1-5-9"]

Reproduction steps

This is with a stock windows 2016 build, using the stock inspec defaults

https://github.com/dev-sec/windows-baseline/blob/master/inspec.yml#L34-L38

Current Behavior

expected: ["S-1-5-9", "S-1-5-32-544"]
got: ["S-1-5-32-544", "S-1-5-9"]

Expected Behavior

The array order should not change.
If the array order does change, it should not be considered a failure as long as the contents are equivalent.

OS / Environment

windows 2016

Inspec Version

5.18.14

Baseline Version

name: .
title: InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: [email protected]
license: Apache-2.0
summary: An InSpec Compliance Profile
version: 0.1.0
supports:
  platform-family: windows
depends:
  - name: windows-baseline
    git: https://github.com/dev-sec/windows-baseline
    tag: 2.1.9

Additional information

No response

LAN Manager authentication level incorrect

Describe the bug
I may be unsure of the intent here, but windows-base-201 "Strong Windows NTLMv2 Authentication Enabled; Weak LM Disabled" is not set correctly according to CIS Windows 2012R2 and 2016. I'm not sure if the current implementation is for a different spec.

The CIS policy I'm referencing is:

2.3.11.7 (L1) Ensure 'Network security: LAN Manager authentication
level' is set to 'Send NTLMv2 response only. Refuse LM & NTLM' 

Expected behavior
HKLM\System\CurrentControlSet\Control\Lsa:LmCompatibilityLevel should be set to 5

Actual behavior
HKLM\System\CurrentControlSet\Control\Lsa:LmCompatibilityLevel is set to 4

Inspec Version

1.51.21

Baseline Version

1c916e9
(master as of 2018-12-06)

Additional context
If the current implementation is correct, then I'm unsure of how to modify windows-baseline to support different specs for the same registry key. Any guidance would be helpful.

boolean 'or' logic for describe block

For CIS 2.2.7 'Allow log on through Remote Desktop Services' - I would like to configure a describe block that either nothing, or admins, or admins & RDS users, but no other accounts.

    describe security_policy do
      its('SeRemoteInteractiveLogonRight') { should eq ['] } or
      its('SeRemoteInteractiveLogonRight') { should eq ['S-1-5-32-544'] } or
      its('SeRemoteInteractiveLogonRight') { should eq ['S-1-5-32-544', 'S-1-5-32-555'] } 
    end

Is this possible?

formatting error when executing profile

Describe the bug
In some recent testing I discovered this profile is failing inspec exec with some formatting issues.

Expected behavior
Can execute this profile with inspec exec and send the results to Automate

Actual behavior

         2: from C:/opscode/inspec/embedded/lib/ruby/gems/2.6.0/gems/inspec-4.3.2/lib/inspec/reporters/automate.rb:41:in
 `send_report'
         1: from C:/opscode/inspec/embedded/lib/ruby/gems/2.6.0/gems/inspec-4.3.2/lib/inspec/reporters/automate.rb:41:in
 `to_json'
C:/opscode/inspec/embedded/lib/ruby/gems/2.6.0/gems/inspec-4.3.2/lib/inspec/reporters/automate.rb:41:in `encode': "\xC3"
 from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)

OS / Environment
windows_server_2016

Inspec Version
inspec 3.9.0

Baseline Version
master

Additional context
chef/automate#296

adjust memory quota test allows for other users to be present

This test:

control 'cis-adjust-memory-quotas-2.2.5' do
impact 0.7
title '2.2.5 Set Adust memory quotas for a process to Administrators, LOCAL SERVICE, NETWORK SERVICE'
desc 'Set Adust memory quotas for a process to Administrators, LOCAL SERVICE, NETWORK SERVICE'
describe security_policy do
its('SeIncreaseQuotaPrivilege') { should include 'S-1-5-19' }
its('SeIncreaseQuotaPrivilege') { should include 'S-1-5-20' }
its('SeIncreaseQuotaPrivilege') { should include 'S-1-5-32-544' }
end
end

..currently allows for other users to be present. This is potentially necessary, if the server is a web server or SQL server, but is not secure by default, as any user can be arbitrarily added?

Typo FontBocking/FontBlocking?

Describe the bug
In control windows-249 there is a mitigation called MitigationOptions_FontBocking instead of MitigationOptions_FontBlocking

I don't know if this is correct.
Stig viewer has the same typo: https://www.stigviewer.com/stig/windows_10/2015-11-30/finding/V-63641

For Windows 10 Font Blocking works entirely different: https://docs.microsoft.com/en-us/windows/security/threat-protection/block-untrusted-fonts-in-enterprise

  describe registry_key('HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\MitigationOptions') do
    it { should exist }
    it { should have_property 'MitigationOptions_FontBocking' }
    its('MitigationOptions_FontBocking') { should eq '1000000000000' }
end

We should check what option actually blocks untrusted fonts.

Error `undefined method `positive?' for #<RSpec::Matchers::DSL::Matcher cmp>`

On the windows baseline, I'm finding the following error

undefined method `positive?' for #<RSpec::Matchers::DSL::Matcher cmp>

inspec is using a method cmp.positive?

    its('MaximumPasswordAge') { should cmp.positive? }

https://github.com/dev-sec/windows-baseline/blob/master/controls/local_policies.rb#L1291-L1318

cmp.positive? does not appear to be a valid method on the RSpec::Matchers::DSL::Matcher class

https://rspec.info/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Matcher.html

inspec --version
5.18.14

There is only 1 example in this repo of .positive? being used.

Here is the commit where it was changed. https://github.com/dev-sec/windows-baseline/pull/50/files

Previous versions used the its('MaximumPasswordAge') { should cmp > 0 } syntax

Licensing information mismatch?

Controls in this repo (numbers 04-08) contain the following information in the headers:

# copyright: 2015, Chef Software, Inc
# license: All rights reserved

Pardon my ignorance, but isn't it contradictory to the general Apache License specified at the repo level?

The title of each test should clearly state what should be done

This is not a bug, rather a comment. The title of each test should clearly state what should be done or what should not be done.
For instance:
'windows-base-105'
title 'SMB1 to Windows Shares is disabled'
It would be better to update the title to something like:
title 'SMB1 to Windows Shares should be disabled'

'windows-base-203'
title 'Enable Strong Encryption for Windows Network Sessions on Servers'
It would be better to update the title to something like:
title 'Strong Encryption for Windows Network Sessions on Servers should be enabled'

Thanks.

False Positives due to integers in strings

Describe the bug
Many Inspec tests are failing the test when Windows stores a numerical value as a string.

Expected behavior
Tests should pass when the expected value is either a number or string

Actual behavior

AllocateDASD
is expected to eq 
  Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }

    expected: 0
         got: "0"

    (compared using ==)
  # windows-baseline-master/controls/local_policies.rb:1094:in `block (3 levels) in load_with_context'

OS / Environment
Domain-joined Windows Server 2016/2019

Inspec Version

4.20.10

Baseline Version

2.1.4

Additional context

I believe the recommendation from Opscode is to use cmp instead of eq

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.