-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathdefinitions.yaml
1728 lines (1615 loc) · 59.4 KB
/
definitions.yaml
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
---
controls:
id: "17.06"
description: "CIS Docker Community Edition Benchmark"
groups:
- id: 1
description: "Host Configuration"
checks:
- id: 1.1
description: "Ensure a separate partition for containers has been created (Scored)"
audit: grep $docker-storage /etc/fstab
tests:
test_items:
- flag: "$docker-storage"
set: true
remediation: "For new installations, create a separate partition for $docker-storage
mount point. For systems that were previously installed, use the Logical Volume Manager
(LVM) to create partitions."
scored: true
- id: 1.2
description: "Ensure the container host has been Hardened (Not Scored)"
type: manual
remediation: "You may consider various CIS Security Benchmarks for your container host.
If you have other security guidelines or regulatory requirements to adhere to, please
follow them as suitable in your environment.
Additionally, you can run a kernel with grsecurity and PaX . This would add many safety
checks, both at compile-time and run-time. It is also designed to defeat many exploits and
has powerful security features. These features do not require Docker-specific
configuration, since those security features apply system-wide, independent of containers."
scored: false
- id: 1.3
description: "Ensure Docker is up to date (Not Scored)"
audit: "docker version"
type: manual
remediation: "Keep a track of Docker releases and update as necessary."
scored: false
- id: 1.4
description: "Ensure only trusted users are allowed to control Docker daemon (Scored)"
audit: "getent group docker"
type: manual
remediation: "Remove any users from the docker group that are not trusted. Additionally,
do not create a mapping of sensitive directories on host to container volumes."
scored: true
- id: 1.5
description: "Ensure auditing is configured for the docker daemon (Scored)"
audit: "auditctl -l | grep /usr/bin/docker"
tests:
test_items:
- flag: "/usr/bin/docker"
set: true
remediation: "Add a rule for Docker daemon.
For example,
Add the line as below line in /etc/audit/audit.rules file:\n
-w /usr/bin/docker -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.6
description: "Ensure auditing is configured for Docker files and directories -
$docker-storage (Scored)"
audit: "auditctl -l | grep $docker-storage"
tests:
test_items:
- flag: "$docker-storage"
set: true
remediation: "Add a rule for $docker-storage directory.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w $docker-storage -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.7
description: "Ensure auditing is configured for Docker files and directories -
/etc/docker (Scored)"
audit: "auditctl -l | grep /etc/docker"
tests:
test_items:
- flag: "/etc/docker"
set: true
remediation: "Add a rule for /etc/docker directory.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w /etc/docker -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.8
description: "Ensure auditing is configured for Docker files and directories -
docker.service (Scored)"
audit: "systemctl show -p FragmentPath docker.service | awk -F \"=\" '{print $2}' |xargs -I % test -f % && auditctl -l | grep `systemctl show -p FragmentPath docker.service | awk -F \"=\" '{print $2}'`"
tests:
test_items:
- flag: "docker.service"
set: true
remediation: "If the file exists, add a rule for it.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w /usr/lib/systemd/system/docker.service -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.9
description: "Ensure auditing is configured for Docker files and directories -
docker.socket (Scored)"
audit: "systemctl show -p FragmentPath docker.socket | awk -F \"=\" '{print $2}' |xargs -I % test -f % && auditctl -l | grep `systemctl show -p FragmentPath docker.socket | awk -F \"=\" '{print $2}'`"
tests:
test_items:
- flag: "docker.socket"
set: true
remediation: "If the file exists, add a rule for it.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w /usr/lib/systemd/system/docker.socket -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.10
description: "Ensure auditing is configured for Docker files and directories -
/etc/default/docker (Scored)"
audit: "auditctl -l | grep /etc/default/docker"
tests:
test_items:
- flag: "/etc/default/docker"
set: true
remediation: "Add a rule for /etc/default/docker file.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w /etc/default/docker -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.11
description: "Ensure auditing is configured for Docker files and directories -
/etc/docker/daemon.json (Scored)"
audit: "auditctl -l | grep /etc/docker/daemon.json"
tests:
test_items:
- flag: "/etc/docker/daemon.json"
set: true
remediation: "Add a rule for /etc/docker/daemon.json file.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w /etc/docker/daemon.json -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.12
description: "Ensure auditing is configured for Docker files and directories -
/usr/bin/docker-containerd (Scored)"
audit: "auditctl -l | grep /usr/bin/docker-containerd"
tests:
test_items:
- flag: "/usr/bin/docker-containerd"
set: true
remediation: "Add a rule for /usr/bin/docker-containerd file.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w /usr/bin/docker-containerd -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 1.13
description: "Ensure auditing is configured for Docker files and directories -
/usr/bin/docker-runc (Scored)"
audit: "auditctl -l | grep /usr/bin/docker-runc"
tests:
test_items:
- flag: "/usr/bin/docker-runc"
set: true
remediation: "Add a rule for /usr/bin/docker-runc file.
For example,
Add the line as below in /etc/audit/audit.rules file:\n
-w /usr/bin/docker-runc -k docker\n
Then, restart the audit daemon. For example,\n
service auditd restart"
scored: true
- id: 2
description: "Docker daemon configuration"
checks:
- id: 2.1
description: "Ensure network traffic is restricted between containers on the
default bridge (Scored)"
audit: "docker network ls --quiet | xargs docker network inspect --format '{{ .Name }}: {{ .Options }}'"
tests:
test_items:
- flag: "com.docker.network.bridge.enable_icc:true"
set: false
remediation: |
Run the docker in daemon mode and pass --icc=false as an argument.
For Example,
dockerd --icc=false
Alternatively, you can follow the Docker documentation and create a custom network and
only join containers that need to communicate to that custom network. The --icc
parameter only applies to the default docker bridge, if custom networks are used then the
approach of segmenting networks should be adopted instead.
scored: true
- id: 2.2.a
description: "Ensure the logging level is set to 'info' (Scored)"
audit: "ps -ef | grep docker"
tests:
bin_op: or
test_items:
- flag: "--log-level"
set: false
- flag: "--log-level"
compare:
op: eq
value: "info"
set: true
remediation: |
Ensure that the Docker daemon configuration file has the following configuration included
"log-level": "info"
Alternatively, run the Docker daemon as below:
dockerd --log-level="info"
scored: true
- id: 2.2.b
description: "Ensure the logging level is set to 'info' (Scored)"
audit: "grep log-level /etc/docker/daemon.json"
tests:
test_items:
- flag: "\"log-level\""
compare:
op: eq
value: "info"
set: true
remediation: |
Ensure that the Docker daemon configuration file has the following configuration included
"log-level": "info"
Alternatively, run the Docker daemon as below:
dockerd --log-level="info"
scored: true
- id: 2.3
description: "Ensure Docker is allowed to make changes to iptables (Scored)"
audit: "ps -ef | grep dockerd"
tests:
bin_op: or
test_items:
- flag: "--iptables"
set: false
- flag: "--iptables"
compare:
op: eq
value: true
set: true
remediation: |
Do not run the Docker daemon with --iptables=false parameter. For example, do not
start the Docker daemon as below:
dockerd --iptables=false
scored: true
- id: 2.4
description: "Ensure insecure registries are not used (Scored)"
audit: "ps -ef | grep dockerd"
tests:
test_items:
- flag: "--insecure-registry"
set: false
remediation: |
Do not use any insecure registries.
For example, do not start the Docker daemon as below:
dockerd --insecure-registry 10.1.0.0/16
scored: true
- id: 2.5
description: "Ensure aufs storage driver is not used (Scored)"
audit: docker info | grep -e "^Storage Driver:\s*aufs\s*$"
tests:
test_items:
- flag: "Storage Driver: aufs"
set: false
remediation: |
Do not explicitly use aufs as storage driver.
For example, do not start Docker daemon as below:
dockerd --storage-driver aufs
scored: true
- id: 2.6.a
description: "Ensure TLS authentication for Docker daemon is configured (Scored)"
audit: "ps -ef | grep dockerd"
tests:
bin_op: and
test_items:
- flag: "--tlsverify"
set: true
- flag: "--tlscacert"
set: true
- flag: "--tlscert"
set: true
- flag: "--tlskey"
set: true
remediation: |
Follow the steps mentioned in the Docker documentation or other references.
scored: true
- id: 2.6.b
description: "Ensure TLS authentication for Docker daemon is configured (Scored)"
audit: 'grep tls /etc/docker/daemon.json | tr -d ","'
tests:
bin_op: and
test_items:
- flag: '"tlsverify"'
compare:
op: eq
value: true
set: true
- flag: '"tlscacert"'
compare:
op: noteq
value: '""'
set: true
- flag: '"tlscert"'
compare:
op: noteq
value: '""'
set: true
- flag: '"tlskey"'
compare:
op: noteq
value: '""'
set: true
remediation: |
Follow the steps mentioned in the Docker documentation or other references.
scored: true
- id: 2.7
description: "Ensure the default ulimit is configured appropriately (Not Scored)"
audit: ps -ef | grep dockerd
type: manual
tests:
test_items:
- flag: "--default-ulimit"
set: true
remediation: |
Run the docker in daemon mode and pass --default-ulimit as argument with respective
ulimits as appropriate in your environment.
For Example,
dockerd --default-ulimit nproc=1024:2048 --default-ulimit nofile=100:200
scored: false
- id: 2.8
description: "Enable user namespace support (Scored)"
audit: docker info --format '{{ .SecurityOptions }}'
tests:
test_items:
- flag: "userns"
compare:
op: has
value: "userns"
set: true
remediation: |
Please consult Docker documentation for various ways in which this can be configured
depending upon your requirements. Your steps might also vary based on platform - For
example, on Red Hat, sub-UIDs and sub-GIDs mapping creation does not work
automatically. You might have to create your own mapping.
However, the high-level steps are as below:
Step 1: Ensure that the files /etc/subuid and /etc/subgid exist.
touch /etc/subuid /etc/subgid
Step 2: Start the docker daemon with --userns-remap flag
dockerd --userns-remap=default
scored: true
- id: 2.9.a
description: "Ensure the default cgroup usage has been confirmed (Scored)"
audit: ps -ef | grep dockerd
tests:
bin_op: or
test_items:
- flag: "--cgroup-parent"
set: false
- flag: "--cgroup-parent"
compare:
op: nothave
value: "/docker"
set: true
remediation: |
The default setting is good enough and can be left as-is. If you want to specifically set a non-
default cgroup, pass --cgroup-parent parameter to the docker daemon when starting it.
For Example,
dockerd --cgroup-parent=/foobar
scored: true
- id: 2.9.b
description: "Ensure the default cgroup usage has been confirmed (Scored)"
audit: "grep cgroup-parent /etc/docker/daemon.json"
tests:
bin_op: or
test_items:
- flag: ""
compare:
op: eq
value: ""
set: false
- flag: '"cgroup-parent"'
compare:
op: nothave
value: "/docker"
set: true
remediation: |
The default setting is good enough and can be left as-is. If you want to specifically set a non-
default cgroup, pass --cgroup-parent parameter to the docker daemon when starting it.
For Example,
dockerd --cgroup-parent=/foobar
scored: true
- id: 2.10.a
description: "Ensure base device size is not changed until needed (Scored)"
audit: ps -ef | grep dockerd
tests:
test_items:
- flag: "--storage-opt"
set: false
remediation: |
Do not set --storage-opt dm.basesize until needed.
scored: true
- id: 2.10.b
description: "Ensure base device size is not changed until needed (Scored)"
audit: "grep storage-opt /etc/docker/daemon.json"
tests:
test_items:
- flag: '"storage-opt"'
compare:
op: eq
value: ""
set: true
remediation: |
Do not set --storage-opt dm.basesize until needed.
scored: true
- id: 2.11.a
description: "Ensure that authorization for Docker client commands is enabled (Scored)"
audit: ps -ef | grep dockerd
tests:
test_items:
- flag: "--authorization-plugin"
set: true
remediation: |
Step 1: Install/Create an authorization plugin.
Step 2: Configure the authorization policy as desired.
Step 3: Start the docker daemon as below:
dockerd --authorization-plugin=<PLUGIN_ID>
scored: true
- id: 2.11.b
description: "Ensure that authorization for Docker client commands is enabled (Scored)"
audit: 'grep authorization-plugin /etc/docker/daemon.json | tr -d ","'
tests:
test_items:
- flag: '"authorization-plugins"'
compare:
op: noteq
value: "[]"
set: true
remediation: |
Step 1: Install/Create an authorization plugin.
Step 2: Configure the authorization policy as desired.
Step 3: Start the docker daemon as below:
dockerd --authorization-plugin=<PLUGIN_ID>
scored: true
- id: 2.12
description: "Ensure centralized and remote logging is configured (Scored)"
audit: ps -ef | grep dockerd
type: manual
tests:
test_items:
- flag: "--log-driver"
set: true
remediation: |
Step 1: Setup the desired log driver by following its documentation.
Step 2: Start the docker daemon with that logging driver.
For example,
dockerd --log-driver=syslog --log-opt syslog-address=tcp://192.xxx.xxx.xxx
scored: true
- id: 2.13
description: "Ensure operations on legacy registry (v1) are Disabled (Scored)"
audit: ps -ef | grep dockerd
tests:
test_items:
- flag: "--disable-legacy-registry"
set: true
remediation: |
Start the docker daemon as below:
dockerd --disable-legacy-registry
scored: true
- id: 2.14.a
description: "Ensure live restore is Enabled (Scored)"
audit: ps -ef | grep dockerd
tests:
test_items:
- flag: "--live-restore"
set: true
remediation: |
Run the docker in daemon mode and pass --live-restore as an argument.
For Example,
dockerd --live-restore
scored: true
- id: 2.14.b
description: "Ensure live restore is Enabled (Scored)"
audit: 'grep live-restore /etc/docker/daemon.json | tr -d ","'
tests:
test_items:
- flag: '"live-restore"'
compare:
op: eq
value: "true"
set: true
remediation: |
Run the docker in daemon mode and pass --live-restore as an argument.
For Example,
dockerd --live-restore
scored: true
- id: 2.15.a
description: "Ensure Userland Proxy is Disabled (Scored)"
audit: "ps -ef | grep dockerd"
tests:
test_items:
- flag: "--userland-proxy"
compare:
op: eq
value: "false"
set: true
remediation: |
Run the Docker daemon as below:
dockerd --userland-proxy=false
scored: true
- id: 2.15.b
description: "Disable Userland Proxy (Scored)"
audit: 'grep userland-proxy /etc/docker/daemon.json | tr -d ","'
tests:
test_items:
- flag: '"userland-proxy"'
compare:
op: eq
value: "false"
set: true
remediation: |
Run the Docker daemon as below:
dockerd --userland-proxy=false
scored: true
- id: 2.16
description: "Ensure daemon-wide custom seccomp profile is applied, if needed
(Not Scored)"
audit: docker info --format '{{ .SecurityOptions }}'
tests:
test_items:
- flag: "profile"
compare:
op: nothave
value: "default"
set: true
remediation: |
By default, Docker's default seccomp profile is applied. If this is good for your environment,
no action is necessary. Alternatively, if you choose to apply your own seccomp profile, use
the --seccomp-profile flag at daemon start or put it in the daemon runtime parameters
file.
dockerd --seccomp-profile </path/to/seccomp/profile>
scored: false
- id: 2.17
description: "Ensure experimental features are avoided in production (Scored)"
audit: docker version --format '{{ .Server.Experimental }}'
tests:
test_items:
- flag: "false"
compare:
op: eq
value: "false"
set: true
remediation: |
Do not pass --experimental as a runtime parameter to the docker daemon.
scored: true
- id: 2.18.a
description: "Ensure containers are restricted from acquiring new privileges (Scored)"
audit: ps -ef | grep dockerd
tests:
test_items:
- flag: "--no-new-privileges"
compare:
op: eq
value: "true"
set: true
remediation: |
Run the Docker daemon as below:
dockerd --no-new-privileges
scored: true
- id: 2.18.b
description: "Ensure containers are restricted from acquiring new privileges (Scored)"
audit: 'grep no-new-privileges /etc/docker/daemon.json | tr -d ","'
tests:
test_items:
- flag: '"no-new-privileges"'
compare:
op: eq
value: "true"
set: true
remediation: |
For example, you should start your container as below:
docker run --rm -it --security-opt=no-new-privileges ubuntu bash
scored: true
- id: 3
description: "Docker daemon configuration files"
checks:
- id: 3.1
description: "Ensure that docker.service file ownership is set to root:root (Scored)"
audit: systemctl show -p FragmentPath docker.service | cut -d= -f2 | xargs stat -c %U:%G
tests:
test_items:
- flag: "root:root"
compare:
op: eq
value: "root:root"
set: true
remediation: |
Step 1: Find out the file location:
systemctl show -p FragmentPath docker.service
Step 2: If the file does not exist, this recommendation is not applicable. If the file exists,
execute the below command with the correct file path to set the ownership and group
ownership for the file to root .
For example,
chown root:root /usr/lib/systemd/system/docker.service
scored: true
- id: 3.2
description: "Ensure that docker.service file permissions are set to 644 or more
restrictive (Scored)"
audit: systemctl show -p FragmentPath docker.service | cut -d= -f2 | xargs stat -c "permissions=%a"
tests:
test_items:
- flag: "permissions"
compare:
op: bitmask
value: "644"
set: true
remediation: |
Step 1: Find out the file location:
systemctl show -p FragmentPath docker.service
Step 2: If the file does not exist, this recommendation is not applicable. If the file exists,
execute the below command with the correct file path to set the file permissions to 644 .
For example,
chmod 644 /usr/lib/systemd/system/docker.service
scored: true
- id: 3.3
description: "Ensure that docker.socket file ownership is set to root:root (Scored)"
audit: systemctl show -p FragmentPath docker.socket | cut -d= -f2 | xargs stat -c %U:%G
tests:
test_items:
- flag: "root:root"
compare:
op: eq
value: "root:root"
set: true
remediation: |
Step 1: Find out the file location:
systemctl show -p FragmentPath docker.socket
Step 2: If the file does not exist, this recommendation is not applicable. If the file exists,
execute the below command with the correct file path to set the ownership and group
ownership for the file to root .
For example,
chown root:root /usr/lib/systemd/system/docker.socket
scored: true
- id: 3.4
description: "Ensure that docker.socket file permissions are set to 644 or more
restrictive (Scored)"
audit: systemctl show -p FragmentPath docker.socket | cut -d= -f2 | xargs stat -c "permissions=%a"
tests:
test_items:
- flag: "permissions"
compare:
op: bitmask
value: "644"
set: true
remediation: |
Step 1: Find out the file location:
systemctl show -p FragmentPath docker.socket
Step 2: If the file does not exist, this recommendation is not applicable. If the file exists,
execute the below command with the correct file path to set the file permissions to 644 .
For example,
chmod 644 /usr/lib/systemd/system/docker.socket
scored: true
- id: 3.5
description: "Ensure that /etc/docker directory ownership is set to root:root
(Scored)"
audit: stat -c %U:%G /etc/docker
tests:
test_items:
- flag: "root:root"
compare:
op: eq
value: "root:root"
set: true
remediation: |
chown root:root /etc/docker
This would set the ownership and group-ownership for the directory to root .
scored: true
- id: 3.6
description: "Ensure that /etc/docker directory permissions are set to 755 or more
restrictive (Scored)"
audit: stat -c "permissions=%a" /etc/docker
tests:
test_items:
- flag: "permissions"
compare:
op: bitmask
value: "755"
set: true
remediation: |
chmod 755 /etc/docker
This would set the permissions for the directory to 755 .
scored: true
- id: 3.7
description: "Ensure that registry certificate file ownership is set to root:root
(Scored)"
audit: stat -c %U:%G /etc/docker/certs.d/*
tests:
test_items:
- flag: "root:root"
set: true
remediation: |
chown root:root /etc/docker/certs.d/<registry-name>/*
This would set the ownership and group-ownership for the registry certificate files to root .
scored: true
- id: 3.8
description: "Ensure that registry certificate file permissions are set to 444 or
more restrictive (Scored)"
audit: stat -c "permissions=%a" /etc/docker/certs.d/*
tests:
test_items:
- flag: "permissions"
compare:
op: bitmask
value: "444"
set: true
remediation: |
chmod 444 /etc/docker/certs.d/<registry-name>/*
This would set the permissions for registry certificate files to 444 .
scored: true
- id: 3.9
description: "Ensure that TLS CA certificate file ownership is set to root:root
(Scored)"
type: manual
remediation: |
chown root:root <path to TLS CA certificate file>
This would set the ownership and group-ownership for the TLS CA certificate file to root .
scored: true
- id: 3.10
description: "Ensure that TLS CA certificate file permissions are set to 444 or
more restrictive (Scored)"
type: manual
remediation: |
chmod 444 <path to TLS CA certificate file>
This would set the file permissions of the TLS CA file to 444 .
scored: true
- id: 3.11
description: "Ensure that Docker server certificate file ownership is set to
root:root (Scored)"
type: manual
remediation: |
chown root:root <path to Docker server certificate file>
This would set the ownership and group-ownership for the Docker server certificate file to
root .
scored: true
- id: 3.12
description: "Ensure that Docker server certificate file permissions are set to 444
or more restrictive (Scored)"
type: manual
remediation: |
chmod 444 <path to Docker server certificate file>
This would set the file permissions of the Docker server file to 444 .
scored: true
- id: 3.13
description: "Ensure that Docker server certificate key file ownership is set to
root:root (Scored)"
type: manual
remediation: |
chown root:root <path to Docker server certificate key file>
This would set the ownership and group-ownership for the Docker server certificate key
file to root.
scored: true
- id: 3.14
description: "Ensure that Docker server certificate key file permissions are set to
400 (Scored)"
type: manual
remediation: |
chmod 400 <path to Docker server certificate key file>
This would set the Docker server certificate key file permissions to 400 .
scored: true
- id: 3.15
description: "Ensure that Docker socket file ownership is set to root:docker
(Scored)"
audit: stat -c %U:%G /var/run/docker.sock
tests:
test_items:
- flag: "root:docker"
compare:
op: eq
value: "root:docker"
set: true
remediation: |
chown root:docker /var/run/docker.sock
This would set the ownership to root and group-ownership to docker for default Docker
socket file.
scored: true
- id: 3.16
description: "Ensure that Docker socket file permissions are set to 660 or more
restrictive (Scored)"
audit: stat -c "permissions=%a" /var/run/docker.sock
tests:
test_items:
- flag: "permissions"
compare:
op: bitmask
value: "660"
set: true
remediation: |
chmod 660 /var/run/docker.sock
This would set the file permissions of the Docker socket file to 660 .
scored: true
- id: 3.17
description: "Ensure that daemon.json file ownership is set to root:root (Scored)"
audit: /bin/sh -c "if [ -f /etc/docker/daemon.json ]; then stat -c %U:%G /etc/docker/daemon.json; fi"
tests:
test_items:
- flag: "root:root"
compare:
op: eq
value: "root:root"
set: true
remediation: |
chown root:root /etc/docker/daemon.json
This would set the ownership and group-ownership for the file to root .
scored: true
- id: 3.18
description: "Ensure that daemon.json file permissions are set to 644 or more
restrictive (Scored)"
audit: /bin/sh -c "if [ -f /etc/docker/daemon.json ]; then stat -c "permissions=%a" /etc/docker/daemon.json; fi"
tests:
test_items:
- flag: "permissions"
compare:
op: bitmask
value: "644"
set: true
remediation: |
chown root:root /etc/default/docker
This would set the ownership and group-ownership for the file to root .
scored: true
- id: 3.19
description: "Ensure that /etc/default/docker file ownership is set to root:root
(Scored)"
audit: /bin/sh -c "if [ -f /etc/default/docker ]; then stat -c %U:%G /etc/default/docker; fi"
tests:
test_items:
- flag: "root:root"
compare:
op: eq
value: "root:root"
set: true
remediation: |
chown root:root /etc/default/docker
This would set the ownership and group-ownership for the file to root .
scored: true
- id: 3.20
description: "Ensure that /etc/default/docker file permissions are set to 644 or
more restrictive (Scored)"
audit: /bin/sh -c "if [ -f /etc/default/docker ]; then stat -c "permissions=%a" /etc/default/docker; fi"
tests:
test_items:
- flag: "permissions"
compare:
op: bitmask
value: "644"
set: true
remediation: |
chmod 644 /etc/default/docker
This would set the file permissions for this file to 644.
scored: true
- id: 4
description: "Container Images and Build File"
checks:
- id: 4.1
description: "Ensure a user for the container has been created (Scored)"
audit: "docker ps --quiet --all | xargs docker inspect --format '{{ .Id }}: User={{ .Config.User }}'"
use_multiple_values: true
tests:
bin_op: and
test_items:
- flag: "User"
compare:
op: nothave
value: "root"
set: true
- flag: "User"
compare:
op: noteq
value: ""
set: true
- flag: "User"
compare:
op: noteq
value: "1"
set: true
remediation: |
Ensure that the Dockerfile for the container image contains below instruction:
USER <username or ID>
where username or ID refers to the user that could be found in the container base image. If
there is no specific user created in the container base image, then add a useradd command
to add the specific user before USER instruction.
For example, add the below lines in the Dockerfile to create a user in the container:
RUN useradd -d /home/username -m -s /bin/bash username
USER username
Note: If there are users in the image that the containers do not need, consider deleting
them. After deleting those users, commit the image and then generate new instances of
containers for use.
scored: true
- id: 4.2
description: "Ensure that containers use trusted base images (Not Scored)"
type: manual
remediation: |
- Configure and use Docker Content trust.
- Inspect Docker image history to evaluate their risk to operate on your network.
- Scan Docker images for vulnerabilities in their dependencies and configurations
they will impose upon your network.
scored: false
- id: 4.3
description: "Ensure unnecessary packages are not installed in the container (Not Scored)"
type: manual
remediation: |
At the outset, do not install anything on the container that does not justify the purpose. If
the image had some packages that your container does not use, uninstall them.
Consider using a minimal base image rather than the standard Redhat/Centos/Debian
images if you can. Some of the options include BusyBox and Alpine.
Not only does this trim your image size from >150Mb to ~20 Mb, there are also fewer tools
and paths to escalate privileges. You can even remove the package installer as a final
hardening measure for leaf/production containers.
scored: false
- id: 4.4
description: "Ensure images are scanned and rebuilt to include security patches
(Not Scored)"
type: manual
remediation: |
Follow the below steps to rebuild the images with security patches:
Step 1: Pull all the base images (i.e., given your set of Dockerfiles, extract all images
declared in FROM instructions, and re-pull them to check for an updated/patched versions).
Patch the packages within the images too.
docker pull
Step 2: Force a rebuild of each image:
docker build --no-cache
Step 3: Restart all containers with the updated images.
You could also use ONBUILD directive in the Dockerfile to trigger particular update
instructions for images that you know are used as base images frequently.
scored: false