This Puppet module provides secure configuration of your base OS with hardening.
- Puppet OpenSource or Enterprise
- Module stdlib
- Module sysctl
If you are using this module in a PE environment, you have to set pe_environment = true
Otherwise puppet will drop an error (duplicate resource)!
system_environment = default
define the context in which the system runs. Some options don't work fordocker
/lxc
pe_environment = false
set this to true if you are using Puppet Enterprise IMPORTANT - see abovedesktop_enabled = false
true if this is a desktop system, ie Xorg, KDE/GNOME/Unity/etcenable_ipv4_forwarding = false
true if this system requires packet forwarding in IPv4 (eg Router), false otherwiseenable_ipv6_forwarding = false
true if this system requires packet forwarding in IPv6 (eg Router), false otherwiseenable_ipv6 = false
false to disable ipv6 on this system, true to enablemanage_ipv6 = true
true to harden ipv6 setup, false to ignore ipv6 completelyenable_log_martians = true
true to enable logging on suspicious / unroutable network packets, false otherwise WARNING - this might generate huge log files!arp_restricted = true
true if you want the behavior of announcing and replying to ARP to be restricted, false otherwiseenable_rpfilter = true
true to enable reverse path filtering (discard bogus packets), false otherwiseextra_user_paths = []
add additional paths to the user'sPATH
variable (default is empty).umask = "027"
umask used for the creation of new home directories by useradd / newusersmaildir = "/var/mail"
path for maildirusergroups = true
true if you want separate groups for each user, false otherwisepassword_max_age = 60
maximum password agepassword_min_age = 7
minimum password age (before allowing any other password change)password_warn_age = 7
Days warning before password change is dueauth_retries = 5
the maximum number of authentication attempts, before the account is locked for some timeauth_lockout_time = 600
time in seconds that needs to pass, if the account was locked due to too many failed authentication attemptslogin_retries = 5
the maximum number of login retries if password is bad (normally overridden by PAM / auth_retries)login_timeout = 60
authentication timeout in seconds, so login will exit if this time passesallow_login_without_home = false
true if to allow users without home to loginpasswdqc_enabled = true
true if you want to use strong password checking in PAM using passwdqcpasswdqc_options = "min=disabled,disabled,16,12,8"
set to any option line (as a string) that you want to pass to passwdqcmanage_pam_unix = false
true if you want pam_unix managed by this moduleenable_pw_history = true
true if you want pam_unix to remember password history to prevent reuse of passwords (requiresmanage_pam_unix = true
)pw_remember_last = 5
the number of last passwords (e.g. 5 will prevent user to reuse any of her last 5 passwords)allow_change_user = false
if a user may usesu
to change his loginonly_root_may_su = false
true when only root and member of the group wheel may use su, required to be true for CIS Benchmark complianceignore_users = []
array of system user accounts that should not be hardened (password disabled and shell set to/usr/sbin/nologin
)folders_to_restrict = ['/usr/local/games','/usr/local/sbin','/usr/local/bin','/usr/bin','/usr/sbin','/sbin','/bin']
folders to make sure of that group and world do not have write access to it or any of the contentsrecurselimit = 5
directory depth for recursive permission checkchfn_restrict = ""
which fields may be changed by regular users using chfnenable_module_loading = true
true if you want to allowed to change kernel modules once the system is running (egmodprobe
,rmmod
)load_modules = []
load this modules via initramfs if enable_module_loading is falsedisable_filesystems = ['cramfs','freevxfs','jffs2','hfs','hfsplus','squashfs','udf','vfat']
array of filesystems (kernel modules) that should be disabledenable_sysrq = false
true to enable the magic sysrq key, false otherwiseenable_core_dump = false
false to prevent the creation of core dumps, true otherwiseenable_stack_protection = true
for Address Space Layout Randomization. ASLR can help defeat certain types of buffer overflow attacks. ASLR can locate the base, libraries, heap, and stack at random positions in a process's address space, which makes it difficult for an attacking program to predict the memory address of the next instruction.cpu_vendor = 'intel'
only required ifenable_module_loading = false
: set the CPU vendor for modules to loadroot_ttys = ['console','tty1','tty2','tty3','tty4','tty5','tty6']
registered TTYs for rootwhitelist = []
all files which should keep their SUID/SGID bits if set (will be combined with pre-defined whiteliste of files)blacklist = []
all files which should have their SUID/SGID bits removed if set (will be combined with pre-defined blacklist of files)remove_from_unknown = false
true
if you want to remove SUID/SGID bits from any file, that is not explicitly configured in ablacklist
. This will make every Puppet 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 yourwhitelist
.dry_run_on_unknown = false
likeremove_from_unknown
above, only that SUID/SGID bits aren't removed. It will still search the filesystems to look for SUID/SGID bits but it will only print them in your log. This option is only ever recommended, when you first configureremove_from_unknown
for SUID/SGID bits, so that you can see the files that are being changed and make adjustments to yourwhitelist
andblacklist
.unwanted_packages = []
packages that should be removed from the systemwanted_packages = []
packages that should be added to the systemdisabled_services = []
services that should not be enabledenable_grub_hardening = false
set to true to enable some grub hardening rulesgrub_user = 'root'
the grub username that needs to be provided when changing config on the grub promptgrub_password_hash = ''
a password hash created withgrub-mkpasswd-pbkdf2
that is associated with the grub_userboot_without_password = true
setup Grub so it only requires a password when changing an entry, not when booting an existing entry
After adding this module, you can use the class:
class { 'os_hardening': }
As the CIS Distribution Independent Linux Benchmark is a good starting point regarding hardening of systems, it was deemed appropriate to implement an easy way to deal with one-offs for which one doesn't want to write an entire module.
For instance, to increase CIS DIL compliance on a Debian system, one should set the following:
wanted_packages => ['ntp'],
unwanted_packages => ['telnet'],
disabled_services => ['rsync'],
The default settings of NTP are actually pretty good for most situations, so it is not immediately necessary to implement a module. However, if you do use a module to control these services, that is of course preferred.
You should have Ruby interpreter installed on your system. It might be a good idea to use rvm for that purpose. Besides that you have to install VirtualBox and Vagrant. See Vagrant Downloads for a vagrant package and VirtualBox Downloads for a VirtualBox package suitable for your system. For all our tests we use test-kitchen
. If you are not familiar with test-kitchen
please have a look at their guide.
Next install test-kitchen:
# Install dependencies
gem install bundler
bundle install
# list all test instances
bundle exec kitchen list
# fast test on one machine
bundle exec kitchen test default-ubuntu-16-04
# test on all machines
bundle exec kitchen test
# for development
bundle exec kitchen create default-ubuntu-16-04
bundle exec kitchen converge default-ubuntu-16-04
bundle exec kitchen verify default-ubuntu-16-04
For more information see test-kitchen
You can enable testing of your fork in Travis CI. By default you will get linting and spec tests.
Integration tests of this repository are conducted using Microsoft Azure.
If you want to have integration tests for your fork, you will have to add following environment variables in the settings of your fork:
AZURE_SUBSCRIPTION_ID
- subscription idAZURE_CLIENT_ID
- id of registered applicationAZURE_CLIENT_SECRET
- secret of registered applicationAZURE_TENANT_ID
- id of Azure Active DirectoryCI_SSH_KEY
- private part of some ssh key, in base64 encoded form (e.g.cat id_rsa | base64 -w0 ; echo
)
- Dominik Richter arlimus
- Edmund Haselwanter ehaselwanter
- Christoph Hartmann chris-rock
- Thomas Dütsch a-tom
- Patrick Meier atomic111
- Artem Sidorenko artem-sidorenko
- Kurt Huwig kurthuwig
- Matthew Haughton 3flex
- Reik Keutterling spielkind
- Daniel Dreier danieldreier
- Timo Goebel timogoebel
- Tristan Helmich fadenb
- Michael Geiger mcgege
For the original port of chef-os-hardening
to puppet:
- Artem Sidorenko artem-sidorenko
- Frank Kloeker eumel8
Thank you all!!
- Author:: Dominik Richter dominik.richter@gmail.com
- Author:: Deutsche Telekom AG
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.