From 6106fa658d30712d2ec5a7337b5d26e067cd9e31 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 5 Jan 2017 13:09:42 -0700 Subject: [PATCH] Add CAT2 Password Requirements (#6) * RHEL-07-010040 Adds /etc/issue login banner * RHEL-07-010090 Password Requirements Require at least 1 uppercase character * RHEL-07-010100 Password Requirements Require at least 1 lower case character * RHEL-07-010110 Password Requirements Require at least one numeric character * RHEL7-07-010120 Password Requirements Require at least one special character * RHEL-07-010130 Password Requirements Minimum of 8 characters difference when changing passwords * RHEL-07-010140 Password Requirements Require the change of at least four character classes when passwords are changed * RHEL-07-010150 Password Requirements Enforce a max of 4 repeating characters * RHEL-07-010160 Password Requirements Enforce max of 4 repeating characters of the same character class * RHEL-07-010200 Password Requirements Require 24 hours minimum lifetime of passwords * RHEL-07-010210 Password Requirements Restrict passwords to 24 hour minimum lifetime * RHEL-07-010220 Password Requirements Passwords restricted to max lifetime of 60 days for new users * RHEL-07-010230 Password Requirements Restrict password lifetime to 60days for existing users. * RHEL-07-010240 Password Requirements Passwords must be prohibited from reuse for a minimum of 5 generations * RHEL-07-010250 Password Requirements Passwords must be a minimum of 15 characters in length * RHEL-07-010040 Use copy module for login banner Changed template to copy since the issue file is in the files/ dir * RHEL-07-010200 | RHEL-07-010220 Fix Typo updated lien to line --- files/issue | 13 ++++++++ tasks/audit-cat2.yml | 24 +++++++++++++++ tasks/fix-cat2.yml | 72 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 files/issue diff --git a/files/issue b/files/issue new file mode 100644 index 0000000..586b8ad --- /dev/null +++ b/files/issue @@ -0,0 +1,13 @@ +"You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only. + +By using this IS (which includes any device attached to this IS), you consent to the following conditions: + +-The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations. + +-At any time, the USG may inspect and seize data stored on this IS. + +-Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose. + +-This IS includes security measures (e.g., authentication and access controls) to protect USG interests--not for your personal benefit or privacy. + +-Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details." \ No newline at end of file diff --git a/tasks/audit-cat2.yml b/tasks/audit-cat2.yml index ea7f9ef..c1b6e54 100644 --- a/tasks/audit-cat2.yml +++ b/tasks/audit-cat2.yml @@ -1,3 +1,27 @@ +- name: "MEDIUM | RHEL-07-010210 | AUDIT | Passwords must be restricted to a 24 hours/1 day minimum lifetime." + command: "awk -F: '$4 < 1 {print $1}' /etc/shadow" + register: rhel_07_010210_audit + failed_when: no + changed_when: no + ignore_errors: yes + tags: + - cat2 + - medium + - audit + - RHEL-07-010210 + +- name: "MEDIUM | RHEL-07-010230 | AUDIT | Passwords must be restricted to a 24 hours/1 day minimum lifetime." + command: "awk -F: '$5 > 60 {print $1}' /etc/shadow" + register: rhel_07_010230_audit + failed_when: no + changed_when: no + ignore_errors: yes + tags: + - cat2 + - medium + - audit + - RHEL-07-010230 + - name: "MEDIUM | RHEL-07-040180 | AUDIT | The operating system must implement cryptography to protect the integrity of Lightweight Directory Access Protocol (LDAP) authentication communications." command: grep -i useldapauth /etc/sysconfig/authconfig register: rhel_07_040180_audit diff --git a/tasks/fix-cat2.yml b/tasks/fix-cat2.yml index b8cad8e..1726be0 100644 --- a/tasks/fix-cat2.yml +++ b/tasks/fix-cat2.yml @@ -15,7 +15,11 @@ - RHEL-07-010031 - name: "MEDIUM | RHEL-07-010040 | PATCH | The operating system must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a command line user logon." - command: "true" + copy: + src: issue + dest: /etc/issue + owner: root + mode: 0644 tags: - cat2 - medium @@ -71,7 +75,10 @@ - RHEL-07-010073 - name: "MEDIUM | RHEL-07-010090 | PATCH | When passwords are changed or new passwords are established, the new password must contain at least one upper-case character." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?ucredit + line: ucredit = -1 tags: - cat2 - medium @@ -79,7 +86,10 @@ - RHEL-07-010090 - name: "MEDIUM | RHEL-07-010100 | PATCH | When passwords are changed or new passwords are established, the new password must contain at least one lower-case character." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?lcredit + line: lcredit = -1 tags: - cat2 - medium @@ -87,7 +97,10 @@ - RHEL-07-010100 - name: "MEDIUM | RHEL-07-010110 | PATCH | When passwords are changed or new passwords are assigned, the new password must contain at least one numeric character." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?dcredit + line: dcredit = -1 tags: - cat2 - medium @@ -95,7 +108,10 @@ - RHEL-07-010110 - name: "MEDIUM | RHEL-07-010120 | PATCH | When passwords are changed or new passwords are assigned, the new password must contain at least one special character." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?ocredit + line: ocredit = -1 tags: - cat2 - medium @@ -103,7 +119,10 @@ - RHEL-07-010120 - name: "MEDIUM | RHEL-07-010130 | PATCH | When passwords are changed a minimum of eight of the total number of characters must be changed." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?difok + line: difok = 8 tags: - cat2 - medium @@ -111,7 +130,10 @@ - RHEL-07-010130 - name: "MEDIUM | RHEL-07-010140 | PATCH | When passwords are changed a minimum of four character classes must be changed." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?minclass + line: minclass = 4 tags: - cat2 - medium @@ -119,7 +141,10 @@ - RHEL-07-010140 - name: "MEDIUM | RHEL-07-010150 | PATCH | When passwords are changed the number of repeating consecutive characters must not be more than four characters." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?maxrepeat + line: maxrepeat = 2 tags: - cat2 - medium @@ -127,7 +152,10 @@ - RHEL-07-010150 - name: "MEDIUM | RHEL-07-010160 | PATCH | When passwords are changed the number of repeating characters of the same character class must not be more than four characters." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?maxclassrepeat + line: maxclassrepeat = 4 tags: - cat2 - medium @@ -159,7 +187,10 @@ - RHEL-07-010190 - name: "MEDIUM | RHEL-07-010200 | PATCH | Passwords for new users must be restricted to a 24 hours/1 day minimum lifetime." - command: "true" + lineinfile: + dest: /etc/login.defs + regexp: (?i)^#?PASS_MIN_DAYS + line: PASS_MIN_DAYS 1 tags: - cat2 - medium @@ -167,7 +198,8 @@ - RHEL-07-010200 - name: "MEDIUM | RHEL-07-010210 | PATCH | Passwords must be restricted to a 24 hours/1 day minimum lifetime." - command: "true" + command: chage -m 1 {{ item }} + with_items: "{{ rhel_07_010210_audit.stdout_lines }}" tags: - cat2 - medium @@ -175,7 +207,10 @@ - RHEL-07-010210 - name: "MEDIUM | RHEL-07-010220 | PATCH | Passwords for new users must be restricted to a 60-day maximum lifetime." - command: "true" + lineinfile: + dest: /etc/login.defs + regexp: (?i)^#?PASS_MAX_DAYS + line: PASS_MAX_DAYS 60 tags: - cat2 - medium @@ -183,7 +218,8 @@ - RHEL-07-010220 - name: "MEDIUM | RHEL-07-010230 | PATCH | Existing passwords must be restricted to a 60-day maximum lifetime." - command: "true" + command: chage -M 60 {{ item }} + with_items: "{{ rhel_07_010230_audit.stdout_lines }}" tags: - cat2 - medium @@ -191,7 +227,10 @@ - RHEL-07-010230 - name: "MEDIUM | RHEL-07-010240 | PATCH | Passwords must be prohibited from reuse for a minimum of five generations." - command: "true" + lineinfile: + dest: /etc/pam.d/system-auth + regexp: password\s*sufficient\s*pam_unix.so + line: password sufficient pam_unix.so sha512 shadow try_first_pass use_authtok remember=5 tags: - cat2 - medium @@ -199,7 +238,10 @@ - RHEL-07-010240 - name: "MEDIUM | RHEL-07-010250 | PATCH | Passwords must be a minimum of 15 characters in length." - command: "true" + lineinfile: + dest: /etc/security/pwquality.conf + regexp: ^#?\s?minlen + line: minlen = 15 tags: - cat2 - medium