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

Fix rule ubtu 20 010072 #11074

Closed

Conversation

dexterle
Copy link
Contributor

@dexterle dexterle commented Sep 7, 2023

Description:

  • Fix UBTU-20-010072
  • Fix ansible remediation
  • Fix OVAL definition

Rationale:

Review Hints:

Build the product:

./build_product ubuntu2004

To test these changes with Ansible:

ansible-playbook build/ansible/ubuntu2004-playbook-stig.yml --tags "DISA-STIG-UBTU-20-010072"

To test changes with bash, run the remediation section: xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_audit

Checkout Manual STIG OVAL definitions, and use software like DISA STIG Viewer to view definitions.

git checkout dexterle:add-manual-stig-ubtu-20-v1r9

This STIG can be tested with the latest Ubuntu 2004 Benchmark SCAP. For reference, please review the latest artifacts: https://public.cyber.mil/stigs/downloads/

This commit will properly fix STIG by ensuring that the pam_faillock arguments are properly set in /etc/pam.d/common-auth and within /etc/security/faillok.conf.
This commit will fix oval checks for accounts-pam which includes regex modularization, and proper line remediations for /etc/pam.d/common-auth along with /etc/security/faillock.conf.
This commit will simplify conditional logic to use pam_path jinja assigned variable.
@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Used by openshift-ci bot. needs-ok-to-test Used by openshift-ci bot. labels Sep 7, 2023
@openshift-ci
Copy link

openshift-ci bot commented Sep 7, 2023

Hi @dexterle. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dexterle
Copy link
Contributor Author

dexterle commented Sep 7, 2023

feedback:
ee58feb#r1319035461
af5bbd3#r1319027544

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_account_passwords_pam_faillock_audit' differs.
--- xccdf_org.ssgproject.content_rule_account_passwords_pam_faillock_audit
+++ xccdf_org.ssgproject.content_rule_account_passwords_pam_faillock_audit
@@ -99,6 +99,16 @@
     when:
     - result_pam_faillock_is_enabled.found == 0
 
+  - name: Account Lockouts Must Be Logged - Enable pam_faillock.so authsucc editing
+      PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
   - name: Account Lockouts Must Be Logged - Enable pam_faillock.so authfail editing
       PAM files
     ansible.builtin.lineinfile:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_audit' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_audit
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_audit
@@ -106,6 +106,16 @@
     when:
     - result_pam_faillock_is_enabled.found == 0
 
+  - name: Account Lockouts Must Be Logged - Enable pam_faillock.so authsucc editing
+      PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
   - name: Account Lockouts Must Be Logged - Enable pam_faillock.so authfail editing
       PAM files
     ansible.builtin.lineinfile:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
@@ -137,6 +137,16 @@
     when:
     - result_pam_faillock_is_enabled.found == 0
 
+  - name: Lock Accounts After Failed Password Attempts - Enable pam_faillock.so authsucc
+      editing PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
   - name: Lock Accounts After Failed Password Attempts - Enable pam_faillock.so authfail
       editing PAM files
     ansible.builtin.lineinfile:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny_root' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny_root
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny_root
@@ -130,6 +130,16 @@
     - result_pam_faillock_is_enabled.found == 0
 
   - name: Configure the root Account for Failed Password Attempts - Enable pam_faillock.so
+      authsucc editing PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
+  - name: Configure the root Account for Failed Password Attempts - Enable pam_faillock.so
       authfail editing PAM files
     ansible.builtin.lineinfile:
       path: '{{ item }}'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
@@ -125,6 +125,16 @@
     when:
     - result_pam_faillock_is_enabled.found == 0
 
+  - name: Lock Accounts Must Persist - Enable pam_faillock.so authsucc editing PAM
+      files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
   - name: Lock Accounts Must Persist - Enable pam_faillock.so authfail editing PAM
       files
     ansible.builtin.lineinfile:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_enforce_local' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_enforce_local
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_enforce_local
@@ -119,6 +119,16 @@
     when:
     - result_pam_faillock_is_enabled.found == 0
 
+  - name: Enforce pam_faillock for Local Accounts Only - Enable pam_faillock.so authsucc
+      editing PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
   - name: Enforce pam_faillock for Local Accounts Only - Enable pam_faillock.so authfail
       editing PAM files
     ansible.builtin.lineinfile:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_interval' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_interval
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_interval
@@ -130,6 +130,16 @@
     - result_pam_faillock_is_enabled.found == 0
 
   - name: Set Interval For Counting Failed Password Attempts - Enable pam_faillock.so
+      authsucc editing PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
+  - name: Set Interval For Counting Failed Password Attempts - Enable pam_faillock.so
       authfail editing PAM files
     ansible.builtin.lineinfile:
       path: '{{ item }}'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_silent' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_silent
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_silent
@@ -124,6 +124,16 @@
     - result_pam_faillock_is_enabled.found == 0
 
   - name: Do Not Show System Messages When Unsuccessful Logon Attempts Occur - Enable
+      pam_faillock.so authsucc editing PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
+
+  - name: Do Not Show System Messages When Unsuccessful Logon Attempts Occur - Enable
       pam_faillock.so authfail editing PAM files
     ansible.builtin.lineinfile:
       path: '{{ item }}'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_unlock_time' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_unlock_time
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_unlock_time
@@ -139,6 +139,16 @@
     - /etc/pam.d/password-auth
     when:
     - result_pam_faillock_is_enabled.found == 0
+
+  - name: Set Lockout Time for Failed Password Attempts - Enable pam_faillock.so authsucc
+      editing PAM files
+    ansible.builtin.lineinfile:
+      path: /etc/pam.d/common-auth
+      line: auth        sufficient      pam_faillock.so authsucc
+      insertbefore: ^auth.*sufficient.*pam_unix\.so.*
+      state: present
+    when:
+    - not result_authselect_present.stat.exists
 
   - name: Set Lockout Time for Failed Password Attempts - Enable pam_faillock.so authfail
       editing PAM files

@codeclimate
Copy link

codeclimate bot commented Sep 8, 2023

Code Climate has analyzed commit fa50612 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 53.8% (0.0% change).

View more on Code Climate.

@marcusburghardt marcusburghardt added the Ubuntu Ubuntu product related. label Sep 8, 2023
@dodys dodys self-assigned this Sep 8, 2023
@dodys dodys added the STIG STIG Benchmark related. label Sep 8, 2023
@dexterle dexterle marked this pull request as ready for review September 11, 2023 14:17
@dexterle dexterle requested a review from a team as a code owner September 11, 2023 14:18
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Sep 11, 2023
@dodys dodys added ok-to-test Used by openshift-ci bot. and removed needs-ok-to-test Used by openshift-ci bot. labels Sep 11, 2023
@dodys
Copy link
Contributor

dodys commented Sep 11, 2023

/packit retest-failed

@dodys
Copy link
Contributor

dodys commented Sep 11, 2023

/test

@openshift-ci
Copy link

openshift-ci bot commented Sep 11, 2023

@dodys: The /test command needs one or more targets.
The following commands are available to trigger required jobs:

  • /test e2e-aws-ocp4-cis
  • /test e2e-aws-ocp4-cis-node
  • /test e2e-aws-ocp4-e8
  • /test e2e-aws-ocp4-high
  • /test e2e-aws-ocp4-high-node
  • /test e2e-aws-ocp4-moderate
  • /test e2e-aws-ocp4-moderate-node
  • /test e2e-aws-ocp4-pci-dss
  • /test e2e-aws-ocp4-pci-dss-node
  • /test e2e-aws-ocp4-stig
  • /test e2e-aws-ocp4-stig-node
  • /test e2e-aws-rhcos4-e8
  • /test e2e-aws-rhcos4-high
  • /test e2e-aws-rhcos4-moderate
  • /test e2e-aws-rhcos4-stig
  • /test images

Use /test all to run the following jobs that were automatically triggered:

  • pull-ci-ComplianceAsCode-content-master-images

In response to this:

/test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dodys
Copy link
Contributor

dodys commented Sep 11, 2023

/retest

Copy link
Contributor

@dodys dodys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not break the oval check into multiple checks, that is the only way to test the order of configuration, because it matters.
Also DISA's configuration is missing the preauth IMO

@openshift-merge-robot openshift-merge-robot added the needs-rebase Used by openshift-ci bot. label Sep 16, 2023
@openshift-merge-robot
Copy link
Collaborator

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dodys
Copy link
Contributor

dodys commented Dec 7, 2023

closing this in favor of #11355

@dodys dodys closed this Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Used by openshift-ci bot. ok-to-test Used by openshift-ci bot. STIG STIG Benchmark related. Ubuntu Ubuntu product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants