-
Notifications
You must be signed in to change notification settings - Fork 145
/
fix-cat2.yml
4791 lines (4499 loc) · 188 KB
/
fix-cat2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
- name: "MEDIUM | RHEL-07-010019 | PATCH | RHEL 7 must ensure cryptographic verification of vendor software packages."
block:
- name: "MEDIUM | RHEL-07-010019 | PATCH | RHEL 7 must ensure cryptographic verification of vendor software packages. | package installed"
ansible.builtin.package:
name: "{{ gpg_package }}"
state: present
when: "gpg_package not in ansible_facts.packages"
- name: "MEDIUM | RHEL-07-010019 | AUDIT | RHEL 7 must ensure cryptographic verification of vendor software packages. | Confirm keys"
ansible.builtin.shell: "gpg -q --keyid-format short --with-fingerprint {{ rpm_gpg_key }} | grep -A1 '{{ item.name }}' | grep '{{ item.fingerprint }}'"
changed_when: false
failed_when: rhel_07_010019_gpg_info.rc not in [ 0, 1]
register: rhel_07_010019_gpg_info
loop: "{{ gpg_keys }}"
loop_control:
label: item.name
- name: "MEDIUM | RHEL-07-010019 | AUDIT | RHEL 7 must ensure cryptographic verification of vendor software packages. | warn"
ansible.builtin.debug:
msg:
- "WARNING!! Please investigate the vendor gpgkeys match expected values"
loop: "{{ rhel_07_010019_gpg_info.results }}"
when: item.rc != 0
when:
- rhel_07_010019
tags:
- RHEL-07-010019
- CAT2
- CCI-001749
- SRG-OS-000366-GPOS-00153
- SV-256968r902687_rule
- V-256968
### RHEL-07-010030 | RHEL-07-010040 combined as related tasks in regards to a config file no other content will be in.
- name: "MEDIUM | RHEL-07-010030 | RHEL-07-010040 | PATCH | The Red Hat Enterprise Linux operating system must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a graphical user logon."
ansible.builtin.copy: # noqa: template-instead-of-copy
dest: /etc/dconf/db/local.d/01-banner-message
content: |
[org/gnome/login-screen]
banner-message-enable=true
banner-message-text='{{ rhel7stig_logon_banner | replace(newline, "\n") }}'
mode: '0644'
vars:
newline: "\n"
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010030
- rhel_07_010040
tags:
- CAT2
- RHEL-07-010030
- CCI-000048
- SRG-OS-000023-GPOS-00006
- SV-204393r603261_rule
- V-204393
- RHEL_07_010040
- SV-204394r603261_rule
- V-204394
- dod_logon_banner
- name: "MEDIUM | RHEL-07-010050 | PATCH | The Red Hat Enterprise Linux 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."
ansible.builtin.copy:
content: "{{ rhel7stig_logon_banner }}" # noqa: template-instead-of-copy
dest: "{{ item }}"
owner: root
group: root
mode: 0644
with_items:
- /etc/issue
- /etc/issue.net
when:
- rhel_07_010050
- rhel7stig_ssh_required
tags:
- RHEL-07-010050
- CAT2
- CCI-000048
- SRG-OS-000023-GPOS-00006
- SV-204395r603261_rule
- V-204395
- ssh
- dod_logon_banner
- name: "MEDIUM | RHEL-07-010060 | PATCH | The Red Hat Enterprise Linux operating system must enable a user session lock until that user re-establishes access using established identification and authentication procedures."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/00-screensaver_rhel_07_010060
content: |
[org/gnome/desktop/screensaver]
lock-enabled=true
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010060
tags:
- RHEL-07-010060
- CAT2
- CCI-000056
- SRG-OS-000028-GPOS-00009
- SV-204396r880746_rule
- V-204396
- dconf
- name: "MEDIUM | RHEL-07-010061 | PATCH | The Red Hat Enterprise Linux operating system must uniquely identify and must authenticate users using multifactor authentication via a graphical user logon."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/00-defaults_rhel_07_010061
content: |
[org/gnome/login-screen]
enable-smartcard-authentication=true
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010061
tags:
- RHEL-07-010061
- CAT2
- CCI-001948
- CCI-001953
- CCI-001954
- SRG-OS-000375-GPOS-00160
- SV-204397r603261_rule
- V-204397
- dconf
- name: "MEDIUM | RHEL-07-010062 | The Red Hat Enterprise Linux operating system must prevent a user from overriding the screensaver lock-enabled setting for the graphical user interface."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/locks/session_rhel_07_010062
content: |
/org/gnome/desktop/screensaver/lock-enabled
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010062
tags:
- RHEL-07-010062
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-214937r880767_rule
- V-214937
- dconf
- name: "MEDIUM | RHEL-07-010063 | PATCH | The Red Hat Enterprise Linux operating system must disable the login screen user list for graphical user interfaces."
block:
- name: "MEDIUM | RHEL-07-010063 | PATCH | The Red Hat Enterprise Linux operating system must disable the login screen user list for graphical user interfaces. | login_screen"
ansible.builtin.lineinfile:
path: /etc/dconf/db/local.d/00-login-screen
line: "{{ item }}"
mode: '0644'
create: true
loop:
- [org/gnome/login-screen]
- disable-user-list=true
notify: dconf update
- name: "MEDIUM | RHEL-07-010063 | PATCH | The Red Hat Enterprise Linux operating system must disable the login screen user list for graphical user interfaces. | gdm profile"
ansible.builtin.lineinfile:
path: /etc/dconf/profile/gdm
line: "{{ item }}"
mode: '0644'
create: true
loop:
- user-db:user
- system-db:gdm
- file-db:/usr/share/gdm/greeter-dconf-defaults
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010063
tags:
- RHEL-07-010063
- CAT2
- CCI-000366
- SRG-OS-000480-GPOS-00227
- SV-256969r902690_rule
- V-256969
- dconf
- name: "MEDIUM | RHEL-07-010070 | PATCH | The Red Hat Enterprise Linux operating system must initiate a screensaver after a 15-minute period of inactivity for graphical user interfaces."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/00-screensaver_rhel_07_010070
content: |
[org/gnome/desktop/session]
idle-delay=uint32 900
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010070
tags:
- RHEL-07-010070
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-204398r880770_rule
- V-204398
- dconf
- name: "MEDIUM | RHEL-07-010081 | PATCH | The Red Hat Enterprise Linux operating system must prevent a user from overriding the screensaver lock-delay setting for the graphical user interface."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/locks/session_rhel_07_010081
content: |
/org/gnome/desktop/screensaver/lock-delay
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010081
tags:
- RHEL-07-010081
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-204399r880773_rule
- V-204399
- dconf
- name: "MEDIUM | RHEL-07-010082 | PATCH | The Red Hat Enterprise Linux operating system must prevent a user from overriding the session idle-delay setting for the graphical user interface."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/locks/session_rhel_07_010082
content: |
/org/gnome/desktop/session/idle-delay
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010082
tags:
- RHEL-07-010082
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-204400r880776_rule
- V-204400
- dconf
- name: "MEDIUM | RHEL-07-010090 | PATCH | The Red Hat Enterprise Linux operating system must have the screen package installed."
ansible.builtin.package:
name: screen
state: present
when:
- rhel_07_010090
- "'screen' not in ansible_facts.packages"
- "'tmux' not in ansible_facts.packages"
tags:
- RHEL-07-010090
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-255926r880779_rule
- V-255926
- screen
- name: "MEDIUM | RHEL-07-010100 | PATCH | The Red Hat Enterprise Linux operating system must initiate a session lock for the screensaver after a period of inactivity for graphical user interfaces."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/00-screensaver_rhel_07_010100
content: |
[org/gnome/desktop/screensaver]
idle-activation-enabled=true
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010100
tags:
- RHEL-07-010100
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-204402r880782_rule
- V-204402
- dconf
- name: "MEDIUM | RHEL-07-010101 | PATCH | The Red Hat Enterprise Linux operating system must prevent a user from overriding the screensaver idle-activation-enabled setting for the graphical user interface."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/locks/session_rhel_07_010101
content: |
/org/gnome/desktop/screensaver/idle-activation-enabled
mode: '0644'
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010101
tags:
- RHEL-07-010101
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-204403r880785_rule
- V-204403
- dconf
- name: "MEDIUM | RHEL-07-010110 | PATCH | The Red Hat Enterprise Linux operating system must initiate a session lock for graphical user interfaces when the screensaver is activated."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/00-screensaver_rhel_07_010110
content: |
[org/gnome/desktop/screensaver]
lock-delay=uint32 5
mode: '0644'
register: rhel_07_010110
notify: dconf update
when:
- rhel7stig_dconf_available
- rhel_07_010110
tags:
- RHEL-07-010110
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-204404r880788_rule
- V-204404
- dconf
- name: "MEDIUM | RHEL-07-010118 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that /etc/pam.d/passwd implements /etc/pam.d/system-auth when changing passwords."
ansible.builtin.lineinfile:
path: /etc/pam.d/passwd
regexp: '^password\s+substack\s+system-auth'
line: 'password substack system-auth'
when:
- rhel_07_010118
tags:
- RHEL-07-010118
- CAT2
- CCI-000192
- SRG-OS-000069-GPOS-00037
- SV-204405r603261_rule
- V-204405
- pamd
- name: "MEDIUM | RHEL-07-010119 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed or new passwords are established, pwquality must be used."
ansible.builtin.lineinfile:
create: true
dest: /etc/pam.d/system-auth
regexp: '^#?password\s+(required|requisite) pam_pwquality.so retry'
line: password requisite pam_pwquality.so retry=3
mode: 0644
when:
- rhel_07_010119
tags:
- RHEL-07-010119
- CAT2
- CCI-000192
- SRG-OS-000069-GPOS-00037
- SV-204406r902704_rule
- V-204406
- pamd
- name: "MEDIUM | RHEL-07-010120 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed or new passwords are established, the new password must contain at least one upper-case character."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*ucredit'
line: "ucredit = {{ rhel7stig_password_complexity.ucredit | default('-1') }}"
mode: 0644
when:
- rhel_07_010120
tags:
- RHEL-07-010120
- CAT2
- CCI-000192
- SRG-OS-000069-GPOS-00037
- SV-204407r603261_rule
- V-204407
- pwquality
- name: "MEDIUM | RHEL-07-010130 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed or new passwords are established, the new password must contain at least one lower-case character."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*lcredit'
line: "lcredit = {{ rhel7stig_password_complexity.lcredit | default('-1') }}"
mode: 0644
when:
- rhel_07_010130
tags:
- RHEL-07-010130
- CAT2
- CCI-000193
- SRG-OS-000070-GPOS-00038
- SV-204408r603261_rule
- V-204408
- pwquality
- name: "MEDIUM | RHEL-07-010140 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed or new passwords are assigned, the new password must contain at least one numeric character."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*dcredit'
line: "dcredit = {{ rhel7stig_password_complexity.dcredit | default('-1') }}"
mode: 0644
when:
- rhel_07_010140
tags:
- RHEL-07-010140
- CAT2
- CCI-000194
- SV-204409r603261_rule
- V-204409
- RHELsality
- name: "MEDIUM | RHEL-07-010150 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed or new passwords are established, the new password must contain at least one special character."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*ocredit'
line: "ocredit = {{ rhel7stig_password_complexity.ocredit | default('-1') }}"
mode: 0644
when:
- rhel_07_010150
tags:
- RHEL-07-010150
- CAT2
- CCI-001619
- SRG-OS-000266-GPOS-00101
- SV-204410r603261_rule
- V-204410
- pwquality
- name: "MEDIUM | RHEL-07-010160 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed a minimum of eight of the total number of characters must be changed."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*difok'
line: "difok = {{ rhel7stig_password_complexity.difok | default('8') }}"
mode: 0644
when:
- rhel_07_010160
tags:
- RHEL-07-010160
- CAT2
- CCI-000195
- SRG-OS-000072-GPOS-00040
- SV-204411r603261_rule
- V-204411
- pwquality
- name: "MEDIUM | RHEL-07-010170 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed a minimum of four character classes must be changed."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*minclass'
line: "minclass = {{ rhel7stig_password_complexity.minclass | default('4') }}"
mode: 0644
when:
- rhel_07_010170
tags:
- RHEL-07-010170
- CAT2
- CCI-000195
- SRG-OS-000072-GPOS-00040
- SV-204412r603261_rule
- V-204412
- pwquality
- name: "MEDIUM | RHEL-07-010180 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed the number of repeating consecutive characters must not be more than three characters."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*maxrepeat'
line: "maxrepeat = {{ rhel7stig_password_complexity.maxrepeat | default('3') }}"
mode: 0644
when:
- rhel_07_010180
tags:
- RHEL-07-010180
- CAT2
- CCI-000195
- SRG-OS-000072-GPOS-00040
- SV-204413r603261_rule
- V-204413
- pwquality
- name: "MEDIUM | RHEL-07-010190 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that when passwords are changed the number of repeating characters of the same character class must not be more than four characters."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*maxclassrepeat'
line: "maxclassrepeat = {{ rhel7stig_password_complexity.maxclassrepeat | default('4') }}"
mode: 0644
when:
- rhel_07_010190
tags:
- RHEL-07-010190
- CAT2
- CCI-000195
- SRG-OS-000072-GPOS-00040
- SV-204414r809186_rule
- V-204414
- pwquality
- name: "MEDIUM | RHEL-07-010199 | PATCH | The Red Hat Enterprise Linux operating system must be configured to prevent overwriting of custom authentication configuration settings by the authconfig utility."
block:
- name: "MEDIUM | RHEL-07-010199 | PATCH | The Red Hat Enterprise Linux operating system must be configured to prevent overwriting of custom authentication configuration settings by the authconfig utility. | local file"
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/{{ item }}"
owner: root
group: root
mode: 0644
loop:
- etc/pam.d/password-auth-local
- etc/pam.d/system-auth-local
- name: "MEDIUM | RHEL-07-010199 | PATCH | The Red Hat Enterprise Linux operating system must be configured to prevent overwriting of custom authentication configuration settings by the authconfig utility. | copy and symlink"
ansible.builtin.shell: "if [[ -f {{ item }} && ! -L {{ item }} ]]; then cp -p {{ item }} {{ item }}-ac; ln -sf {{ item }}-local {{ item }} && (exit 99); else (exit 98); fi"
changed_when: rhel_07_010199_changed.rc == 99
failed_when: rhel_07_010199_changed.rc not in [ 98, 99 ]
register: rhel_07_010199_changed
loop:
- /etc/pam.d/password-auth
- /etc/pam.d/system-auth
when:
- rhel_07_010199
tags:
- RHEL-07-010199
- CAT2
- CCI-000196
- SRG-OS-000072-GPOS-00040
- SV-255928r917838_rule
- V-255928
- pamd
- name: "MEDIUM | RHEL-07-010200 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that the PAM system service is configured to store only encrypted representations of passwords."
community.general.pamd:
name: "{{ item[0] }}"
state: "{{ item[1].state }}"
type: password
control: sufficient
module_path: pam_unix.so
module_arguments: "{{ item[1].args }}"
with_nested:
- [ 'system-auth', 'password-auth' ]
-
- state: args_present
args:
- "sha512"
- state: args_absent
args:
- "md5"
- "bigcrypt"
- "sha256"
- "blowfish"
when:
- rhel_07_010200
tags:
- RHEL-07-010200
- CAT2
- CCI-000196
- SRG-OS-000073-GPOS-00041
- SV-204415r917816_rule
- V-204415
- pamd
- name: "MEDIUM | RHEL-07-010210 | PATCH | The Red Hat Enterprise Linux operating system must be configured to use the shadow file to store only encrypted representations of passwords."
ansible.builtin.lineinfile:
path: /etc/login.defs
regexp: ^#?ENCRYPT_METHOD
line: "ENCRYPT_METHOD {{ rhel7stig_login_defaults.encrypt_method | default('SHA512') }}"
when:
- rhel_07_010210
tags:
- RHEL-07-010210
- CAT2
- CCI-000196
- SRG-OS-000073-GPOS-00041
- SV-204416r603261_rule
- V-204416
- login
- name: "MEDIUM | RHEL-07-010220 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that user and group account administration utilities are configured to store only encrypted representations of passwords."
ansible.builtin.lineinfile:
path: /etc/libuser.conf
regexp: ^#?crypt_style
line: crypt_style = sha512
when:
- rhel_07_010220
tags:
- RHEL-07-010220
- CAT2
- CCI-000196
- SRG-OS-000073-GPOS-00041
- SV-204417r603261_rule
- V-204417
- login
- name: "MEDIUM | RHEL-07-010230 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that passwords for new users are restricted to a 24 hours/1 day minimum lifetime."
ansible.builtin.lineinfile:
create: true
dest: /etc/login.defs
regexp: ^#?PASS_MIN_DAYS
line: "PASS_MIN_DAYS {{ rhel7stig_login_defaults.pass_min_days | default('1') }}"
mode: 0644
when:
- rhel_07_010230
tags:
- RHEL-07-010230
- CAT2
- CCI-000198
- SRG-OS-000075-GPOS-00043
- SV-204418r603261_rule
- V-204418
- login
- name: "MEDIUM | RHEL-07-010240 | The Red Hat Enterprise Linux operating system must be configured so that passwords are restricted to a 24 hours/1 day minimum lifetime."
block:
- name: "MEDIUM | RHEL-07-010240 | AUDIT | Passwords must be restricted to a 24 hours/1 day minimum lifetime."
ansible.builtin.shell: "awk -F: '$1 !~ /^root$/ && $2 !~ /^[!*]/ && $4 < 1 {print $1}' /etc/shadow"
check_mode: false
changed_when: false
register: rhel_07_010240_audit
- name: "MEDIUM | RHEL-07-010240 | PATCH | Passwords must be restricted to a 24 hours/1 day minimum lifetime."
ansible.builtin.shell: chage -m 1 {{ item }}
check_mode: false
changed_when: true
with_items:
- "{{ rhel_07_010240_audit.stdout_lines }}"
when:
- rhel_07_010240
tags:
- RHEL-07-010240
- CAT2
- CCI-000198
- SRG-OS-000075-GPOS-00043
- SV-204419r603261_rule
- V-204419
- password
- name: "MEDIUM | RHEL-07-010250 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that passwords for new users are restricted to a 60-day maximum lifetime."
ansible.builtin.lineinfile:
create: true
dest: /etc/login.defs
regexp: ^#?PASS_MAX_DAYS
line: "PASS_MAX_DAYS {{ rhel7stig_login_defaults.pass_max_days | default('60') }}"
mode: 0644
when:
- rhel_07_010250
tags:
- RHEL-07-010250
- CAT2
- CCI-000199
- SRG-OS-000076-GPOS-00044
- SV-204420r603261_rule
- V-204420
- login
- name: "MEDIUM | RHEL-07-010260 | The Red Hat Enterprise Linux operating system must be configured so that existing passwords are restricted to a 60-day maximum lifetime."
block:
- name: "MEDIUM | RHEL-07-010260 | AUDIT | The Red Hat Enterprise Linux operating system must be configured so that existing passwords are restricted to a 60-day maximum lifetime."
ansible.builtin.shell: "awk -F: '$1 !~ /^root$/ && $2 !~ /^[!*]/ && $5 > 60 {print $1}' /etc/shadow"
check_mode: false
changed_when: false
register: rhel_07_010260_audit
- name: "MEDIUM | RHEL-07-010260 | PATCH | Reset password timeout to prevent locking out user."
ansible.builtin.shell: chage -d '-1 day' {{ item }}
check_mode: "{{ rhel7stig_disruptive_check_mode }}"
with_items:
- "{{ rhel_07_010260_audit.stdout_lines }}"
- name: "MEDIUM | RHEL-07-010260 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that existing passwords are restricted to a 60-day maximum lifetime."
ansible.builtin.shell: "chage -M 60 {{ item }}"
check_mode: "{{ rhel7stig_disruptive_check_mode }}"
with_items:
- "{{ rhel_07_010260_audit.stdout_lines }}"
when:
- rhel_07_010260
- rhel7stig_disruptive
tags:
- RHEL-07-010260
- CAT2
- CCI-000199
- SRG-OS-000076-GPOS-00044
- SV-204421r603261_rule
- V-204421
- disruption-high
- password
- name: "MEDIUM | RHEL-07-010270 | The Red Hat Enterprise Linux operating system must be configured so that passwords are prohibited from reuse for a minimum of five generations."
block:
- name: "MEDIUM | RHEL-07-010270 | PATCH | Ensure pam_pwhistory rule exists | system-auth"
community.general.pamd:
name: system-auth
state: before
type: password
control: requisite
module_path: pam_pwquality.so
new_type: password
new_control: requisite
new_module_path: pam_pwhistory.so
module_arguments:
- remember={{ rhel7stig_pam_pwhistory.remember | default(5) }}
- retry={{ rhel7stig_pam_pwhistory.retries | default(3) }}
- name: "MEDIUM | RHEL-07-010270 | PATCH | Ensure pam_pwhistory module arguments are set | password-auth"
community.general.pamd:
name: password-auth
state: updated
type: password
control: requisite
module_path: pam_pwhistory.so
module_arguments:
- use_authtok
- remember={{ rhel7stig_pam_pwhistory.remember | default(5) }}
- retry={{ rhel7stig_pam_pwhistory.retries | default(3) }}
when:
- not rhel_07_010199 # 010199 uses template that is compliant already
- rhel_07_010270
tags:
- RHEL-07-010270
- CAT2
- CCI-000200
- SRG-OS-000077-GPOS-00045
- SV-204422r917818_rule
- V-204422
- pamd
- name: "MEDIUM | AUDIT | RHEL-07-010271 | The Red Hat Enterprise Linux operating system must automatically expire temporary accounts within 72 hours."
ansible.builtin.debug:
msg:
- "Warning!! Verify every existing emergency account and make sure it has an expiration date set within 72 hours."
when:
- rhel_07_010271
tags:
- RHEL-07-010271
- CAT2
- CCI-001682
- SRG-OS-000123-GPOS-00064
- SV-254523r903130_rule
- V-254523
- name: "MEDIUM | RHEL-07-010280 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that passwords are a minimum of 15 characters in length."
ansible.builtin.lineinfile:
create: true
dest: /etc/security/pwquality.conf
regexp: '^#?\s*minlen'
line: "minlen = {{ rhel7stig_password_complexity.minlen | default('15') }}"
mode: 0644
when:
- rhel_07_010280
tags:
- RHEL-07-010280
- CAT2
- CCI-000205
- SRG-OS-000078-GPOS-00046
- SV-204423r603261_rule
- V-204423
- pwquality
- name: "MEDIUM | RHEL-07-010310 | PATCH | The Red Hat Enterprise Linux operating system must disable account identifiers (individuals, groups, roles, and devices) if the password expires."
ansible.builtin.lineinfile:
path: /etc/default/useradd
regexp: ^#?INACTIVE
line: INACTIVE=35
when:
- rhel_07_010310
tags:
- RHEL-07-010310
- CAT2
- CCI-000795
- SRG-OS-000118-GPOS-00060
- SV-204426r809190_rule
- V-204426
- accounts
- name: |
"MEDIUM | RHEL-07-010320 | The Red Hat Enterprise Linux operating system must be configured to lock accounts for a minimum of 15 minutes after three unsuccessful logon attempts within a 15-minute timeframe."
"MEDIUM | RHEL-07-010330 | The Red Hat Enterprise Linux operating system must lock the associated account after three unsuccessful root logon attempts are made within a 15-minute period."
block:
- name: |
"MEDIUM | RHEL-07-010320 | PATCH | The Red Hat Enterprise Linux operating system must be configured to lock accounts for a minimum of 15 minutes after three unsuccessful logon attempts within a 15-minute timeframe."
"MEDIUM | RHEL-07-010330 | PATCH | The Red Hat Enterprise Linux operating system must lock the associated account after three unsuccessful root logon attempts are made within a 15-minute period."
community.general.pamd:
name: "{{ item }}"
state: before
type: auth
control: sufficient
module_path: pam_unix.so
new_type: auth
new_control: required
new_module_path: pam_faillock.so
with_items:
- "system-auth"
- "password-auth"
# TODO: Remove temporary audit check to determine if the following pamd module task needs to be run since the module is not idempotent
# - name: |
# "MEDIUM | RHEL-07-010320 | AUDIT | Check for existing account lockout settings"
# "MEDIUM | RHEL-07-010330 | AUDIT | Check for existing account lockout settings"
# ansible.builtin.shell: "grep -iE '^auth\\s+required\\s+pam_faillock.so\\s+preauth\\s+silent\\s+audit\\s+deny={{ rhel7stig_pam_faillock.attempts }}{{ (rhel7stig_pam_faillock.fail_for_root) | ternary(' even_deny_root ',' ') }}fail_interval={{ rhel7stig_pam_faillock.interval }}\\s+unlock_time={{ rhel7stig_pam_faillock.unlock_time }}$' /etc/pam.d/{{ item }}"
# check_mode: no
# changed_when: no
# failed_when: rhel_07_010320_010330_preauth_audit.rc > 1
# register: rhel_07_010320_010330_preauth_audit
# with_items:
# - "system-auth"
# - "password-auth"
# TODO: Once the pamd module is fixed (either args_present or updated) then remove the previous grep task and update the following.
- name: |
"MEDIUM | RHEL-07-010320 | PATCH | The Red Hat Enterprise Linux operating system must be configured to lock accounts for a minimum of 15 minutes after three unsuccessful logon attempts within a 15-minute timeframe."
"MEDIUM | RHEL-07-010330 | PATCH | The Red Hat Enterprise Linux operating system must lock the associated account after three unsuccessful root logon attempts are made within a 15-minute period."
community.general.pamd:
name: "{{ item }}"
state: updated
type: auth
control: required
module_path: pam_faillock.so
module_arguments: "preauth silent audit deny={{ rhel7stig_pam_faillock.attempts }}{{ (rhel7stig_pam_faillock.fail_for_root) | ternary(' even_deny_root ',' ') }}fail_interval={{ rhel7stig_pam_faillock.interval }} unlock_time={{ rhel7stig_pam_faillock.unlock_time }}"
with_items:
- "system-auth"
- "password-auth"
- name: "MEDIUM | RHEL-07-010330 | PATCH | The Red Hat Enterprise Linux operating system must lock the associated account after three unsuccessful root logon attempts are made within a 15-minute period."
community.general.pamd:
name: "{{ item }}"
state: before
type: auth
control: required
module_path: pam_deny.so
new_type: auth
new_control: "[default=die]"
new_module_path: pam_faillock.so
with_items:
- "system-auth"
- "password-auth"
# TODO: Remove temporary audit check to determine if the following pamd module task needs to be run since the module is not idempotent
# - name: "MEDIUM | RHEL-07-010330 | AUDIT | Check for existing account lockout settings"
# ansible.builtin.shell: "grep -iE '^auth\\s+\\[default=die\\]\\s+pam_faillock.so\\s+authfail\\s+audit\\s+deny={{ rhel7stig_pam_faillock.attempts }}{{ (rhel7stig_pam_faillock.fail_for_root) | ternary(' even_deny_root ',' ') }}fail_interval={{ rhel7stig_pam_faillock.interval }}\\s+unlock_time={{ rhel7stig_pam_faillock.unlock_time }}$' /etc/pam.d/{{ item }}"
# check_mode: no
# changed_when: no
# failed_when: rhel_07_010330_authfail_audit.rc > 1
# register: rhel_07_010330_authfail_audit
# with_items:
# - "system-auth"
# - "password-auth"
# TODO: Once the pamd module is fixed (either args_present or updated) then remove the previous grep task and update the following.
- name: "MEDIUM | RHEL-07-010330 | PATCH | The Red Hat Enterprise Linux operating system must lock the associated account after three unsuccessful root logon attempts are made within a 15-minute period."
community.general.pamd:
name: "{{ item }}"
state: updated
type: auth
control: "[default=die]"
module_path: pam_faillock.so
module_arguments: "authfail audit deny={{ rhel7stig_pam_faillock.attempts }}{{ (rhel7stig_pam_faillock.fail_for_root) | ternary(' even_deny_root ',' ') }}fail_interval={{ rhel7stig_pam_faillock.interval }} unlock_time={{ rhel7stig_pam_faillock.unlock_time }}"
with_items:
- "system-auth"
- "password-auth"
# when: item.rc == 1
- name: "MEDIUM | RHEL-07-010330 | PATCH | The Red Hat Enterprise Linux operating system must lock the associated account after three unsuccessful root logon attempts are made within a 15-minute period."
community.general.pamd:
name: "{{ item }}"
state: before
type: account
control: required
module_path: pam_unix.so
new_type: account
new_control: required
new_module_path: pam_faillock.so
with_items:
- "system-auth"
- "password-auth"
when:
- not rhel_07_010199 # 010199 uses template that is compliant already
- rhel_07_010320 or
rhel_07_010330
tags:
- CAT2
- RHEL-07-010320
- CCI-000044
- CCI-002236
- CCI-002237
- CCI-002238
- SRG-OS-000329-GPOS-00128
- SV-204427r880842_rule
- V-204427
- RHEL-07-010330
- CCI-002238
- SV-204428r880845_rule
- V-204428
- pamd
- name: "MEDIUM | RHEL-07-010339 | PATCH | The Red Hat Enterprise Linux operating system must specify the default 'include' directory for the /etc/sudoers file."
ansible.builtin.lineinfile:
path: /etc/sudoers
regex: '^#includedir'
line: '#includedir /etc/sudoers.d'
validate: '/usr/sbin/visudo -cf %s'
when:
- rhel_07_010339
tags:
- RHEL-07-010339
- CAT2
- CCI-000366
- SRG-OS-000480-GPOS-00227
- SV-251703r833183_rule
- V-251703
- sudoers
- name: "MEDIUM | RHEL-07-010340 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that users must provide a password for privilege escalation."
ansible.builtin.replace:
path: "{{ item }}"
regexp: '^([^#].*)NOPASSWD(.*)'
replace: '\1PASSWD\2'
validate: '/usr/sbin/visudo -cf %s'
with_items:
- "{{ rhel7stig_sudoers_files.stdout_lines }}"
when:
- rhel7stig_using_password_auth
- rhel7stig_disruption_high
- rhel_07_010340
tags:
- RHEL-07-010340
- CAT2
- CCI-002038
- SRG-OS-000373-GPOS-00156
- SV-204429r833190_rule
- V-204429
- sudoers
- name: "MEDIUM | RHEL-07-010344 | PATCH | The Red Hat Enterprise Linux operating system must not be configured to bypass password requirements for privilege escalation."
ansible.builtin.lineinfile:
path: /etc/pam.d/sudo
regex: 'pam_succeed_if'
state: absent
when:
- rhel_07_010344
tags:
- RHEL-07-010344
- CAT2
- CCI-002038
- SRG-OS-000373-GPOS-00156
- SV-251704r809568_rule
- V-251704
- name: "MEDIUM | RHEL-07-010350 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that users must re-authenticate for privilege escalation."
ansible.builtin.replace:
path: "{{ item }}"
regexp: '^([^#].*)!authenticate(.*)'
replace: '\1authenticate\2'
validate: '/usr/sbin/visudo -cf %s'
with_items: "{{ rhel7stig_sudoers_files.stdout_lines }}"
when:
- rhel_07_010350
- not ansible_distribution == "OracleLinux"
tags:
- RHEL-07-010350
- CAT2
- CCI-002038
- SRG-OS-000373-GPOS-00156
- SV-204430r603261_rule
- V-204430
- sudoers
- name: "MEDIUM | RHEL-07-010430 | PATCH | The Red Hat Enterprise Linux operating system must be configured so that the delay between logon prompts following a failed console logon attempt is at least four seconds."
ansible.builtin.lineinfile:
path: /etc/login.defs
regexp: ^#?FAIL_DELAY
line: "FAIL_DELAY {{ rhel7stig_login_defaults.fail_delay_secs | default('4') }}"
when:
- rhel_07_010430
tags:
- RHEL-07-010430
- CAT2
- CCI-000366
- SRG-OS-000480-GPOS-00226
- SV-204431r603261_rule
- V-204431
- login
- name: "MEDIUM | RHEL-07-010460 | PATCH | The Red Hat Enterprise Linux operating system must not allow users to override SSH environment variables."
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: "(?i)^#?PermitUserEnvironment"
line: PermitUserEnvironment no
validate: /usr/sbin/sshd -t -f %s
notify: restart sshd
when:
- rhel_07_010460
- rhel7stig_ssh_required
tags:
- RHEL-07-010460
- CAT2
- CCI-000366
- SRG-OS-000480-GPOS-00229
- SV-204434r603261_rule
- V-204434
- ssh
- name: "MEDIUM | RHEL-07-010470 | PATCH | The Red Hat Enterprise Linux operating system must not allow a non-certificate trusted host SSH logon to the system."
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config