Version information
This version is compatible with:
- Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.0.0 < 6.0.0
- , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'hardening-os_hardening', '2.1.1'
Learn more about managing modules with a PuppetfileDocumentation
Puppet OS hardening
Description
This Puppet module provides secure configuration of your base OS with hardening.
Requirements
- Puppet
Parameters
system_environment = default
define the context in which the system runs. Some options don't work fordocker
/lxc
desktop_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 loginignore_users = []
array of system user accounts that should not be hardened (password disabled and shell set to/usr/sbin/nologin
)recurselimit = 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
.
Usage
After adding this module, you can use the class:
class { 'os_hardening': }
Testing
Local Testing
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
CI testing of forks
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
)
Contributors + Kudos
- 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!!
License and Author
- 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.
Change Log
2.1.1 (2018-05-17)
Implemented enhancements:
- Convert module into "standardized PDK module" #107
- Adding new param to specify maildir path. Updated nologin path for Re… #127 (hundredacres)
- converted module to pdk #107 #120 (enemarke)
Closed issues:
- net.ipv4.tcp_rfc1337 not a valid sysctl key #124
Merged pull requests:
- Add password_warn_age parameter for login.defs #128 (claw-real)
- CI: switch testing to DigitalOcean #126 (artem-sidorenko)
- Refactoring and new spec test #121 (enemarke)
2.1.0 (2018-01-17)
Implemented enhancements:
- Update to verify the module against https://github.com/dev-sec/linux-baseline #79
- Use type checking by defining data types #114 (mcgege)
- Make paramater USERGROUPS_ENAB in login.defs configurable #113 (mcgege)
Fixed bugs:
Closed issues:
- Minimize access needs a better way of removing +w on system folders #60
- login.defs for different OS #57
- Adduser consistency #49
- Update some RH settings in this module #102
Merged pull requests:
- Get CI tests running on azure #115 (artem-sidorenko)
- Correct header comments in sysctl.pp #69 (Zordrak)
- Skip entropy tests and disable auditd tests #117 (artem-sidorenko)
- Making test-kitchen work again #112 (artem-sidorenko)
- Implement new RH defaults (see issue #102) #103 (mcgege)
2.0.0 (2017-12-19)
Closed issues:
- SLES and OEL errors when ipv6 is disabled #82
- Failed to generate additional resources #75
- Multiple conflicts with Puppet Enterprise #74
- Conflict with Puppet Enterprise 2016.1.1 #71
- allow_core_dump set to true still ends up setting /etc/security/limits.d/10.hardcore.conf and /etc/profile.d/pinerolo_profile.sh files #68
- IPv6 setting problem #67
- Log martian packets #66
- Merge #64 #65
- net.ipv6.conf.default.accept_ra #56
- Publish new release on Puppet Forge #104
Merged pull requests:
- Update links + contributors in README #108 (mcgege)
- Avoid picking up users retrieved from SSSD or other domain services. #101 (tprobinson)
- Implement linux-baseline os-10 #100 (mcgege)
- Style Guide corrections #98 (mcgege)
- Update module metadata #97 (mcgege)
- Baseline sysctl-17: Enable logging of martian packets #96 (mcgege)
- One single coredump parameter #95 (mcgege)
- Fix for Linux Baseline os-02 #94 (mcgege)
- Baseline os-05b: set SYS_[GU]ID_[MIN|MAX] in /etc/login.defs #92 (mcgege)
- Remove config/scripts to prevent core dumps if function is disabled… #91 (mcgege)
- DevSec Linux Baseline os-05 #90 (mcgege)
- Corrected handling of /bin/su (via allow_change_user) #89 (mcgege)
- Documentation update #88 (mcgege)
- added switch manage_ipv6, so people could disable managing of ipv6 co… #87 (STetzel)
- CentOS7 issue - revert "Remove link following in minimize_access file resource" #86 (mcgege)
- Making rubocop happy #85 (artem-sidorenko)
- Make the sysctl setting 'rp_filter' configurable #84 (mcgege)
- Quick fix for issue #71: remove '/usr/local/bin' from managed folders #83 (mcgege)
- Puppet-lint done for sysctl.pp #81 (bitvijays)
- Fix the CI #80 (artem-sidorenko)
- Adopt Puppet style guide - remove dynamic variable lookup #70 (tuxmea)
- Remove link following in minimize_access file resource #64 (rooprob)
- update common kitchen.yml platforms #63 (chris-rock)
- add support for limiting password re-use. #61 (igoraj)
- add local testing section to readme #59 (chris-rock)
- add net.ipv6.conf.default.accept_ra. closes #56 #58 (igoraj)
- Disable System Accounts #54 (igoraj)
- common files: add centos 7 #53 (arlimus)
- Prepare module for v2.0.0 #109 (mcgege)
1.1.2 (2015-05-09)
Merged pull requests:
- Update common readme badges + contributors + rubocop #52 (arlimus)
- update common travis.yml, kitchen.yml platforms #51 (arlimus)
- bugfix: use scoped resource for puppet 4 #50 (arlimus)
OLD Changelog
1.1.2
- bugfix: ruby1.8+puppet+rspec interplay
- bugfix: use scoped resource for puppet 4
1.1.1
- feature: add stack protection configuration via sysctl (enabled)
- bugfix: replace non-ascii char in login.defs
- bugfix: follow links for RHEL7 /bin and /sbin
- bugfix: fixed tty newlines
- bugfix: minor log typos
1.1.0
API-change: renamed module to hardening-os_hardening
- improvement: linting
1.0.2
- improvement: only run 'update-pam' when needed
1.0.1
- bugfix: add missing colon for user-defined paths in PATH env
- adjust login.defs template to not log user logins (as per Debian defaults)
1.0.0
- add verified support for puppet 3.6, remove support for puppet 3.0 and 3.4
- improvement: streamlined rubocop and puppet-lint
- improvement: remove stdlib fixed version dependency
- improvement: loosened thias/sysctl dependency
- bugfix: get puppet version in gemfile from ENV:
PUPPET_VERSION
0.1.3
API-change: dry_run_on_unkown
is now dry_run_on_unknown
- feature: allow configuration of custom modules (if module loading is disabled)
- improvement: only remove SUID/SGID if necessary
- improvement: clarify SUID/SGID options
- improvement: use thias/sysctl to configure sysctls (also fixes previous bugs with the template)
- improvement: add spec tests for sysctl options
- improvement: puppet-lint everything
- improvement: add travis testing for lint+specs
- improvement: use file resource instead of exec for access minimization
- bugfix: fix typo dry_run_on_unkown -> dry_run_on_unknown
- bugfix: don't run update initramfs on each run, only when requiered
- bugfix: deactivation of kernel module loading wasn't implemented
- bugfix: ip_forwarding wasn't activated correctly
0.1.2
- feature: add additional ipv6 hardening to sysctl
- feature: add test kitchen
- improvement: remove unnecessary attributes from os_hardening::pam
- bugfix: remove cracklib if passwdqc is used
0.1.1
- feature: add configurable system environment
- feature: remove suid/sgid bits from blacklist
- feature: remove suid/sgid bits from unknown files
0.1.0
- port from chef-os-hardening and monolithic puppet implementation
* This Change Log was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/stdlib (>= 4.6.0 < 5.0.0)
- thias/sysctl (>= 1.0.6 < 2.0.0)