Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds EL9 hardening-content per Issue 496 #506

Merged
merged 84 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6541eb8
Set up directory-structure
ferricoxide May 6, 2024
d34759e
Update caution-message
ferricoxide May 8, 2024
83f1569
Update description-block
ferricoxide May 8, 2024
b6e0ec7
Stub content
ferricoxide May 8, 2024
9d10898
Add handler for RHEL-09-255065
ferricoxide May 8, 2024
5fbffc8
This needs to reference client-config
ferricoxide May 8, 2024
777090b
Ensure appropriate 'Include's are present
ferricoxide May 8, 2024
4d7e142
Null out (for now)
ferricoxide May 29, 2024
7d446c3
Rules that don't yet have STIG-IDs
ferricoxide May 29, 2024
61c13c7
Force use of tmux on shell-logins
ferricoxide May 29, 2024
2269f1f
Lock session after specified idle time
ferricoxide May 29, 2024
dc9ee30
Remove ID-conflicts
ferricoxide May 29, 2024
63c3e1a
Break ID conflicts
ferricoxide May 29, 2024
5c9e002
Add SELinux contexts
ferricoxide May 30, 2024
fdc7ff2
Avoid state-ID collisions
ferricoxide May 30, 2024
7e6f3a6
Add tmux lock-command handler
ferricoxide May 30, 2024
53d591e
Fix whitespace
ferricoxide May 30, 2024
2328e99
Fix requisites' reference-IDs
ferricoxide May 30, 2024
98990cc
Add handler for rsyslog remote-logging task
ferricoxide May 30, 2024
16586cb
Add initial sudoers password-enforcement logic
ferricoxide May 30, 2024
0909ac3
Invoke sudoers password-enforcement logic
ferricoxide May 30, 2024
9fb0099
Warn for violations
ferricoxide May 30, 2024
0d84128
Skip '90-cloud-init-users' file
ferricoxide May 30, 2024
cb590cc
Implement safing-logic
ferricoxide May 30, 2024
f10d29a
Prevent ID collisions
ferricoxide May 30, 2024
d256235
"Handler" for non-redundant client-DNS configuration
ferricoxide May 30, 2024
320fa58
Ensure `noexec` option present on /tmp
ferricoxide May 30, 2024
5ccc5db
Ensure default mount-opts are preserved
ferricoxide May 31, 2024
2fd234b
Prevent option-duplication
ferricoxide May 31, 2024
230ebca
Set root user's "real" email-destination
ferricoxide May 31, 2024
f535bb0
Standardize state-labeling
ferricoxide May 31, 2024
da770e2
Fix pattern logic
ferricoxide May 31, 2024
55dd36f
Use 'not_found_content
ferricoxide May 31, 2024
2706e49
correct indentation-foul
ferricoxide May 31, 2024
71a5ea7
Fix case of identifiers strings
ferricoxide May 31, 2024
cc7c036
Add handler-skipping logic
ferricoxide May 31, 2024
10ba186
Close note-block
ferricoxide May 31, 2024
f3c4b10
Use `server` directives for Chrony service
ferricoxide May 31, 2024
874f4e9
Change NTP-usage toggle
ferricoxide May 31, 2024
7bd142c
Fix bool-ref
ferricoxide May 31, 2024
f5c1ac9
Remediations for SSH and FirewallD
ferricoxide Jun 3, 2024
c55f18d
Ensure ssh service activated in firewalld
ferricoxide Jun 3, 2024
d03241a
Also explicitly enable in each zone
ferricoxide Jun 3, 2024
5502df6
Fix match-condition
ferricoxide Jun 3, 2024
f8274b3
change link-type
ferricoxide Jun 3, 2024
8fc5a95
Add conversion to NM-keyfile logic
ferricoxide Jun 3, 2024
8d4f1a3
Re-order sections
ferricoxide Jun 3, 2024
5bff79a
Add a 'brake' to make order more rigid
ferricoxide Jun 3, 2024
243f8f4
Set UEFI bootloader password
ferricoxide Jun 3, 2024
33f21cf
Ensure tmux not in /etc/shells
ferricoxide Jun 4, 2024
9e79abb
change to file.replace
ferricoxide Jun 4, 2024
d55c7f0
Organize by priority
ferricoxide Jun 4, 2024
32aa081
Fix 'stig_id' reference
ferricoxide Jun 4, 2024
a6e95d9
Add configuration-content
ferricoxide Jun 4, 2024
f742d5d
Make finding-levels executable as groups
ferricoxide Jun 4, 2024
99c4350
get rid of spurious requisite
ferricoxide Jun 4, 2024
3577f4a
Fix case
ferricoxide Jun 4, 2024
6b38279
Customize GRUB2 super-user name
ferricoxide Jun 4, 2024
90c989d
Make GRUB2 info-file sharable
ferricoxide Jun 4, 2024
3311a11
Fix grub command
ferricoxide Jun 4, 2024
1142b28
Fix regex and replacement
ferricoxide Jun 4, 2024
7aacd27
Fixing the 'not found content'
ferricoxide Jun 4, 2024
90d397d
Make dependabot look for GitHub Actions
ferricoxide Jun 5, 2024
99eac5f
Update with upstream commit-id
ferricoxide Jun 5, 2024
580cf55
Removed CentOS handlers per request
ferricoxide Jul 2, 2024
3e00d16
Remove (redundant) 'Brake' state
ferricoxide Jul 2, 2024
3788cf4
Update skip-logic
ferricoxide Jul 2, 2024
e0b2102
Restore regex test
ferricoxide Jul 2, 2024
e523a56
Need to replace 'NOPASSWD' w/ 'PASSWD'
ferricoxide Jul 2, 2024
868d0ad
Get rid of redundant 'unless' block
ferricoxide Jul 2, 2024
a301147
Shorthand it (for easier readability)
ferricoxide Jul 2, 2024
a356bc8
Move 'undo' logic to (new) undo state-file
ferricoxide Jul 2, 2024
b0add0b
Fix per comment
ferricoxide Jul 10, 2024
d5aa920
Avoid 'cant concat list string' error
ferricoxide Jul 10, 2024
e434f98
Add match-logic for CentOS
ferricoxide Jul 10, 2024
3c54178
Package no longer seems to be necessary
ferricoxide Jul 10, 2024
73cc4d0
Add test-condition for EL9
ferricoxide Jul 10, 2024
07dc23f
Update ash-linux/el9/VendorSTIG/init.sls
ferricoxide Jul 10, 2024
6448179
Update ash-linux/el9/VendorSTIG/packages.sls
ferricoxide Jul 10, 2024
cd7a853
Update ash-linux/el9/VendorSTIG/remediate.sls
ferricoxide Jul 10, 2024
13aeff4
Update ash-linux/el9/VendorSTIG/report.sls
ferricoxide Jul 10, 2024
633d763
Forgot to carry over sudoerFiles definition
ferricoxide Jul 10, 2024
d9e7e55
Update ash-linux/el9/RuleById/medium/content_rule_configure_tmux_lock…
ferricoxide Aug 2, 2024
5b0bdb2
Update ash-linux/el9/STIGbyID/cat2/RHEL-09-255065.sls
ferricoxide Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
version: 2
updates:
- package-ecosystem: docker
directory: "/tests/docker/centos7"
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
open-pull-requests-limit: 10
interval: weekly
# Maintain dependencies for root dockerfile
- package-ecosystem: docker
directory: "/tests/docker/centos8"
directory: /
schedule:
interval: daily
open-pull-requests-limit: 10
interval: weekly
...
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
ferricoxide marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ concurrency:

jobs:
test:
uses: plus3it/actions-workflows/.github/workflows/test-salt-linux.yml@b1b7bdb32125ccb05afa36909954a75b9f2ab431
uses: plus3it/actions-workflows/.github/workflows/test-salt-linux.yml@72a8659c8716b3fbf6e9ea01b53b2f83c0b6d6d8
strategy:
matrix:
os_version:
- 7
- 8
- 9
salt_state:
- ash-linux.iavm
- ash-linux.stig
Expand Down
10 changes: 9 additions & 1 deletion ash-linux/el8/STIGbyID/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ include:
Print ash-linux el8 stig baseline help:
test.show_notification:
- text: |
The full, item-by-item `ash-linux.stig` baseline for EL8 is in beta.
The full, item-by-item `ash-linux.stig` baseline for EL8 is known to
"over-harden" some systems to the point that they cannot be used for
their intended workloads.

Use this content at your own risk.

If you choose to use this content and it causes issues for you, you can
block the configuration of some items by setting up exclusions in the
Pillar-content for this project. See the `skip-stigs` setting in the
project's `pillar.example` file.
7 changes: 7 additions & 0 deletions ash-linux/el9/Nessus/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Print ash-linux el9 Nessus baseline help:
test.show_notification:
- text: |
The ash-linux Nessus baseline for EL9 has no current known findings or
remediation actions. This state is provided only as a notification
message and a placeholder. On its own, this state does not modify the
system in any way.
Empty file added ash-linux/el9/RuleById/.gitkeep
Empty file.
12 changes: 12 additions & 0 deletions ash-linux/el9/RuleById/common/grub2_info.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{%- set grubUser = salt.pillar.get('ash-linux:lookup:grub-user', 'grubuser') %}
{%- set grubClearPass = salt.pillar.get('ash-linux:lookup:grub-passwd', 'AR34llyB4dP4ssw*rd') %}

{%-
set grubEncryptedPass = salt.cmd.shell(
'printf "%s\n%s\n" "' + grubClearPass + '" "' + grubClearPass + '" |
/bin/grub2-mkpasswd-pbkdf2 |
grep "hash of" |
sed "s/^.* is //"',
ignore_retcode=True
)
%}
181 changes: 181 additions & 0 deletions ash-linux/el9/RuleById/high/content_rule_grub2_uefi_password.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Rule ID: content_rule_grub2_uefi_password
# Finding Level: high
#
# Rule Summary:
# The grub2 boot loader should have a superuser account and password
# protection enabled to protect boot-time settings.
#
# Identifiers:
# - content_rule_grub2_uefi_password
#
# References:
# - ANSSI
# - BP28(R17)
# - CIS-CSC
# - 11
# - 12
# - 14
# - 15
# - 16
# - 18
# - 3
# - 5
# - COBIT5
# - DSS05.02
# - DSS05.04
# - DSS05.05
# - DSS05.07
# - DSS06.03
# - DSS06.06
# - CUI
# - 3.4.5
# - DISA
# - CCI-000213
# - HIPAA
# - 164.308(A)(1)(II)(B)
# - 164.308(a)(7)(i)
# - 164.308(a)(7)(ii)(A)
# - 164.310(a)(1)
# - 164.310(a)(2)(i)
# - 164.310(a)(2)(ii)
# - 164.310(a)(2)(iii)
# - 164.310(b)
# - 164.310(c)
# - 164.310(d)(1)
# - 164.310(d)(2)(iii)
# - ISA-62443-2009
# - 4.3.3.2.2
# - 4.3.3.5.1
# - 4.3.3.5.2
# - 4.3.3.5.3
# - 4.3.3.5.4
# - 4.3.3.5.5
# - 4.3.3.5.6
# - 4.3.3.5.7
# - 4.3.3.5.8
# - 4.3.3.6.1
# - 4.3.3.6.2
# - 4.3.3.6.3
# - 4.3.3.6.4
# - 4.3.3.6.5
# - 4.3.3.6.6
# - 4.3.3.6.7
# - 4.3.3.6.8
# - 4.3.3.6.9
# - 4.3.3.7.1
# - 4.3.3.7.2
# - 4.3.3.7.3
# - 4.3.3.7.4
# - ISA-62443-2013
# - SR 1.1
# - SR 1.10
# - SR 1.11
# - SR 1.12
# - SR 1.13
# - SR 1.2
# - SR 1.3
# - SR 1.4
# - SR 1.5
# - SR 1.6
# - SR 1.7
# - SR 1.8
# - SR 1.9
# - SR 2.1
# - SR 2.2
# - SR 2.3
# - SR 2.4
# - SR 2.5
# - SR 2.6
# - SR 2.7
# - ISO27001-2013
# - A.6.1.2
# - A.7.1.1
# - A.9.1.2
# - A.9.2.1
# - A.9.2.3
# - A.9.4.1
# - A.9.4.4
# - A.9.4.5
# - NIST
# - CM-6(A)
# - NIST-CSF
# - PR.AC-4
# - PR.AC-6
# - PR.PT-3
# - OSPP
# - FIA_UAU.1
# - OS-SRG
# - SRG-OS-000080-GPOS-00048
#
################################################################################
{%- set stig_id = 'grub2_uefi_password' %}
{%- set helperLoc = tpldir ~ '/files' %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ '/el9/RuleById/common/grub2_info.jinja' import grubEncryptedPass with context %}
{%- from tplroot ~ '/el9/RuleById/common/grub2_info.jinja' import grubUser with context %}
{%- set skipIt = salt.pillar.get('ash-linux:lookup:skip-stigs', []) %}
{%- set mustSet = salt.pillar.get('ash-linux:lookup:grub-passwd', '') %}
{%- set grubUserFile = '/etc/grub.d/01_users' %}
{%- set grubPassFile = '/boot/grub2/user.cfg' %}
{%- set grubUtil = '/bin/grub2-mkpasswd-pbkdf2' %}

{{ stig_id }}-description:
test.show_notification:
- text: |
--------------------------------------------
STIG Finding ID: {{ stig_id }}
The grub2 boot loader should have a
superuser account and password protection
enabled to protect boot-time settings.
--------------------------------------------

{%- if stig_id in skipIt %}
notify_{{ stig_id }}-skipSet:
test.show_notification:
- text: |
Handler for {{ stig_id }} has been selected for skip.
{%- elif salt.file.directory_exists('/sys/firmware/efi') %}

# Ensure password-containing file exists
user_cfg_exists-{{ stig_id }}:
file.touch:
- name: '{{ grubPassFile }}'
- makedirs: True
- unless:
- '[[ -e {{ grubPassFile }} ]]'

# Add password to user password file
user_cfg_content-{{ stig_id }}-present:
file.replace:
- name: '{{ grubPassFile }}'
- append_if_not_found: True
- not_found_content: |-
GRUB2_PASSWORD={{ grubEncryptedPass }}
- pattern: '^(\s*GRUB2_PASSWORD=).*$'
- repl: 'GRUB2_PASSWORD={{ grubEncryptedPass }}'
- require:
- file: user_cfg_exists-{{ stig_id }}

# Ensure proper permissions (etc.)
user_cfg_content-{{ stig_id }}-secmode:
file.managed:
- name: '{{ grubPassFile }}'
- group: 'root'
- require:
- file: user_cfg_content-{{ stig_id }}-present
- selinux:
serange: 's0'
serole: 'object_r'
setype: 'boot_t'
seuser: 'system_u'

{%- else %}
Why Skip ({{ stig_id }}) - No EFI Support:
notify_{{ stig_id }}-skipSet:
test.show_notification:
- text: |
---------------------------------------
This system does not support UEFI-boot
---------------------------------------
{%- endif %}
2 changes: 2 additions & 0 deletions ash-linux/el9/RuleById/high/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include:
- ash-linux.el9.RuleById.high.content_rule_grub2_uefi_password
4 changes: 4 additions & 0 deletions ash-linux/el9/RuleById/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include:
- ash-linux.el9.RuleById.high
- ash-linux.el9.RuleById.medium
- ash-linux.el9.RuleById.low
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Rule ID: content_rule_configure_usbguard_auditbackend
# Finding Level: low
#
# Rule Summary:
# Configure USBGuard daemon to log via Linux Audit service by setting the
# `AuditBackend` option in the `/etc/usbguard/usbguard-daemon.conf`
# file to `LinuxAudit`
#
# Identifiers:
# - content_rule_configure_usbguard_auditbackend
#
# References:
# - DISA
# - CCI-000169
# - CCI-000172
# - NIST
# - AU-2
# - CM-8(3)
# - IA-3
# - OSPP
# - FMT_SMF_EXT.1
# - OS-SRG
# - SRG-OS-000062-GPOS-00031
# - SRG-OS-000471-GPOS-00215
# - APP-SRG
# - SRG-APP-000141-CTR-000315
#
#################################################################
{%- set stig_id = 'configure_usbguard_auditbackend' %}
{%- set helperLoc = tpldir ~ '/files' %}
{%- set skipIt = salt.pillar.get('ash-linux:lookup:skip-stigs', []) %}
{%- set cfgFile = '/etc/usbguard/usbguard-daemon.conf' %}

{{ stig_id }}-description:
test.show_notification:
- text: |
--------------------------------------
STIG Finding ID: {{ stig_id }}:
Configure USBGuard daemon to log via
Linux Audit service
--------------------------------------

{%- if stig_id in skipIt %}
notify_{{ stig_id }}-skipSet:
test.show_notification:
- text: |
Handler for {{ stig_id }} has been selected for skip.
{%- else %}
# Ensure file-protections
{{ cfgFile }} - Exists:
file.managed:
- name: '{{ cfgFile }}'
- mode: '0600'
- user: 'root'
- group: 'root'
- selinux:
serange: 's0'
serole: 'object_r'
setype: 'usbguard_conf_t'
seuser: 'system_u'

# Make config-change
{{ cfgFile }} - Update content:
file.replace:
- name: '{{ cfgFile }}'
- append_if_not_found: True
- not_found_content: |-
# Set per rule '{{ stig_id }}'
AuditBackend=LinuxAudit
- pattern: '^(|\s*)(AuditBackend)=.*$'
- repl: '# Set per rule "{{ stig_id }}"\n\2=LinuxAudit'
- require:
- file: {{ cfgFile }} - Exists
- unless:
- '[[ $( grep AuditBackend=LinuxAudit {{ cfgFile }} ) ]]'

{%- endif %}
52 changes: 52 additions & 0 deletions ash-linux/el9/RuleById/low/content_rule_no_tmux_in_shells.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Rule ID: content_rule_no_tmux_in_shells
# Finding Level: low
#
# Rule Summary:
# The tmux terminal multiplexer is used to implement automatic session
# locking. It should not be listed in /etc/shells.
#
# Identifiers:
# - content_rule_no_tmux_in_shells
#
# References:
# - DISA
# - CCI-000056
# - CCI-000058
# - NIST
# - CM-6
# - OSPP
# - FMT_SMF_EXT.1
# - FMT_MOF_EXT.1
# - FTA_SSL.1
# - OS-SRG
# - SRG-OS-000324-GPOS-00125
# - SRG-OS-000028-GPOS-00009
# - SRG-OS-000030-GPOS-00011
#
#################################################################
{%- set stig_id = 'no_tmux_in_shells' %}
{%- set helperLoc = tpldir ~ '/files' %}
{%- set skipIt = salt.pillar.get('ash-linux:lookup:skip-stigs', []) %}
{%- set cfgFile = '/etc/shells' %}

{{ stig_id }}-description:
test.show_notification:
- text: |
--------------------------------------
STIG Finding ID: {{ stig_id }}:
`tmux` should not exist in the
`/etc/shells` file
--------------------------------------

{%- if stig_id in skipIt %}
notify_{{ stig_id }}-skipSet:
test.show_notification:
- text: |
Handler for {{ stig_id }} has been selected for skip.
{%- else %}
Ensure tmux not in {{ cfgFile }}:
file.replace:
- name: '{{ cfgFile }}'
- pattern: '^.*/tmux\n'
- repl: ''
{%- endif %}
3 changes: 3 additions & 0 deletions ash-linux/el9/RuleById/low/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include:
- ash-linux.el9.RuleById.low.content_rule_configure_usbguard_auditbackend
- ash-linux.el9.RuleById.low.content_rule_no_tmux_in_shells
Loading
Loading