This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmunki_script_checks.tf
1958 lines (1788 loc) · 69.7 KB
/
munki_script_checks.tf
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
resource "zentral_munki_script_check" "mcs-auditing-audit_acls_files_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Files to Not Contain Access Control Lists"
description = trimspace(<<EODESC
The audit log files _MUST_ not contain access control lists (ACLs).
This rule ensures that audit information and audit files are configured to be readable and writable only by system administrators, thereby preventing unauthorized access, modification, and deletion of files.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -le $(/usr/bin/grep '^dir' /etc/security/audit_control | /usr/bin/awk -F: '{print $2}') | /usr/bin/awk '{print $1}' | /usr/bin/grep -c ":"
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_acls_folders_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Folder to Not Contain Access Control Lists"
description = trimspace(<<EODESC
The audit log folder _MUST_ not contain access control lists (ACLs).
Audit logs contain sensitive data about the system and users. This rule ensures that the audit service is configured to create log folders that are readable and writable only by system administrators in order to prevent normal users from reading audit logs.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -lde /var/audit | /usr/bin/awk '{print $1}' | /usr/bin/grep -c ":"
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_auditd_enabled" {
name = "[mSCP] - Auditing - Enable Security Auditing"
description = trimspace(<<EODESC
The information system _MUST_ be configured to generate audit records.
Audit records establish what types of events have occurred, when they occurred, and which users were involved. These records aid an organization in their efforts to establish, correlate, and investigate the events leading up to an outage or attack.
The content required to be captured in an audit record varies based on the impact level of an organization's system. Content that may be necessary to satisfy this requirement includes, for example, time stamps, source addresses, destination addresses, user identifiers, event descriptions, success/fail indications, filenames involved, and access or flow control rules invoked.
The information system initiates session audits at system start-up.
NOTE: Security auditing is NOT enabled by default on macOS Sonoma.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
LAUNCHD_RUNNING=$(/bin/launchctl list | /usr/bin/grep -c com.apple.auditd)
AUDITD_RUNNING=$(/usr/sbin/audit -c | /usr/bin/grep -c "AUC_AUDITING")
if [[ $LAUNCHD_RUNNING == 1 ]] && [[ -e /etc/security/audit_control ]] && [[ $AUDITD_RUNNING == 1 ]]; then
echo "pass"
else
echo "fail"
fi
EOSRC
)
expected_result = "pass"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_control_acls_configure" {
name = "[mSCP] - Auditing - Configure Audit_Control to Not Contain Access Control Lists"
description = trimspace(<<EODESC
/etc/security/audit_control _MUST_ not contain Access Control Lists (ACLs).
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -le /etc/security/audit_control | /usr/bin/awk '{print $1}' | /usr/bin/grep -c ":"
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_control_group_configure" {
name = "[mSCP] - Auditing - Configure Audit_Control Group to Wheel"
description = trimspace(<<EODESC
/etc/security/audit_control _MUST_ have the group set to wheel.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -dn /etc/security/audit_control | /usr/bin/awk '{print $4}'
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_control_mode_configure" {
name = "[mSCP] - Auditing - Configure Audit_Control Owner to Mode 440 or Less Permissive"
description = trimspace(<<EODESC
/etc/security/audit_control _MUST_ be configured so that it is readable only by the root user and group wheel.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -l /etc/security/audit_control | /usr/bin/awk '!/-r--[r-]-----|current|total/{print $1}' | /usr/bin/wc -l | /usr/bin/xargs
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_control_owner_configure" {
name = "[mSCP] - Auditing - Configure Audit_Control Owner to Root"
description = trimspace(<<EODESC
/etc/security/audit_control _MUST_ have the owner set to root.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -dn /etc/security/audit_control | /usr/bin/awk '{print $3}'
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_files_group_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Files Group to Wheel"
description = trimspace(<<EODESC
Audit log files _MUST_ have the group set to wheel.
The audit service _MUST_ be configured to create log files with the correct group ownership to prevent normal users from reading audit logs.
Audit logs contain sensitive data about the system and users. If log files are set to be readable and writable only by system administrators, the risk is mitigated.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -n $(/usr/bin/grep '^dir' /etc/security/audit_control | /usr/bin/awk -F: '{print $2}') | /usr/bin/awk '{s+=$4} END {print s}'
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_files_mode_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Files to Mode 440 or Less Permissive"
description = trimspace(<<EODESC
The audit service _MUST_ be configured to create log files that are readable only by the root user and group wheel. To achieve this, audit log files _MUST_ be configured to mode 440 or less permissive; thereby preventing normal users from reading, modifying or deleting audit logs.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -l $(/usr/bin/grep '^dir' /etc/security/audit_control | /usr/bin/awk -F: '{print $2}') | /usr/bin/awk '!/-r--r-----|current|total/{print $1}' | /usr/bin/wc -l | /usr/bin/tr -d ' '
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_files_owner_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Files to be Owned by Root"
description = trimspace(<<EODESC
Audit log files _MUST_ be owned by root.
The audit service _MUST_ be configured to create log files with the correct ownership to prevent normal users from reading audit logs.
Audit logs contain sensitive data about the system and users. If log files are set to only be readable and writable by system administrators, the risk is mitigated.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -n $(/usr/bin/grep '^dir' /etc/security/audit_control | /usr/bin/awk -F: '{print $2}') | /usr/bin/awk '{s+=$3} END {print s}'
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_folder_group_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Folders Group to Wheel"
description = trimspace(<<EODESC
Audit log files _MUST_ have the group set to wheel.
The audit service _MUST_ be configured to create log files with the correct group ownership to prevent normal users from reading audit logs.
Audit logs contain sensitive data about the system and users. If log files are set to be readable and writable only by system administrators, the risk is mitigated.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -dn $(/usr/bin/grep '^dir' /etc/security/audit_control | /usr/bin/awk -F: '{print $2}') | /usr/bin/awk '{print $4}'
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_folder_owner_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Folders to be Owned by Root"
description = trimspace(<<EODESC
Audit log folders _MUST_ be owned by root.
The audit service _MUST_ be configured to create log folders with the correct ownership to prevent normal users from reading audit logs.
Audit logs contain sensitive data about the system and users. If log folders are set to only be readable and writable by system administrators, the risk is mitigated.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls -dn $(/usr/bin/grep '^dir' /etc/security/audit_control | /usr/bin/awk -F: '{print $2}') | /usr/bin/awk '{print $3}'
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_folders_mode_configure" {
name = "[mSCP] - Auditing - Configure Audit Log Folders to Mode 700 or Less Permissive"
description = trimspace(<<EODESC
The audit log folder _MUST_ be configured to mode 700 or less permissive so that only the root user is able to read, write, and execute changes to folders.
Because audit logs contain sensitive data about the system and users, the audit service _MUST_ be configured to mode 700 or less permissive; thereby preventing normal users from reading, modifying or deleting audit logs.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/stat -f %A $(/usr/bin/grep '^dir' /etc/security/audit_control | /usr/bin/awk -F: '{print $2}')
EOSRC
)
expected_result = "700"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-auditing-audit_retention_configure" {
name = "[mSCP] - Auditing - Configure Audit Retention to 7d"
description = trimspace(<<EODESC
The audit service _MUST_ be configured to require records be kept for a organizational defined value before deletion, unless the system uses a central audit record storage facility.
When "expire-after" is set to "7d", the audit service will not delete audit logs until the log data criteria is met.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/awk -F: '/expire-after/{print $2}' /etc/security/audit_control
EOSRC
)
expected_result = "7d"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_airdrop_disable" {
name = "[mSCP] - macOS - Disable AirDrop"
description = trimspace(<<EODESC
AirDrop _MUST_ be disabled to prevent file transfers to or from unauthorized devices.
AirDrop allows users to share and receive files from other nearby Apple devices.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/osascript -l JavaScript << EOS
$.NSUserDefaults.alloc.initWithSuiteName('com.apple.applicationaccess')\
.objectForKey('allowAirDrop').js
EOS
EOSRC
)
expected_result = "false"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_anti_virus_installed" {
name = "[mSCP] - macOS - Must Use an Approved Antivirus Program"
description = trimspace(<<EODESC
An approved antivirus product _MUST_ be installed and configured to run.
Malicious software can establish a base on individual desktops and servers. Employing an automated mechanism to detect this type of software will aid in elimination of the software from the operating system.'
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/launchctl list | /usr/bin/grep -cE "(com.apple.XprotectFramework.PluginService$|com.apple.XProtect.daemon.scan$)"
EOSRC
)
expected_result = "2"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_authenticated_root_enable" {
name = "[mSCP] - macOS - Enable Authenticated Root"
description = trimspace(<<EODESC
Authenticated Root _MUST_ be enabled.
When Authenticated Root is enabled the macOS is booted from a signed volume that is cryptographically protected to prevent tampering with the system volume.
NOTE: Authenticated Root is enabled by default on macOS systems.
WARNING: If more than one partition with macOS is detected, the csrutil command will hang awaiting input.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/csrutil authenticated-root | /usr/bin/grep -c 'enabled'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_config_data_install_enforce" {
name = "[mSCP] - macOS - Enforce Installation of XProtect Remediator and Gatekeeper Updates Automatically"
description = trimspace(<<EODESC
Software Update _MUST_ be configured to update XProtect Remediator and Gatekeeper automatically.
This setting enforces definition updates for XProtect Remediator and Gatekeeper; with this setting in place, new malware and adware that Apple has added to the list of malware or untrusted software will not execute. These updates do not require the computer to be restarted.
link:https://support.apple.com/en-us/HT207005[]
NOTE: Software update will automatically update XProtect Remediator and Gatekeeper by default in the macOS.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/osascript -l JavaScript << EOS
$.NSUserDefaults.alloc.initWithSuiteName('com.apple.SoftwareUpdate')\
.objectForKey('ConfigDataInstall').js
EOS
EOSRC
)
expected_result = "true"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_firewall_log_enable" {
name = "[mSCP] - macOS - Enable Firewall Logging"
description = trimspace(<<EODESC
Firewall logging _MUST_ be enabled.
Firewall logging ensures that malicious network activity will be logged to the system.
NOTE: The firewall data is logged to Apple's Unified Logging with the subsystem `com.apple.alf` and the data is marked as private. In order to enable private data, review the `com.apple.alf.private_data.mobileconfig` file in the project's `includes` folder.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/osascript -l JavaScript << EOS
function run() {
let pref1 = $.NSUserDefaults.alloc.initWithSuiteName('com.apple.security.firewall')\
.objectForKey('EnableLogging').js
let pref2 = $.NSUserDefaults.alloc.initWithSuiteName('com.apple.security.firewall')\
.objectForKey('LoggingOption').js
if ( pref1 == true && pref2 == "detail" ){
return("true")
} else {
return("false")
}
}
EOS
EOSRC
)
expected_result = "true"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_gatekeeper_enable" {
name = "[mSCP] - macOS - Enable Gatekeeper"
description = trimspace(<<EODESC
Gatekeeper _MUST_ be enabled.
Gatekeeper is a security feature that ensures that applications are digitally signed by an Apple-issued certificate before they are permitted to run. Digital signatures allow the macOS host to verify that the application has not been modified by a malicious third party.
Administrator users will still have the option to override these settings on a case-by-case basis.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/sbin/spctl --status | /usr/bin/grep -c "assessments enabled"
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_guest_folder_removed" {
name = "[mSCP] - macOS - Remove Guest Folder if Present"
description = trimspace(<<EODESC
The guest folder _MUST_ be deleted if present.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/ls /Users/ | /usr/bin/grep -c "Guest"
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_home_folders_secure" {
name = "[mSCP] - macOS - Secure User's Home Folders"
description = trimspace(<<EODESC
The system _MUST_ be configured to prevent access to other user's home folders.
The default behavior of macOS is to allow all valid users access to the top level of every other user's home folder while restricting access only to the Apple default folders within.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/find /System/Volumes/Data/Users -mindepth 1 -maxdepth 1 -type d ! \( -perm 700 -o -perm 711 \) | /usr/bin/grep -v "Shared" | /usr/bin/grep -v "Guest" | /usr/bin/wc -l | /usr/bin/xargs
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_httpd_disable" {
name = "[mSCP] - macOS - Disable the Built-in Web Server"
description = trimspace(<<EODESC
The built-in web server is a non-essential service built into macOS and _MUST_ be disabled.
NOTE: The built in web server service is disabled at startup by default macOS.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/launchctl print-disabled system | /usr/bin/grep -c '"org.apache.httpd" => disabled'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_install_log_retention_configure" {
name = "[mSCP] - macOS - Configure Install.log Retention to 365"
description = trimspace(<<EODESC
The install.log _MUST_ be configured to require records be kept for a organizational defined value before deletion, unless the system uses a central audit record storage facility.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/sbin/aslmanager -dd 2>&1 | /usr/bin/awk '/\/var\/log\/install.log$/ {count++} /Processing module com.apple.install/,/Finished/ { for (i=1;i<=NR;i++) { if ($i == "TTL" && $(i+2) >= 365) { ttl="True" }; if ($i == "MAX") {max="True"}}} END{if (count > 1) { print "Multiple config files for /var/log/install, manually remove the extra files"} else if (max == "True") { print "all_max setting is configured, must be removed" } if (ttl != "True") { print "TTL not configured" } else { print "Yes" }}'
EOSRC
)
expected_result = "Yes"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_mdm_require" {
name = "[mSCP] - macOS - Enforce Enrollment in Mobile Device Management"
description = trimspace(<<EODESC
You _MUST_ enroll your Mac in a Mobile Device Management (MDM) software.
User Approved MDM (UAMDM) enrollment or enrollment via Apple Business Manager (ABM)/Apple School Manager (ASM) is required to manage certain security settings. Currently these include:
* Allowed Kernel Extensions
* Allowed Approved System Extensions
* Privacy Preferences Policy Control Payload
* ExtensibleSingleSignOn
* FDEFileVault
In macOS 11, UAMDM grants Supervised status on a Mac, unlocking the following MDM features, which were previously locked behind ABM:
* Activation Lock Bypass
* Access to Bootstrap Tokens
* Scheduling Software Updates
* Query list and delete local users
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles status -type enrollment | /usr/bin/awk -F: '/MDM enrollment/ {print $2}' | /usr/bin/grep -c "Yes (User Approved)"
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_mobile_file_integrity_enable" {
name = "[mSCP] - macOS - Enable Apple Mobile File Integrity"
description = trimspace(<<EODESC
Mobile file integrity _MUST_ be ebabled.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/sbin/nvram -p | /usr/bin/grep -c "amfi_get_out_of_my_way=1"
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_nfsd_disable" {
name = "[mSCP] - macOS - Disable Network File System Service"
description = trimspace(<<EODESC
Support for Network File Systems (NFS) services is non-essential and, therefore, _MUST_ be disabled.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/bin/launchctl print-disabled system | /usr/bin/grep -c '"com.apple.nfsd" => disabled'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_on_device_dictation_enforce" {
name = "[mSCP] - macOS - Enforce On Device Dictation"
description = trimspace(<<EODESC
Dictation _MUST_ be restricted to on device only to prevent potential data exfiltration.
The information system _MUST_ be configured to provide only essential capabilities.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/osascript -l JavaScript << EOS
$.NSUserDefaults.alloc.initWithSuiteName('com.apple.applicationaccess')\
.objectForKey('forceOnDeviceOnlyDictation').js
EOS
EOSRC
)
expected_result = "true"
arch_amd64 = false
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_password_hint_remove" {
name = "[mSCP] - macOS - Remove Password Hint From User Accounts"
description = trimspace(<<EODESC
User accounts _MUST_ not contain password hints.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
HINT=$(/usr/bin/dscl . -list /Users hint | /usr/bin/awk '{ print $2 }')
if [ -z "$HINT" ]; then
echo "PASS"
else
echo "FAIL"
fi
EOSRC
)
expected_result = "PASS"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_power_nap_disable" {
name = "[mSCP] - macOS - Disable Power Nap"
description = trimspace(<<EODESC
Power Nap _MUST_ be disabled.
NOTE: Power Nap allows your Mac to perform actions while a Mac is asleep. This can interfere with USB power and may cause devices such as smartcards to stop functioning until a reboot and must therefore be disabled on all applicable systems.
The following Macs support Power Nap:
* MacBook (Early 2015 and later)
* MacBook Air (Late 2010 and later)
* MacBook Pro (all models with Retina display)
* Mac mini (Late 2012 and later)
* iMac (Late 2012 and later)
* Mac Pro (Late 2013 and later)
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/pmset -g custom | /usr/bin/awk '/powernap/ { sum+=$2 } END {print sum}'
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = false
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_root_disable" {
name = "[mSCP] - macOS - Disable Root Login"
description = trimspace(<<EODESC
To assure individual accountability and prevent unauthorized access, logging in as root at the login window _MUST_ be disabled.
The macOS system _MUST_ require individuals to be authenticated with an individual authenticator prior to using a group authenticator, and administrator users _MUST_ never log in directly as root.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/dscl . -read /Users/root UserShell 2>&1 | /usr/bin/grep -c "/usr/bin/false"
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_safari_advertising_privacy_protection_enable" {
name = "[mSCP] - macOS - Ensure Advertising Privacy Protection in Safari Is Enabled"
description = trimspace(<<EODESC
Allow privacy-preserving measurement of ad effectiveness _MUST_ be enabled in Safari.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles -P -o stdout | /usr/bin/grep -c '"WebKitPreferences.privateClickMeasurementEnabled" = 1' | /usr/bin/awk '{ if ($1 >= 1) {print "1"} else {print "0"}}'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_safari_open_safe_downloads_disable" {
name = "[mSCP] - macOS - Disable Automatic Opening of Safe Files in Safari"
description = trimspace(<<EODESC
Open "safe" files after downloading _MUST_ be disabled in Safari.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles -P -o stdout | /usr/bin/grep -c 'AutoOpenSafeDownloads = 0' | /usr/bin/awk '{ if ($1 >= 1) {print "1"} else {print "0"}}'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_safari_popups_disabled" {
name = "[mSCP] - macOS - Ensure Pop-Up Windows are Blocked in Safari"
description = trimspace(<<EODESC
Safari _MUST_ be configured to block Pop-Up windows.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles -P -o stdout | /usr/bin/grep -c 'safariAllowPopups = 0' | /usr/bin/awk '{ if ($1 >= 1) {print "1"} else {print "0"}}'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_safari_prevent_cross-site_tracking_enable" {
name = "[mSCP] - macOS - Ensure Prevent Cross-site Tracking in Safari Is Enabled"
description = trimspace(<<EODESC
Prevent cross-site tracking _MUST_ be enabled in Safari.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles -P -o stdout | /usr/bin/grep -cE '"WebKitPreferences.storageBlockingPolicy" = 1|"WebKitStorageBlockingPolicy" = 1|"BlockStoragePolicy" =2' | /usr/bin/awk '{ if ($1 >= 1) {print "1"} else {print "0"}}'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_safari_show_full_website_address_enable" {
name = "[mSCP] - macOS - Ensure Show Full Website Address in Safari Is Enabled"
description = trimspace(<<EODESC
Show full website address _MUST_ be enabled in Safari.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles -P -o stdout | /usr/bin/grep -c 'ShowFullURLInSmartSearchField = 1' | /usr/bin/awk '{ if ($1 >= 1) {print "1"} else {print "0"}}'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_safari_show_status_bar_enabled" {
name = "[mSCP] - macOS - Ensure Show Safari shows the Status Bar is Enabled"
description = trimspace(<<EODESC
Safari _MUST_ be configured to show the status bar.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles -P -o stdout | /usr/bin/grep -c 'ShowOverlayStatusBar = 1' | /usr/bin/awk '{ if ($1 >= 1) {print "1"} else {print "0"}}'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_safari_warn_fraudulent_website_enable" {
name = "[mSCP] - macOS - Ensure Warn When Visiting A Fraudulent Website in Safari Is Enabled"
description = trimspace(<<EODESC
Warn when visiting a fraudulent website _MUST_ be enabled in Safari.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/profiles -P -o stdout | /usr/bin/grep -c 'WarnAboutFraudulentWebsites = 1' | /usr/bin/awk '{ if ($1 >= 1) {print "1"} else {print "0"}}'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_show_filename_extensions_enable" {
name = "[mSCP] - macOS - Enable Show All Filename Extensions"
description = trimspace(<<EODESC
Show all filename extensions _MUST_ be enabled in the Finder.
[NOTE]
====
The check and fix are for the currently logged in user. To get the currently logged in user, run the following.
[source,bash]
----
CURRENT_USER=$( /usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
----
====
EODESC
)
type = "ZSH_BOOL"
source = trimspace(<<EOSRC
/usr/bin/sudo -u "$CURRENT_USER" /usr/bin/defaults read .GlobalPreferences AppleShowAllExtensions 2>/dev/null
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_sip_enable" {
name = "[mSCP] - macOS - Ensure System Integrity Protection is Enabled"
description = trimspace(<<EODESC
System Integrity Protection (SIP) _MUST_ be enabled.
SIP is vital to protecting the integrity of the system as it prevents malicious users and software from making unauthorized and/or unintended modifications to protected files and folders; ensures the presence of an audit record generation capability for defined auditable events for all operating system components; protects audit tools from unauthorized access, modification, and deletion; restricts the root user account and limits the actions that the root user can perform on protected parts of the macOS; and prevents non-privileged users from granting other users direct access to the contents of their home directories and folders.
NOTE: SIP is enabled by default in macOS.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/csrutil status | /usr/bin/grep -c 'System Integrity Protection status: enabled.'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_software_update_deferral" {
name = "[mSCP] - macOS - Ensure Software Update Deferment Is Less Than or Equal to 30 Days"
description = trimspace(<<EODESC
Software updates _MUST_ be deferred for 30 days or less.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/osascript -l JavaScript << EOS
function run() {
let timeout = ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('com.apple.applicationaccess')\
.objectForKey('enforcedSoftwareUpdateDelay')) || 0
if ( timeout <= 30 ) {
return("true")
} else {
return("false")
}
}
EOS
EOSRC
)
expected_result = "true"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_sudo_timeout_configure" {
name = "[mSCP] - macOS - Configure Sudo Timeout Period to 0"
description = trimspace(<<EODESC
The file /etc/sudoers _MUST_ include a timestamp_timeout of 0.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/sudo /usr/bin/sudo -V | /usr/bin/grep -c "Authentication timestamp timeout: 0.0 minutes"
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_sudoers_timestamp_type_configure" {
name = "[mSCP] - macOS - Configure Sudoers Timestamp Type"
description = trimspace(<<EODESC
The file /etc/sudoers _MUST_ be configured to not include a timestamp_type of global or ppid and be configured for timestamp record types of tty.
This rule ensures that the "sudo" command will prompt for the administrator's password at least once in each newly opened terminal window. This prevents a malicious user from taking advantage of an unlocked computer or an abandoned logon session by bypassing the normal password prompt requirement.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/sudo /usr/bin/sudo -V | /usr/bin/awk -F": " '/Type of authentication timestamp record/{print $2}'
EOSRC
)
expected_result = "tty"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_system_wide_applications_configure" {
name = "[mSCP] - macOS - Ensure Appropriate Permissions Are Enabled for System Wide Applications"
description = trimspace(<<EODESC
Applications in the System Applications Directory (/Applications) _MUST_ not be world-writable.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/find /Applications -iname "*\.app" -type d -perm -2 -ls | /usr/bin/wc -l | /usr/bin/xargs
EOSRC
)
expected_result = "0"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_terminal_secure_keyboard_enable" {
name = "[mSCP] - macOS - Ensure Secure Keyboard Entry Terminal.app is Enabled"
description = trimspace(<<EODESC
Secure keyboard entry _MUST_ be enabled in Terminal.app.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/osascript -l JavaScript << EOS
$.NSUserDefaults.alloc.initWithSuiteName('com.apple.Terminal')\
.objectForKey('SecureKeyboardEntry').js
EOS
EOSRC
)
expected_result = "true"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_time_offset_limit_configure" {
name = "[mSCP] - macOS - Ensure Time Offset Within Limits"
description = trimspace(<<EODESC
The macOS system time _MUST_ be monitored to not drift more than four minutes and thirty seconds.
EODESC
)
type = "ZSH_STR"
source = trimspace(<<EOSRC
/usr/bin/sntp $(/usr/sbin/systemsetup -getnetworktimeserver | /usr/bin/awk '{print $4}') | /usr/bin/awk -F'.' '/\+\/\-/{if (substr($1,2) >= 270) {print "No"} else {print "Yes"}}'
EOSRC
)
expected_result = "Yes"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}
resource "zentral_munki_script_check" "mcs-macos-os_unlock_active_user_session_disable" {
name = "[mSCP] - macOS - Disable Login to Other User's Active and Locked Sessions"
description = trimspace(<<EODESC
The ability to log in to another user's active or locked session _MUST_ be disabled.
macOS has a privilege that can be granted to any user that will allow that user to unlock active user's sessions. Disabling the admins and/or user's ability to log into another user's active and locked session prevents unauthorized persons from viewing potentially sensitive and/or personal information.
NOTE: Configuring this setting will change the user experience and disable TouchID from unlocking the screensaver. To restore the user experience and allow TouchID to unlock the screensaver, you can run `/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow screenUnlockMode -int 1`. This setting can also be deployed with a configuration profile.
EODESC
)
type = "ZSH_INT"
source = trimspace(<<EOSRC
/usr/bin/security authorizationdb read system.login.screensaver 2>&1 | /usr/bin/grep -c '<string>authenticate-session-owner</string>'
EOSRC
)
expected_result = "1"
arch_amd64 = true
arch_arm64 = true
min_os_version = "14"
max_os_version = "15"
}