-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathfix-cat2.yml
7808 lines (7291 loc) · 307 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
---
# TODO: ansible-lint: schema
- name: "MEDIUM | RHEL-08-010001 | PATCH | The RHEL 8 operating system must implement the Endpoint Security for Linux Threat Prevention tool."
block:
- name: "MEDIUM | RHEL-08-010001 | PATCH | The RHEL 8 operating system must implement the Endpoint Security for Linux Threat Prevention tool. | Alert no McAfee"
ansible.builtin.debug:
msg:
- "WARNING!! You have no McAfee installed. To comply with STIG ID RHEL-08-010001 you need an AV tool"
- "McAfee is the suggested by STIG"
when:
- "'mcafeetp' not in ansible_facts.packages or
'mfetpd' not in ansible_facts.packages"
- name: "MEDIUM | RHEL-08-010001 | PATCH | The RHEL 8 operating system must implement the Endpoint Security for Linux Threat Prevention tool. | Alert on McAfee present"
ansible.builtin.debug:
msg: "Congratulations! You have McAfee installed"
when:
- "'mcafeetp' in ansible_facts.packages or
'mfetpd' in ansible_facts.packages"
when:
- rhel_08_040286
- rhel8stig_av_sftw == 'mcafee'
tags:
- RHEL-08-010001
- CAT2
- CCI-001233
- SRG-OS-000191-GPOS-00080
- SV-245540r942951_rule
- V-245540
- name: "MEDIUM | RHEL-08-010010 | PATCH | RHEL 8 vendor packaged system security patches and updates must be installed and up to date."
ansible.builtin.package:
name: "*"
state: latest
when:
- not system_is_ec2
- rhel_08_010010
tags:
- RHEL-08-010010
- CAT2
- CCI-000366
- SRG-OS-000480-GPOS-00227
- SV-230222r627750_rule
- V-230222
- name: "MEDIUM | RHEL-08-010019 | PATCH | RHEL 8 must ensure cryptographic verification of vendor software packages."
block:
- name: "MEDIUM | RHEL-08-010019 | PATCH | RHEL 8 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-08-010019 | AUDIT | RHEL 8 must ensure cryptographic verification of vendor software packages. | Confirm keys"
ansible.builtin.shell: "gpg -q --keyid-format short --with-fingerprint {{ rpm_gpg_key }} | grep -B1 '{{ item.name }}' | grep '{{ item.fingerprint }}'"
changed_when: false
failed_when: rhel_08_010019_gpg_info.rc not in [ 0, 1]
register: rhel_08_010019_gpg_info
loop: "{{ gpg_keys }}"
loop_control:
label: item.name
- name: "MEDIUM | RHEL-08-010019 | AUDIT | RHEL 8 must ensure cryptographic verification of vendor software packages. | warn"
ansible.builtin.debug:
msg:
- "WARNING!! Please investigate the vendor gpgkeys match expected values"
loop: "{{ rhel_08_010019_gpg_info.results }}"
when: item.rc != 0
when:
- not system_is_ec2
- rhel_08_010019
tags:
- RHEL-08-010019
- CAT2
- CCI-001749
- SRG-OS-000366-GPOS-00153
- SV-256973r902752_rule
- V-256973
- name: "MEDIUM | RHEL-08-010030 | AUDIT | All RHEL 8 local disk partitions must implement cryptographic mechanisms to prevent unauthorized disclosure or modification of all information that requires at rest protection."
block:
- name: "MEDIUM | RHEL-08-010030 | AUDIT | All RHEL 8 local disk partitions must implement cryptographic mechanisms to prevent unauthorized disclosure or modification of all information that requires at rest protection. | Get partition layout"
ansible.builtin.shell: lsblk
changed_when: false
failed_when: false
register: rhel_08_010030_partition_layout
- name: "MEDIUM | RHEL-08-010030 | AUDIT | All RHEL 8 local disk partitions must implement cryptographic mechanisms to prevent unauthorized disclosure or modification of all information that requires at rest protection. | Message out warning"
ansible.builtin.debug:
msg:
- 'WARNING!! Below is the partition layout. Please run the "sudo more /etc/crypttab" command to confirm every persistent disk partition has an entry.'
- "If partitions other than pseudo file systems (such as /var or /sys) this is a finding"
- "{{ rhel_08_010030_partition_layout.stdout_lines }}"
when:
- rhel_08_010030
tags:
- RHEL-08-010030
- CAT2
- CCI-001199
- SRG-OS-000185-GPOS-00079
- SV-230224r917864_rule
- V-230224
- name: |
"MEDIUM | RHEL-08-010040 | PATCH | RHEL 8 must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a ssh logon."
"MEDIUM | RHEL-08-010060 | PATCH | RHEL 8 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"
block:
- name: |
"MEDIUM | RHEL-08-010040 | PATCH | RHEL 8 must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a ssh logon. | Uncomment banner keyword and set banner path""
"MEDIUM | RHEL-08-010060 | PATCH | RHEL 8 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. | Uncomment banner keyword and set banner path""
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '(?i)^#?Banner'
line: 'Banner /etc/issue'
validate: '/usr/sbin/sshd -T -f %s'
when:
- rhel8stig_ssh_required
- name: |
"MEDIUM | RHEL-08-010040 | PATCH | RHEL 8 must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a ssh logon. | Set banner message""
"MEDIUM | RHEL-08-010060 | PATCH | RHEL 8 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. | Set banner message""
ansible.builtin.copy: # noqa: template-instead-of-copy
dest: "{{ item }}"
content: "{{ rhel8stig_logon_banner }}"
owner: root
group: root
mode: 'u-x,go-wx'
notify: restart sshd
with_items:
- /etc/issue
- /etc/issue.net
when:
# - not system_is_ec2
- rhel_08_010040 or
rhel_08_010060
tags:
- CAT2
- RHEL-08-010040
- RHEL-08-010060
- CCI-000048
- SRG-OS-000023-GPOS-00006
- SV-230225r951590_rule
- SV-230227r627750_rule
- V-230225
- V-230227
- name: "MEDIUM | RHEL-08-010049 | PATCH | RHEL 8 must display a banner before granting local or remote access to the system via a graphical user logon"
ansible.builtin.lineinfile:
path: /etc/dconf/db/local.d/01-banner-message
regexp: 'banner-message-enabled='
line: banner-message-enable=true
create: true
mode: 'u-x,go-wx'
owner: root
group: root
insertafter: '[org/gnome/login-screen]'
notify: dconf update
when:
- rhel_08_010049
tags:
- RHEL-08-010049
- CAT2
- CCI-000048
- SRG-OS-000023-GPOS-00006
- SV-244519r743806_rule
- V-244519
- banner
- name: "MEDIUM | RHEL-08-010050 | PATCH | RHEL 8 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-text='{{ rhel8stig_logon_banner | replace(newline, "\n") }}'
banner-message-enable=true
mode: 'u-x,go-wx'
owner: root
group: root
vars:
newline: "\n"
notify: dconf update
when:
- rhel_08_010050
- "'dconf' in ansible_facts.packages"
- rhel8stig_always_configure_dconf
tags:
- RHEL-08-010050
- CAT2
- CCI-000048
- SRG-OS-000023-GPOS-00006
- SV-230226r743916_rule
- V-230226
- name: "MEDIUM | RHEL-08-010070 | PATCH | All RHEL 8 remote access methods must be monitored."
ansible.builtin.lineinfile:
path: /etc/rsyslog.conf
regexp: ^(?!#).*\/var\/log\/secure
line: 'auth.*;authpriv.*;daemon.* /var/log/secure'
create: true
mode: 'u-x,go-wx'
notify: restart rsyslog
when:
- rhel_08_010070
tags:
- RHEL-08-010070
- CAT2
- CCI-000067
- SRG-OS-000032-GPOS-00013
- SV-230228r951592_rule
- V-230228
- rsyslog
# This task wants you to download the latest DoD root certs and place the chain pem in /etc/sssd/pki/sssd_auth_ca_db.pem. This might need to be a message out, but I will circle back to this and confirm.
- name: "MEDIUM | RHEL-08-010090 | PATCH | RHEL 8, for PKI-based authentication, must validate certificates by constructing a certification path (which includes status information) to an accepted trust anchor."
block:
- name: "MEDIUM | RHEL-08-010090 | PATCH | RHEL 8, for PKI-based authentication, must validate certificates by constructing a certification path (which includes status information) to an accepted trust anchor. | Get current certs"
ansible.builtin.shell: openssl x509 -text -in /etc/sssd/pki/sssd_auth_ca_db.pem
changed_when: false
failed_when: false
register: rhel_08_010090_certs_list
- name: "MEDIUM | RHEL-08-010090 | PATCH | RHEL 8, for PKI-based authentication, must validate certificates by constructing a certification path (which includes status information) to an accepted trust anchor. | Message out certs"
ansible.builtin.debug:
msg:
- "WARNING!! The certs below are the ones applied to this system. Please review and confirm they are the latest issued from the DoD"
- "If they are not please apply the latest PKI CA certificate bundle from cyber.mil and copy the DoD_PKE_CA_chain.pem into /etc/sssd/pki/sssd_auth_ca_db.pem"
- "{{ rhel_08_010090_certs_list.stdout_lines | default('None-found') }}"
when:
- rhel_08_010090
tags:
- RHEL-08-010090
- CAT2
- CCI-000185
- SRG-OS-000066-GPOS-00034
- SV-230229r858739_rule
- V-230229
- certificates
- name: "MEDIUM | RHEL-08-010100 | PATCH | RHEL 8, for certificate-based authentication, must enforce authorized access to the corresponding private key."
block:
- name: "MEDIUM | RHEL-08-010100 | PATCH | RHEL 8, for certificate-based authentication, must enforce authorized access to the corresponding private key. | Create .ssh folder"
ansible.builtin.file:
path: "{{ rhel8stig_path_to_sshkey }}"
state: directory
mode: 'u+x,go-rwx'
- name: "MEDIUM | RHEL-08-010100 | PATCH | RHEL 8, for certificate-based authentication, must enforce authorized access to the corresponding private key. | Create key pair"
community.crypto.openssh_keypair:
path: "{{ rhel8stig_path_to_sshkey }}/id_rsa"
when:
- rhel_08_010100
- rhel8stig_ssh_required
tags:
- RHEL-08-010100
- CAT2
- CCI-000186
- SRG-OS-000067-GPOS-00035
- SV-230230r627750_rule
- V-230230
- name: "MEDIUM | RHEL-08-010110 | PATCH | RHEL 8 must encrypt all stored passwords with a FIPS 140-2 approved cryptographic hashing algorithm."
ansible.builtin.lineinfile:
path: /etc/login.defs
regexp: '^ENCRYPT_METHOD.*'
line: "ENCRYPT_METHOD {{ rhel8stig_login_defaults.encrypt_method | default('SHA512') }}"
owner: root
group: root
mode: "{{ rhel8stig_login_defs_file_perms }}"
when:
- rhel_08_010110
tags:
- RHEL-08-010110
- CAT2
- CCI-000196
- SRG-OS-000073-GPOS-00041
- SV-230231r627750_rule
- V-230231
- login
- name: "MEDIUM | RHEL-08-010120 | PATCH | RHEL 8 must employ FIPS 140-2 approved cryptographic hashing algorithms for all stored passwords."
block:
- name: "MEDIUM | RHEL-08-010120 | AUDIT | RHEL 8 must employ FIPS 140-2 approved cryptographic hashing algorithms for all stored passwords. | Get user accounts not using FIPS 140-2 hashing"
ansible.builtin.shell: 'cat /etc/shadow | grep -v "*" | grep -v "!" | grep -v ":$6$" | cut -f1 -d:'
changed_when: false
failed_when: false
register: rhel_08_010120_non_fips_hashed_accounts
- name: "MEDIUM | RHEL-08-010120 | PATCH | RHEL 8 must employ FIPS 140-2 approved cryptographic hashing algorithms for all stored passwords. | Lock user not using FIPS 140-2 hashing"
ansible.builtin.shell: "passwd -l {{ item }}"
with_items:
- "{{ rhel_08_010120_non_fips_hashed_accounts.stdout_lines }}"
when:
- rhel_08_010120_non_fips_hashed_accounts.stdout | length > 0
- name: "MEDIUM | RHEL-08-010120 | AUDIT | RHEL 8 must employ FIPS 140-2 approved cryptographic hashing algorithms for all stored passwords. | Message out user accounts"
ansible.builtin.debug:
msg:
- "WARNING!! The following accounts do not have FIPS 140-2 hashing. Please review the accounts and correct to conform to control 010120 of the RHEL8 STIG"
- "{{ rhel_08_010120_non_fips_hashed_accounts.stdout_lines }}"
when:
- not rhel8stig_disruption_high
- rhel_08_010120_non_fips_hashed_accounts.stdout | length > 0
when:
- rhel_08_010120
- rhel8stig_disruption_high
tags:
- RHEL-08-010120
- CAT2
- CCI-000196
- SRG-OS-000073-GPOS-00041
- SV-230232r627750_rule
- V-230232
- disruption_high
- name: "MEDIUM | RHEL-08-010130 | PATCH | The RHEL 8 shadow password suite must be configured to use a sufficient number of hashing rounds."
ansible.builtin.lineinfile:
path: /etc/login.defs
regexp: ^.*SHA_CRYPT_MIN_ROUNDS\s
line: SHA_CRYPT_MIN_ROUNDS {{ rhel8stig_hashing_rounds }}
owner: root
group: root
mode: "{{ rhel8stig_login_defs_file_perms }}"
when:
- rhel_08_010130
tags:
- RHEL-08-010130
- CAT2
- CCI-000196
- SRG-OS-000073-GPOS-00041
- SV-230233r880705_rule
- V-230233
- pamd
- name: |
"MEDIUM | RHEL-08-010141 | PATCH | RHEL 8 operating systems booted with United Extensible Firmware Interface (UEFI) must require a unique superusers name upon booting into single-user mode and maintenance."
"MEDIUM | RHEL-08-010149 | PATCH | RHEL 8 operating systems booted with a BIOS must require a unique superusers name upon booting into single-user and maintenance modes."
ansible.builtin.template:
src: 01_users.j2
dest: /etc/grub.d/01_users
owner: root
group: root
mode: 'u+x,go-w'
notify: confirm grub2 user cfg
when:
- rhel_08_010141 or
rhel_08_010149
tags:
- RHEL-08-010141
- RHEL-08-010149
- CAT2
- CCI-000213
- SRG-OS-000080-GPOS-00048
- SV-244521r792982_rule
- SV-244522r792984_rule
- V-244521
- V-244522
- grub
- name: "MEDIUM | RHEL-08-010151 | PATCH | RHEL 8 operating systems must require authentication upon booting into emergency or rescue modes."
ansible.builtin.lineinfile:
path: /usr/lib/systemd/system/rescue.service
regexp: '^ExecStart='
line: "ExecStart=-/usr/lib/systemd/systemd-sulogin-shell rescue"
create: true
owner: root
group: root
mode: 'u-x,go-wx'
when:
- rhel_08_010151
tags:
- RHEL-08-010151
- CAT2
- CCI-000213
- SRG-OS-000080-GPOS-00048
- SV-230236r743928_rule
- V-230236
- systemd
- name: "MEDIUM | RHEL-08-010152 | PATCH | RHEL 8 operating systems must require authentication upon booting into emergency mode."
ansible.builtin.lineinfile:
path: /usr/lib/systemd/system/emergency.service
regexp: '^ExecStart='
line: "ExecStart=-/usr/lib/systemd/systemd-sulogin-shell emergency"
create: true
owner: root
group: root
mode: 'u-x,go-wx'
when:
- rhel_08_010152
tags:
- RHEL-08-010152
- CAT2
- CCI-000213
- SRG-OS-000080-GPOS-00048
- SV-244523r743818_rule
- V-244523
- systemd
- name: "MEDIUM | RHEL-08-010159 | PATCH | The RHEL 8 pam_unix.so module must be configured in the system-auth file to use a FIPS 140-2 approved cryptographic hashing algorithm for system authentication."
community.general.pamd:
name: system-auth
type: password
control: sufficient
module_path: pam_unix.so
module_arguments: sha512
state: args_present
when:
- rhel_08_010159
tags:
- RHEL-08-010159
- CAT2
- CCI-000803
- SRG-OS-000120-GPOS-00061
- SV-244524r809331_rule
- V-244524
- pamd
- name: "MEDIUM | RHEL-08-010160 | PATCH | The RHEL 8 pam_unix.so module must be configured in the password-auth file to use a FIPS 140-2 approved cryptographic hashing algorithm for system authentication."
community.general.pamd:
name: password-auth
type: password
control: sufficient
module_path: pam_unix.so
module_arguments: sha512
state: args_present
when:
- rhel_08_010160
tags:
- RHEL-08-010160
- CAT2
- CCI-000803
- SRG-OS-000120-GPOS-00061
- SV-230237r809276_rule
- V-230237
- pamd
- name: "MEDIUM | RHEL-08-010161 | PATCH | RHEL 8 must prevent system daemons from using Kerberos for authentication."
block:
- name: "MEDIUM | RHEL-08-010161 | AUDIT | RHEL 8 must prevent system daemons from using Kerberos for authentication. | Find .keytab files"
ansible.builtin.shell: find / -name *.keytab
changed_when: false
failed_when: rhel8stig_010161_keytab_files.rc not in [ 0, 1 ]
register: rhel8stig_010161_keytab_files
- name: "MEDIUM | RHEL-08-010161 | PATCH | RHEL 8 must prevent system daemons from using Kerberos for authentication. | Remove .keytab files"
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items:
- "{{ rhel8stig_010161_keytab_files.stdout_lines }}"
when: rhel8stig_010161_keytab_files.stdout | length > 0
when:
- rhel_08_010161
tags:
- RHEL-08-010161
- CAT2
- CCI-000803
- SRG-OS-000120-GPOS-00061
- SV-230238r646862_rule
- V-230238
- kerberos
- name: "MEDIUM | RHEL-08-010162 | PATCH | The krb5-workstation package must not be installed on RHEL 8."
ansible.builtin.package:
name: krb5-workstation
state: absent
when:
- rhel_08_010162
tags:
- RHEL-08-010162
- CAT2
- CCI-000803
- SRG-OS-000120-GPOS-00061
- SV-230239r646864_rule
- V-230239
- kerberos
- name: "|
MEDIUM | RHEL-08-010170 | PATCH | RHEL8 must use a Linux Security Module configured to enforce limits on system services.
MEDIUM | RHEL-08-010450 | PATCH | RHEL 8 must enable the SELinux targeted policy."
ansible.posix.selinux:
state: enforcing
policy: targeted
check_mode: "{{ ansible_check_mode or rhel8stig_system_is_chroot }}"
notify: change_requires_reboot
when:
- rhel_08_010170 or rhel_08_010450
- rhel8stig_disruption_high
tags:
- CAT2
- RHEL-08-010170
- RHEL-08-010450
- CCI-001084
- CCI-002696
- SRG-OS-000134-GPOS-00068
- SRG-OS-000445-GPOS-00199
- SV-230240r627750_rule
- SV-230282r627750_rule
- V-230240
- V-230282
- selinux
- disruption_high
- name: "MEDIUM | RHEL-08-010190 | PATCH | A sticky bit must be set on all RHEL 8 public directories to prevent unauthorized and unintended information transferred via shared system resources."
block:
- name: "MEDIUM | RHEL-08-010190 | AUDIT | A sticky bit must be set on all RHEL 8 public directories to prevent unauthorized and unintended information transferred via shared system resources. | Find world-writable directories"
ansible.builtin.shell: "find / -xdev -type d \\( -perm -0002 -a ! -perm -1000 \\) -print 2>/dev/null | sed 's/.* //'"
changed_when: false
failed_when: false
register: rhel_08_010190_world_writable_files
- name: "MEDIUM | RHEL-08-010190 | PATCH | A sticky bit must be set on all RHEL 8 public directories to prevent unauthorized and unintended information transferred via shared system resources. | Set sticky bit to world-writable files"
ansible.builtin.file:
path: "{{ item }}"
mode: '+t'
with_items:
- "{{ rhel_08_010190_world_writable_files.stdout_lines }}"
when:
- rhel_08_010190
tags:
- RHEL-08-010190
- CAT2
- CCI-001090
- SRG-OS-000138-GPOS-00069
- SV-230243r792857_rule
- V-230243
- permissions
- name: "MEDIUM | RHEL-08-010200 | PATCH | RHEL 8 must be configured so that all network connections associated with SSH traffic are terminated at the end of the session or after 10 minutes of inactivity, except to fulfill documented and validated mission requirements."
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '(?i)^#?ClientAliveCountMax.*'
line: ClientAliveCountMax 1
validate: '/usr/sbin/sshd -T -f %s'
notify: restart sshd
when:
- rhel_08_010200
- rhel8stig_ssh_required
tags:
- RHEL-08-010200
- CAT2
- CCI-001133
- SRG-OS-000163-GPOS-00072
- SV-230244r951594_rule
- V-230244
- ssh
- name: "MEDIUM | RHEL-08-010201 | PATCH | The RHEL 8 SSH daemon must be configured with a timeout interval"
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '(?i)^#?ClientAliveInterval.*'
line: "ClientAliveInterval {{ rhel8stig_ssh_session_timeout }}"
validate: '/usr/sbin/sshd -T -f %s'
notify: restart sshd
when:
- rhel_08_010201
- rhel8stig_ssh_required
tags:
- RHEL-08-010201
- CAT2
- CCI-001133
- SRG-OS-000163-GPOS-00072
- SV-244525r951596_rule
- V-244525
- ssh
- name: |
"MEDIUM | RHEL-08-010210 | PATCH | The RHEL 8 /var/log/messages file must have mode 0640 or less permissive."
"MEDIUM | RHEL-08-010220 | PATCH | The RHEL 8 /var/log/messages file must be owned by root."
"MEDIUM | RHEL-08-010230 | PATCH | The RHEL 8 /var/log/messages file must be group-owned by root."
ansible.builtin.file:
path: /var/log/messages
owner: root
group: root
mode: "{{ rhel8stig_var_log_messages_perm }}"
when:
- rhel_08_010210 or
rhel_08_010220 or
rhel_08_010230
tags:
- CAT2
- RHEL-08-010210
- RHEL-08-010220
- RHEL-08-010230
- CCI-001314
- SRG-OS-000206-GPOS-00084
- SV-230245r627750_rule
- SV-230246r627750_rule
- SV-230247r627750_rule
- V-230245
- V-230246
- V-230247
- permissions
- name: "MEDIUM | RHEL-08-020025 | PATCH | 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/system-auth file."
block:
- name: "MEDIUM | RHEL-08-020025 | PATCH | 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/system-auth file. | Set preauth"
ansible.builtin.lineinfile:
path: /etc/pam.d/system-auth
regexp: '^auth\s+required\s+pam_faillock.so preauth'
line: "auth required pam_faillock.so preauth dir={{ rhel8stig_pam_faillock.dir }} silent audit deny={{ rhel8stig_pam_faillock.attempts }}{{ (rhel8stig_pam_faillock.fail_for_root) | ternary(' even_deny_root ',' ') }}fail_interval={{ rhel8stig_pam_faillock.interval }} unlock_time={{ rhel8stig_pam_faillock.unlock_time }}"
insertafter: '^auth\s+required\s+pam_env.so'
notify: restart sssd
- name: "MEDIUM | RHEL-08-020025 | PATCH | 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/system-auth file. | Set authfail"
ansible.builtin.lineinfile:
path: /etc/pam.d/system-auth
regexp: '^auth\s+required\s+pam_faillock.so authfail'
line: 'auth required pam_faillock.so authfail dir={{ rhel8stig_pam_faillock.dir }} unlock_time={{ rhel8stig_pam_faillock.unlock_time }}'
insertafter: '^auth'
notify: restart sssd
- name: "MEDIUM | RHEL-08-020025 | PATCH | 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/system-auth file. | Set account faillock"
ansible.builtin.lineinfile:
path: /etc/pam.d/system-auth
regexp: '^account\s+required\s+pam_faillock.so'
line: 'account required pam_faillock.so'
insertbefore: '^account'
notify: restart sssd
when:
- rhel_08_020025
- ansible_distribution_version is version('8.2', '>=')
tags:
- RHEL-08-020025
- CAT2
- CCI-000044
- SRG-OS-000021-GPOS-00005
- SV-244533r743848_rule
- V-244533
- pamd
- name: "MEDIUM | RHEL-08-020026 | PATCH | RHEL 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/password-auth file."
block:
- name: "MEDIUM | RHEL-08-020026 | PATCH | RHEL 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/password-auth file. | Set preauth"
ansible.builtin.lineinfile:
path: /etc/pam.d/password-auth
regexp: '^auth\s+required\s+pam_faillock.so preauth'
line: "auth required pam_faillock.so preauth dir={{ rhel8stig_pam_faillock.dir }} silent audit deny={{ rhel8stig_pam_faillock.attempts }}{{ (rhel8stig_pam_faillock.fail_for_root) | ternary(' even_deny_root ',' ') }}fail_interval={{ rhel8stig_pam_faillock.interval }} unlock_time={{ rhel8stig_pam_faillock.unlock_time }}"
insertafter: '^auth\s+required\s+pam_env.so'
notify: restart sssd
- name: "MEDIUM | RHEL-08-020026 | PATCH | RHEL 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/password-auth file. | Set authfail"
ansible.builtin.lineinfile:
path: /etc/pam.d/password-auth
regexp: '^auth\s+required\s+pam_faillock.so authfail'
line: 'auth required pam_faillock.so authfail dir={{ rhel8stig_pam_faillock.dir }} unlock_time={{ rhel8stig_pam_faillock.unlock_time }}'
insertafter: '^auth'
notify: restart sssd
- name: "MEDIUM | RHEL-08-020026 | PATCH | RHEL 8 must configure the use of the pam_faillock.so module in the /etc/pam.d/password-auth file. | Set account faillock"
ansible.builtin.lineinfile:
path: /etc/pam.d/password-auth
regexp: '^account\s+required\s+pam_faillock.so'
line: 'account required pam_faillock.so'
insertbefore: '^account'
notify: restart sssd
when:
- rhel_08_020026
- ansible_distribution_version is version('8.2', '>=')
tags:
- RHEL-08-020026
- CAT2
- CCI-000044
- SRG-OS-000021-GPOS-00005
- SV-244534r743851_rule
- V-244534
- pamd
- name: "MEDIUM | RHEL-08-020031 | PATCH | RHEL 8 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_08_020031
content: |
[org/gnome/desktop/screensaver]
lock-delay=uint32 5
mode: 'u-x,go-wx'
notify: dconf update
when:
- rhel_08_020031
- rhel8stig_always_configure_dconf
- rhel8stig_gui
tags:
- RHEL-08-020031
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-244535r743854_rule
- V-244535
- dconf
- name: "MEDIUM | RHEL-08-020032 | PATCH | RHEL 8 must disable the user list at logon for graphical user interfaces."
ansible.builtin.copy:
dest: /etc/dconf/db/local.d/02-login-screen_rhel_08_020032
content: |
[org/gnome/login-screen]
disable-user-list=true
mode: 'u-x,go-wx'
when:
- rhel_08_020032
- rhel8stig_always_configure_dconf
- rhel8stig_gui
tags:
- RHEL-08-020032
- CAT2
- CCI-000366
- SRG-OS-000480-GPOS-00227
- SV-244536r743857_rule
- V-244536
- dconf
- name: "MEDIUM | RHEL-08-020039 | PATCH | RHEL 8 must have the tmux package installed."
ansible.builtin.package:
name: tmux
state: present
when:
- rhel_08_020039
- "'tmux' not in ansible_facts.packages"
tags:
- RHEL-08-020039
- CAT2
- CCI-000056
- SRG-OS-000028-GPOS-00009
- SV-244537r743860_rule
- V-244537
- tmux
- name: |
"MEDIUM | RHEL-08-010240 | PATCH | The RHEL 8 /var/log directory must have mode 0755 or less permissive."
"MEDIUM | RHEL-08-010250 | PATCH | The RHEL 8 /var/log directory must be owned by root."
"MEDIUM | RHEL-08-010260 | PATCH | The RHEL 8 /var/log directory must be group-owned by root."
ansible.builtin.file:
path: /var/log
owner: root
group: root
mode: "{{ rhel8stig_var_log_perm }}"
when:
- rhel_08_010240 or
rhel_08_010250 or
rhel_08_010260
tags:
- CAT2
- RHEL-08-010240
- RHEL-08-010250
- RHEL-08-010260
- CCI-001314
- SRG-OS-000206-GPOS-00084
- SV-230248r627750_rule
- SV-230249r627750_rule
- SV-230250r627750_rule
- V-230248
- V-230249
- V-230250
- permissions
- name: "MEDIUM | RHEL-08-020081 | PATCH | RHEL 8 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_08_020081
content: |
/org/gnome/desktop/session/idle-delay
mode: 'u-x,go-wx'
notify: dconf update
when:
- rhel_08_020081
- rhel8stig_always_configure_dconf
- rhel8stig_gui
tags:
- RHEL-08-020081
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-244538r743863_rule
- V-244538
- name: "MEDIUM | RHEL-08-020082 | PATCH | RHEL 8 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_08_020082
content: |
/org/gnome/desktop/screensaver/lock-enabled
mode: 'u-x,go-wx'
notify: dconf update
when:
- rhel_08_020082
- rhel8stig_always_configure_dconf
- rhel8stig_gui
tags:
- RHEL-08-020082
- CAT2
- CCI-000057
- SRG-OS-000029-GPOS-00010
- SV-244539r743866_rule
- V-244539
- dconf
- name: "MEDIUM | RHEL-08-010287 | PATCH | The RHEL 8 SSH daemon must be configured to use system-wide crypto policies."
ansible.builtin.lineinfile:
path: /etc/sysconfig/sshd
regexp: '^CRYPTO_POLICY='
line: '# CRYPTO_POLICY='
notify: change_requires_reboot
when:
- rhel_08_010287
- rhel8stig_ssh_required
tags:
- RHEL-08-010287
- CAT2
- CCI-001453
- SRG-OS-000250-GPOS-00093
- SV-244526r809334_rule
- V-244526
- ssh
- name: "MEDIUM | RHEL-08-010293 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption in the OpenSSL package."
block:
- name: "MEDIUM | RHEL-08-010293 | AUDIT | The RHEL 8 operating system must implement DoD-approved encryption in the OpenSSL package. | Get current FIPS mode state"
ansible.builtin.shell: fips-mode-setup --check
changed_when: false
failed_when: rhel_08_010293_pre_fips_check.stdout is not defined
register: rhel_08_010293_pre_fips_check
- name: "MEDIUM | RHEL-08-010293 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption in the OpenSSL package. | Enable FIPS"
ansible.builtin.shell: fips-mode-setup --enable
notify: change_requires_reboot
when: '"disabled" in rhel_08_010293_pre_fips_check.stdout'
when:
- rhel_08_010293
tags:
- RHEL-08-010293
- CAT2
- CCI-001453
- SRG-OS-000250-GPOS-00093
- SV-230254r627750_rule
- V-230254
- fips
- name: "MEDIUM | RHEL-08-010290 | PATCH | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms. | Add MACs"
block:
- name: "MEDIUM | RHEL-08-010290 | AUDIT | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms. | get MACs"
ansible.builtin.shell: grep "^CRYPTO_POLICY" /etc/crypto-policies/back-ends/opensshserver.config | cut -d "'" -f2 | sed s'/ /\n/g' | grep -i MACs | sed s'/-o//g'
changed_when: false
register: rhel8stig_current_macs
- name: "MEDIUM | RHEL-08-010290 | PATCH | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms. | get MACs"
ansible.builtin.lineinfile:
path: /etc/crypto-policies/back-ends/opensshserver.config
regexp: '(^CRYPTO_POLICY=.*)-o{{ rhel8stig_current_macs.stdout }}(.*$)'
line: '\g<1>-o{{ rhel8stig_ssh_macs }}\g<2>'
backrefs: true
notify: change_requires_reboot
when:
- rhel_08_010290
tags:
- CAT2
- RHEL-08-010290
- CCI-001453
- SRG-OS-000250-GPOS-00093
- SV-230251r917870_rule
- V-230251
- fips
- name: "MEDIUM | RHEL-08-010291 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH server connections. | Add Ciphers"
block:
- name: "MEDIUM | RHEL-08-010291 | AUDIT | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH server connections. | get Ciphers"
ansible.builtin.shell: grep "^CRYPTO_POLICY" /etc/crypto-policies/back-ends/opensshserver.config | cut -d "'" -f2 | sed s'/ /\n/g' | grep -i Ciphers | sed s'/-o//g'
changed_when: false
register: rhel8stig_current_ciphers
- name: "MEDIUM | RHEL-08-010291 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH server connections. | Apply Ciphers"
ansible.builtin.lineinfile:
path: /etc/crypto-policies/back-ends/opensshserver.config
regexp: '(^CRYPTO_POLICY=.*)-o{{ rhel8stig_current_ciphers.stdout }}(.*$)'
line: '\g<1>-o{{ rhel8stig_ssh_ciphers }}\g<2>'
backrefs: true
notify: change_requires_reboot
when:
- rhel_08_010291
tags:
- CAT2
- RHEL-08-010291
- CCI-001453
- SRG-OS-000250-GPOS-00093
- SV-230252r917873_rule
- V-230252
- fips
- name: "MEDIUM | RHEL-08-010294 | PATCH | The RHEL 8 operating system must implement DoD-approved TLS encryption in the OpenSSL package."
block:
- name: "MEDIUM | RHEL-08-010294 | PATCH | The RHEL 8 operating system must implement DoD-approved TLS encryption in the OpenSSL package."
ansible.builtin.lineinfile:
path: /etc/crypto-policies/back-ends/opensslcnf.config
regexp: '^MinProtocol ='
line: "MinProtocol = TLSv1.2"
notify: change_requires_reboot
when: ansible_facts.packages['crypto-policies'][0].version | int < 20210617
- name: "MEDIUM | RHEL-08-010294 | PATCH | The RHEL 8 operating system must implement DoD-approved TLS encryption in the OpenSSL package."
ansible.builtin.lineinfile:
path: /etc/crypto-policies/back-ends/opensslcnf.config
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
notify: change_requires_reboot
with_items:
- { regexp: '^TLS.MinProtocol = ', line: "TLS.MinProtocol = TLSv1.2" }
- { regexp: '^DTLS.MinProtocol =', line: "DTLS.MinProtocol = DTLSv1.2" }
when: ansible_facts.packages['crypto-policies'][0].version | int >= 20210617
when:
- rhel_08_010294
tags:
- RHEL-08-010294
- CAT2
- CCI-001453
- SRG-OS-000250-GPOS-00093
- SV-230255r809382_rule
- V-230255
- openssl
- name: "MEDIUM | RHEL-08-010295 | PATCH | The RHEL 8 operating system must implement DoD-approved TLS encryption in the GnuTLS package"
ansible.builtin.lineinfile:
path: /etc/crypto-policies/back-ends/gnutls.config
regexp: '^(.*)\+VERS-ALL:'
line: '\1{{ rhel8stig_gnutls_encryption }}'
backrefs: true
notify: change_requires_reboot
when:
- rhel_08_010295
tags:
- RHEL-08-010295
- CAT2
- CCI-001453
- SRG-OS-000250-GPOS-00093
- SV-230256r792859_rule
- V-230256
- gnutls
- name: |
"MEDIUM | RHEL-08-010300 | PATCH | RHEL 8 system commands must have mode 0755 or less permissive."
"MEDIUM | RHEL-08-010310 | PATCH | RHEL 8 system commands must be owned by root."
"MEDIUM | RHEL-08-010320 | PATCH | RHEL 8 system commands must be group-owned by root or a system account."
block:
- name: |
"MEDIUM | RHEL-08-010300 | AUDIT | RHEL 8 system commands must have mode 0755 or less permissive. | Get commands less permissive"
"MEDIUM | RHEL-08-010310 | AUDIT | RHEL 8 system commands must be owned by root. | Get commands not owned by root"
"MEDIUM | RHEL-08-010320 | AUDIT | RHEL 8 system commands must be group-owned by root or a system account. | Get commands no group-owned by root"
ansible.builtin.shell: "find -L /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -perm /0022 -o ! -user root -o ! -group root"
changed_when: false
failed_when: false
register: rhel_08_010300_commands
- name: |
"MEDIUM | RHEL-08-010300 | PATCH | RHEL 8 system commands must have mode 0755 or less permissive. | Set permissions"
"MEDIUM | RHEL-08-010310 | PATCH | RHEL 8 system commands must be owned by root. | Set permissions"
"MEDIUM | RHEL-08-010320 | PATCH | RHEL 8 system commands must be group-owned by root or a system account. | Set permissions"
ansible.builtin.file:
path: "{{ item }}"
owner: root
group: root
mode: "{{ rhel8stig_sys_commands_perm }}"
force: true
with_items:
- "{{ rhel_08_010300_commands.stdout_lines }}"
when:
- rhel_08_010300 or
rhel_08_010310 or
rhel_08_010320
tags:
- CAT2
- RHEL-08-010300
- RHEL-08-010310
- RHEL-08-010320
- CCI-001499
- SRG-OS-000259-GPOS-00100
- SV-230257r792862_rule
- SV-230258r627750_rule
- SV-230259r792864_rule
- V-230257
- V-230258
- V-230259
- permissions
- name: |
"MEDIUM | RHEL-08-010330 | AUDIT | RHEL 8 library files must have mode 0755 or less permissive."
"MEDIUM | RHEL-08-010340 | AUDIT | RHEL 8 library files must be owned by root."
"MEDIUM | RHEL-08-010350 | AUDIT | RHEL 8 library files must be group-owned by root or a system account."
block:
- name: |
"MEDIUM | RHEL-08-010330 | AUDIT | RHEL 8 library files must have mode 0755 or less permissive. | Get library files with mode 0755 or less"
"MEDIUM | RHEL-08-010340 | AUDIT | RHEL 8 library files must be owned by root. | Get library files not owned by root"
"MEDIUM | RHEL-08-010350 | AUDIT | RHEL 8 library files must be group-owned by root or a system account. | Get library files not group-owned by root"
ansible.builtin.shell: "find -L /lib /lib64 /usr/lib /usr/lib64 -perm /0022 -type f -o ! -user root -o ! -group root"
changed_when: false
failed_when: false
register: rhel_08_010330_library_files
- name: |
"MEDIUM | RHEL-08-010330 | PATCH | RHEL 8 library files must have mode 0755 or less permissive. | Get library files with mode 0755 or less"
"MEDIUM | RHEL-08-010340 | PATCH | RHEL 8 library files must be owned by root. | Get library files not owned by root"
"MEDIUM | RHEL-08-010350 | PATCH | RHEL 8 library files must be group-owned by root or a system account. | Get library files not group-owned by root"
ansible.builtin.file:
path: "{{ item }}"
owner: "{{ rhel_08_010340 | ternary('root',omit) }}"
group: "{{ rhel_08_010350 | ternary('root',omit) }}"
mode: "{{ rhel_08_010330 | ternary(rhel8stig_lib_file_perm,omit) }}"