This chef cookbook provides numerous security-related configurations, providing all-round base protection.
This cookbook provides numerous security-related configurations, providing all-round base protection.
It configures:
pam
and pam_limits
moduleIt will not:
['os-hardening']['components'][COMPONENT_NAME]
- allows the fine control over which components should be executed via default recipe. See below for more details['os-hardening']['desktop']['enable'] = false
['os-hardening']['network']['forwarding'] = false
['os-hardening']['network']['ipv6']['enable'] = false
['os-hardening']['network']['arp']['restricted'] = true
['os-hardening']['env']['extra_user_paths'] = []
PATH
variable (default is empty).['os-hardening']['env']['umask'] = "027"
['os-hardening']['env']['root_path'] = "/"
['os-hardening']['auth']['pw_max_age'] = 60
['os-hardening']['auth']['pw_min_age'] = 7
['os-hardening']['auth']['pw_warn_age'] = 7
['os-hardening']['auth']['uid_min'] = 1000
['os-hardening']['auth']['uid_max'] = 60000
['os-hardening']['auth']['gid_min'] = 1000
['os-hardening']['auth']['gid_max'] = 60000
['os-hardening']['auth']['retries'] = 5
['os-hardening']['auth']['lockout_time'] = 600
['os-hardening']['auth']['timeout'] = 60
['os-hardening']['auth']['allow_homeless'] = false
['os-hardening']['auth']['pam']['passwdqc']['enable'] = true
['os-hardening']['auth']['pam']['passwdqc']['options'] = "min=disabled,disabled,16,12,8"
['os-hardening']['auth']['pam']['passwdqc']['template_cookbook'] = 'os-hardening'
/usr/share/pam-configs/passwdqc
file['os-hardening']['auth']['pam']['tally2']['template_cookbook'] = 'os-hardening'
/usr/share/pam-configs/tally2
file['os-hardening']['auth']['pam']['system-auth']['template_cookbook'] = 'os-hardening'
/etc/pam.d/system-auth-ac
file['os-hardening']['security']['users']['allow'] = []
change_user
['os-hardening']['security']['kernel']['enable_module_loading'] = true
modprobe
, rmmod
)['os-hardening']['security']['kernel']['disable_filesystems'] = ['cramfs', 'freevxfs', 'jffs2', 'hfs', 'hfsplus', 'squashfs', 'udf', 'vfat']
[]
to completely avoid this blacklisting['os-hardening']['security']['kernel']['enable_sysrq'] = false
['os-hardening']['security']['kernel']['enable_core_dump'] = false
['os-hardening']['security']['suid_sgid']['enforce'] = true
['os-hardening']['security']['suid_sgid']['blacklist'] = []
['os-hardening']['security']['suid_sgid']['whitelist'] = []
['os-hardening']['security']['suid_sgid']['remove_from_unknown'] = false
blacklist
. This will make every Chef run search through the mounted filesystems looking for SUID/SGID bits that are not configured in the default and user blacklist. If it finds an SUID/SGID bit, it will be removed, unless this file is in your whitelist
.['os-hardening']['security']['suid_sgid']['dry_run_on_unknown'] = false
remove_from_unknown
above, only that SUID/SGID bits aren’t removed.remove_from_unknown
for SUID/SGID bits, so that you can see the files that are being changed and make adjustments to your whitelist
and blacklist
.['os-hardening']['security']['packages']['clean'] = true
['os-hardening']['security']['packages']['list'] = ['xinetd','inetd','ypserv','telnet-server','rsh-server']
['os-hardening']['security']['selinux_mode'] = 'unmanaged'
unmanaged
if you want to let selinux configuration as it is. Set to enforcing
to enforce or permissive
to permissive SELinux.default.rb
includes other components based on the ohai autodetection attributes of your system. E.g. do not execute selinux on non-RHEL systems. You can override this behavior and force components to be executed or not via setting attributes in node['os-hardening']['components']
on the override level. Example
# some attribute file
# do not include sysctl and auditd
override['os-hardening']['components']['sysctl'] = false
override['os-hardening']['components']['auditd'] = false
# force selinux to be included
override['os-hardening']['components']['selinux'] = true
In the current implementation different components are located in the different recipes. See the available recipes or default.rb
for possible component names.
Add the recipes to the run_list
, it should be last:
"recipe[os-hardening]"
Configure attributes:
"security" : {
"kernel" : {
"enable_module_loading" : true
}
},
Please install chef-dk, VirtualBox or VMware Workstation and Vagrant.
Linting is checked with rubocop and foodcritic:
$ chef exec rake lint
.....
Unit/spec tests are done with chefspec:
$ chef exec rake spec
.....
Integration tests are done with test-kitchen and inspec:
$ chef exec rake kitchen
.....
# or you can use the kitchen directly
$ kitchen test
You can enable testing of your fork in Travis CI. By default you will get linting, spec tests and integration tests with kitchen-dokken.
Integration tests with kitchen-dokken do not cover everything as they run in the container environment.
Full integration tests can be executed using DigitalOcean.
If you want to have full integration tests for your fork, you will have to add following environment variables in the settings of your fork:
DIGITALOCEAN_ACCESS_TOKEN
- access token for DigitalOceanCI_SSH_KEY
- private part of some ssh key, available on DigitalOcean for your instances, in base64 encoded form (e.g. cat id_rsa | base64 -w0 ; echo
)DIGITALOCEAN_SSH_KEY_IDS
- ID in DigitalOcean of CI_SSH_KEY
, see this for more informationThis cookbook is mostly based on guides by:
Thanks to all of you!!
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.