Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

os-hardening (22) Versions 1.2.0

Installs and configures operating system hardening

Policyfile
Berkshelf
Knife
cookbook 'os-hardening', '= 1.2.0', :supermarket
cookbook 'os-hardening', '= 1.2.0'
knife supermarket install os-hardening
knife supermarket download os-hardening
README
Dependencies
Changelog
Quality -%

os-hardening (Chef cookbook)

Supermarket
Build Status
Code Coverage
Dependencies

Description

This cookbook provides numerous security-related configurations, providing all-round base protection.

It configures:

  • Configures package management e.g. allows only signed packages
  • Remove packages with known issues
  • Configures pam and pam_limits module
  • Shadow password suite configuration
  • Configures system path permissions
  • Disable core dumps via soft limits
  • Restrict Root Logins to System Console
  • Set SUIDs
  • Configures kernel parameters via sysctl

It will not:

  • Update system packages
  • Install security patches

Requirements

  • Opscode chef
  • Cookbooks:
    • Opscode sysctl https://github.com/onehealth-cookbooks/sysctl
    • Opscode apt https://github.com/opscode-cookbooks/apt.git
    • Opscode yum https://github.com/opscode-cookbooks/yum.git

Note for sysctl usage:

We deprecated sysctl version before 0.6.0. Future versions of this cookbook will depend on version 0.6.0 and greater. If you are going to use version 0.6.0, use sysctl::apply instead of sysctl::default in your runlist to ensure the configuration change will be applied.

Optional: you can use berkshelf to install dependencies.

Attributes

  • ['desktop']['enable'] = false true if this is a desktop system, ie Xorg, KDE/GNOME/Unity/etc
  • ['network']['forwarding'] = false true if this system requires packet forwarding (eg Router), false otherwise
  • ['network']['ipv6']['enable'] = false
  • ['network']['arp']['restricted'] = true true if you want the behavior of announcing and replying to ARP to be restricted, false otherwise
  • ['env']['extra_user_paths'] = [] add additional paths to the user's PATH variable (default is empty).
  • ['env']['umask'] = "027"
  • ['env']['root_path'] = "/" where root is mounted
  • ['auth']['pw_max_age'] = 60 maximum password age
  • ['auth']['pw_min_age'] = 7 minimum password age (before allowing any other password change)
  • ['auth']['retries'] = 5 the maximum number of authentication attempts, before the account is locked for some time
  • ['auth']['lockout_time'] = 600 time in seconds that needs to pass, if the account was locked due to too many failed authentication attempts
  • ['auth']['timeout'] = 60 authentication timeout in seconds, so login will exit if this time passes
  • ['auth']['allow_homeless'] = false true if to allow users without home to login
  • ['auth']['pam']['passwdqc']['enable'] = true true if you want to use strong password checking in PAM using passwdqc
  • ['auth']['pam']['passwdqc']['options'] = "min=disabled,disabled,16,12,8" set to any option line (as a string) that you want to pass to passwdqc
  • ['security']['users']['allow'] = [] list of things, that a user is allowed to do. May contain: change_user
  • ['security']['kernel']['enable_module_loading'] = true true if you want to allowed to change kernel modules once the system is running (eg modprobe, rmmod)
  • ['security']['kernel']['enable_sysrq'] = false
  • ['security']['kernel']['enable_core_dump'] = false
  • ['security']['suid_sgid']['enforce'] = true true if you want to reduce SUID/SGID bits. There is already a list of items which are searched for configured, but you can also add your own
  • ['security']['suid_sgid']['blacklist'] = [] a list of paths which should have their SUID/SGID bits removed
  • ['security']['suid_sgid']['whitelist'] = [] a list of paths which should not have their SUID/SGID bits altered
  • ['security']['suid_sgid']['remove_from_unkown'] = false true if you want to remove SUID/SGID bits from any file, that is not explicitly configured in a 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.
  • ['security']['suid_sgid']['dry_run_on_unkown'] = false like remove_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 configure remove_from_unkown for SUID/SGID bits, so that you can see the files that are being changed and make adjustments to your whitelist and blacklist.
  • ['security']['packages']['clean'] = true removes packages with known issues. See section packages.

Packages

We remove the following packages:

  • xinetd (NSA, Chapter 3.2.1)
  • inetd (NSA, Chapter 3.2.1)
  • tftp-server (NSA, Chapter 3.2.5)
  • ypserv (NSA, Chapter 3.2.4)
  • telnet-server (NSA, Chapter 3.2.2)
  • rsh-server (NSA, Chapter 3.2.3)

Usage

Add the recipes to the run_list, it should be last:

"recipe[os-hardening]"

Configure attributes:

"security" : {
  "kernel" : {
    "enable_module_loading" : true
  }
},

Local Testing

For local testing you can use vagrant and Virtualbox of VMWare to run tests locally. You will have to install Virtualbox and Vagrant on your system. See Vagrant Downloads for a vagrant 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:

gem install test-kitchen kitchen-vagrant

Next install berkshelf for dependency management

gem install berkshelf

Create a local kitchen configuration:

cp .kitchen.local.yml{.example,}

You should now be able to run tests:

# Install dependencies
gem install bundler
bundle install

# Do lint checks
bundle exec rake lint

# Fetch tests
bundle exec thor kitchen:fetch-remote-tests

# fast test on one machine
bundle exec kitchen test default-ubuntu-1204

# test on all machines
bundle exec kitchen test

# for development
bundle exec kitchen create default-ubuntu-1204
bundle exec kitchen converge default-ubuntu-1204

http://kitchen.ci/docs/getting-started

Contributors + Kudos

This cookbook is mostly based on guides by:

Thanks to all of you!!

Contributing

See [contributor guideline](CONTRIBUTING.md).

License and Author

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.

Changelog

1.2.0

  • feature: make UID and GID_MIN configurable in login.defs
  • feature: integrate chefspec
  • improvement: linting
  • improvement: only restart procps for sysctl when necessary
  • improvement: cpu detection for lockdown profile
  • bugfix: add missing ohai dependency for standalone installation
  • bugfix: site location in Berkshelf

1.1.2

  • improvement: extend support for chef-sysctl from 0.3.x-0.6.x
  • improvement: fix linting to current rubocop (0.25)

1.1.1

  • improvement: specified supported operating systems in metadata

1.1.0

  • improvement: remove NTP from os-hardening Configure it via upstream modules as needed We might add a NTP hardening layer in the future
  • improvement: move /usr/bin/screen to SGID whitelisting
  • improvement: changed the log_martians value to 0 in attributes/sysctl.rb
  • bugfix: make sysctl arp restrictions apply to all devices

  • improvement: unify linting and testing; includes huge improvements to style and test scope

  • improvement: make kitchen run optional in guard, use export RUN_KITCHEN=true to enable it

  • improvement: clarify SUID/SGID options in readme

1.0.1

  • feature: remove some dangerous packages by default
  • improvement: added contributor guideline
  • bugfix: correctly enable sysrqs if desired
  • bugfix: determine ipv6 forwarding from user forwarding + ipv6 configuration
  • bugfix: determine ipv4 forwarding from user forwarding configuration

1.0.0

  • imported hardening project and updated to current version with full test suite

No quality metric results found