Skip to content

jacksonsteiner/POP22-CIS

Β 
Β 

Repository files navigation

UBUNTU 22 CIS

Configure a UBUNTU 22 machine to be CIS compliant


Public Repository πŸ“£

Org Stars Stars Forks Followers Twitter URL Discord Badge

License

Lint & Pre-Commit Tools πŸ”§

Pre-Commit.ci YamlLint Ansible-Lint

Community Release Information πŸ“‚

Release Branch Release Tag Main Release Date Benchmark Version Main Benchmark Version Devel

Main Pipeline Status

Devel Pipeline Status

Devel Commits Open Issues Closed Issues Pull Requests


Subscriber Release Information πŸ”

Private Release Branch Private Benchmark Version

Private Remediate Pipeline Private GPO Pipeline

Private Pull Requests Private Closed Issues


Looking for support? 🀝

Lockdown Enterprise

Ansible support

Community πŸ’¬

On our Discord Server to ask questions, discuss features, or just chat with other Ansible-Lockdown users


🚨 Caution(s) 🚨

This role will make changes to the system which may have unintended consequences. This is not an auditing tool but rather a remediation tool to be used after an audit has been conducted.

  • Testing is the most important thing you can do.

  • Check Mode is not guaranteed! 🚫 The role will complete in check mode without errors, but it is not supported and should be used with caution.

  • This role was developed against a clean install of the Operating System. If you are implementing to an existing system please review this role for any site specific changes that are needed.

  • To use release version please point to main branch and relevant release for the cis benchmark you wish to work with.

  • Did we mention testing??


Coming From A Previous Release βͺ

CIS release always contains changes, it is highly recommended to review the new references and available variables. This have changed significantly since ansible-lockdown initial release. This is now compatible with python3 if it is found to be the default interpreter. This does come with pre-requisites which it configures the system accordingly.

Further details can be seen in the Changelog


Matching a security Level for CIS

It is possible to only run level 1 or level 2 controls for CIS. This is managed using tags:

  • level1-server
  • level1-workstation
  • level2-server
  • level2-workstation

The control found in defaults main also need to reflect this as this control the testing that takes place if you are using the audit component.


Requirements βœ…

General:

  • Basic knowledge of Ansible, below are some links to the Ansible documentation to help get started if you are unfamiliar with Ansible

  • Functioning Ansible and/or Tower Installed, configured, and running. This includes all of the base Ansible/Tower configurations, needed packages installed, and infrastructure setup.

  • Please read through the tasks in this role to gain an understanding of what each control is doing. Some of the tasks are disruptive and can have unintended consequences in a live production system. Also familiarize yourself with the variables in the defaults/main.yml file.

Technical Dependencies:

UBUNTU 22 - Other versions are not supported.

  • Access to download or add the goss binary and content to the system if using auditing (other options are available on how to get the content to the system.)
  • Python3.8
  • Ansible 2.12+
  • python-def
  • libselinux-python

Auditing πŸ”

This can be turned on or off within the defaults/main.yml file with the variable run_audit. The value is false by default, please refer to the wiki for more details. The defaults file also populates the goss checks to check only the controls that have been enabled in the ansible role.

This is a much quicker, very lightweight, checking (where possible) config compliance and live/running settings.

A new form of auditing has been developed, by using a small (12MB) go binary called goss along with the relevant configurations to check. Without the need for infrastructure or other tooling. This audit will not only check the config has the correct setting but aims to capture if it is running with that configuration also trying to remove false positives in the process.

Refer to UBUNTU22-CIS-Audit.

Example Audit Summary

This is based on a vagrant image with selections enabled. e.g. No Gui or firewall. Note: More tests are run during audit as we check config and running state.

ok: [default] => {
    "msg": [
        "msg": [
        "The pre remediation audit results are: Count: 763, Failed: 234, Skipped: 4, Duration: 9.741s",
        "The post remediation audit results are: Count: 763, Failed: 19, Skipped: 4, Duration: 12.725s",
        "Full breakdown can be found in /opt",
        ""
    ]
}

PLAY RECAP *******************************************************************************************************************************************
default                    : ok=270  changed=23   unreachable=0    failed=0    skipped=140  rescued=0    ignored=0

Documentation πŸ“–

Role Variables

This role is designed that the end user should not have to edit the tasks themselves. All customizing should be done via the defaults/main.yml file or with extra vars within the project, job, workflow, etc.

Tags 🏷️

There are many tags available for added control precision. Each control has its own set of tags noting what level, what OS element it relates to, whether it's a patch or audit, and the rule number. Additionally, NIST references follow a specific conversion format for consistency and clarity.

Conversion Format for NIST References:

  1. Standard Prefix:
- All references are prefixed with "NIST".
  1. Standard Types:
- "800-53" references are formatted as NIST800-53.
- "800-53r5" references are formatted as NIST800-53R5 (with 'R' capitalized).
- "800-171" references are formatted as NIST800-171.
  1. Details:
- Section and subsection numbers use periods (.) for numeric separators.
- Parenthetical elements are separated by underscores (_), e.g., IA-5(1)(d) becomes IA-5_1_d.
- Subsection letters (e.g., "b") are appended with an underscore.

Below is an example of the tag section from a control within this role. Using this example if you set your run to skip all controls with the tag services, this task will be skipped. The opposite can also happen where you run only controls tagged with services.

      tags:
      - level1-server
      - level1-workstation
      - scored
      - avahi
      - services
      - patch
      - rule_2.2.4

Community Contribution πŸ§‘β€πŸ€β€πŸ§‘

We encourage you (the community) to contribute to this role. Please read the rules below.

  • Your work is done in your own individual branch. Make sure to Signed-off-by and GPG sign all commits you intend to merge.
  • All community Pull Requests are pulled into the devel branch
  • Pull Requests into devel will confirm your commits have a GPG signature, Signed-off-by, and a functional test before being approved
  • Once your changes are merged and a more detailed review is complete, an authorized member will merge your changes into the main branch for a new release

Pipeline Testing πŸ”„

uses:

  • ansible-core 2.16
  • ansible collections - pulls in the latest version based on requirements file
  • runs the audit using the devel branch
  • This is an automated test that occurs on pull requests into devel
  • self-hosted runners using OpenTofu

Known Issues

Local Testing πŸ’»

example

molecule test -s default
molecule converge -s wsl -- --check
molecule verify -s localhost

local testing uses:

  • ansible-core
  • molecule 4.0.1
  • molecule-docker 2.0.0
  • molecule-podman 2.0.2
  • molecule-vagrant 1.0.0
  • molecule-azure 0.5.0

Credits and Thanks πŸ™

Massive thanks to the fantastic community and all its members.

This includes a huge thanks and credit to the original authors and maintainers.

Mark Bolwell, George Nalen, Steve Williams, Fred Witty

About

Automated CIS Benchmark Compliance Remediation for Pop!_OS Ubuntu 22 with Ansible

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • YAML 87.2%
  • Jinja 12.8%