2015-05-11 06:08:28 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
logit "\n"
|
|
|
|
info "2 - Docker Daemon Configuration"
|
|
|
|
|
|
|
|
# 2.1
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_1="2.1 - Restrict network traffic between containers"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_effective_command_line_args '--icc' | grep false >/dev/null 2>&1; then
|
|
|
|
pass "$check_2_1"
|
|
|
|
elif get_docker_configuration_file_args 'icc' | grep "false" >/dev/null 2>&1; then
|
2015-05-11 06:08:28 +02:00
|
|
|
pass "$check_2_1"
|
2016-04-14 22:25:11 +02:00
|
|
|
else
|
|
|
|
warn "$check_2_1"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.2
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_2="2.2 - Set the logging level"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'log-level' >/dev/null 2>&1; then
|
|
|
|
if get_docker_configuration_file_args 'log-level' | grep info >/dev/null 2>&1; then
|
|
|
|
pass "$check_2_2"
|
|
|
|
elif [ -z "$(get_docker_configuration_file_args 'log-level')" ]; then
|
|
|
|
pass "$check_2_2"
|
|
|
|
else
|
|
|
|
warn "$check_2_2"
|
|
|
|
fi
|
|
|
|
elif get_docker_effective_command_line_args '-l'; then
|
2017-02-17 15:03:29 +01:00
|
|
|
if get_docker_effective_command_line_args '-l' | grep "info" >/dev/null 2>&1; then
|
2016-09-28 23:20:51 +02:00
|
|
|
pass "$check_2_2"
|
|
|
|
else
|
|
|
|
warn "$check_2_2"
|
|
|
|
fi
|
2016-04-14 22:25:11 +02:00
|
|
|
else
|
|
|
|
pass "$check_2_2"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.3
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_3="2.3 - Allow Docker to make changes to iptables"
|
2017-02-17 15:03:29 +01:00
|
|
|
if get_docker_effective_command_line_args '--iptables' | grep "false" >/dev/null 2>&1; then
|
2015-05-11 06:08:28 +02:00
|
|
|
warn "$check_2_3"
|
2017-02-20 11:21:18 +01:00
|
|
|
elif get_docker_configuration_file_args 'iptables' | grep "false" >/dev/null 2>&1; then
|
|
|
|
warn "$check_2_3"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
|
|
|
pass "$check_2_3"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.4
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_4="2.4 - Do not use insecure registries"
|
2017-02-17 15:03:29 +01:00
|
|
|
if get_docker_effective_command_line_args '--insecure-registry' | grep "insecure-registry" >/dev/null 2>&1; then
|
2015-05-11 06:08:28 +02:00
|
|
|
warn "$check_2_4"
|
2017-02-20 11:21:18 +01:00
|
|
|
elif ! [ -z "$(get_docker_configuration_file_args 'insecure-registries')" ]; then
|
|
|
|
if get_docker_configuration_file_args 'insecure-registries' | grep '\[]' >/dev/null 2>&1; then
|
|
|
|
pass "$check_2_4"
|
|
|
|
else
|
|
|
|
warn "$check_2_4"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
|
|
|
pass "$check_2_4"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.5
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_5="2.5 - Do not use the aufs storage driver"
|
2017-02-17 15:03:29 +01:00
|
|
|
if docker info 2>/dev/null | grep -e "^Storage Driver:\s*aufs\s*$" >/dev/null 2>&1; then
|
2015-05-11 06:08:28 +02:00
|
|
|
warn "$check_2_5"
|
|
|
|
else
|
|
|
|
pass "$check_2_5"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.6
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_6="2.6 - Configure TLS authentication for Docker daemon"
|
2017-03-21 14:49:42 +01:00
|
|
|
if grep -i 'tcp://' "$CONFIG_FILE" 2>/dev/null 1>&2; then
|
2017-03-21 16:17:08 +01:00
|
|
|
if [ $(get_docker_configuration_file_args '"tls":' | grep 'true') ] || \
|
|
|
|
[ $(get_docker_configuration_file_args '"tlsverify' | grep 'true') ] ; then
|
2017-03-21 14:49:42 +01:00
|
|
|
if get_docker_configuration_file_args 'tlskey' | grep -v '""' >/dev/null 2>&1; then
|
|
|
|
if get_docker_configuration_file_args 'tlsverify' | grep 'true' >/dev/null 2>&1; then
|
|
|
|
pass "$check_2_6"
|
|
|
|
else
|
|
|
|
warn "$check_2_6"
|
|
|
|
warn " * Docker daemon currently listening on TCP with TLS, but no verification"
|
|
|
|
fi
|
2017-02-20 11:21:18 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
warn "$check_2_6"
|
|
|
|
warn " * Docker daemon currently listening on TCP without TLS"
|
|
|
|
fi
|
|
|
|
elif get_docker_cumulative_command_line_args '-H' | grep -vE '(unix|fd)://' >/dev/null 2>&1; then
|
2017-02-17 15:03:29 +01:00
|
|
|
if get_docker_cumulative_command_line_args '--tlskey' | grep 'tlskey=' >/dev/null 2>&1; then
|
|
|
|
if get_docker_cumulative_command_line_args '--tlsverify' | grep 'tlsverify' >/dev/null 2>&1; then
|
2016-09-25 02:42:39 +02:00
|
|
|
pass "$check_2_6"
|
|
|
|
else
|
|
|
|
warn "$check_2_6"
|
|
|
|
warn " * Docker daemon currently listening on TCP with TLS, but no verification"
|
|
|
|
fi
|
2016-04-14 22:25:11 +02:00
|
|
|
else
|
|
|
|
warn "$check_2_6"
|
2016-09-25 02:42:39 +02:00
|
|
|
warn " * Docker daemon currently listening on TCP without TLS"
|
2016-04-14 22:25:11 +02:00
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
|
|
|
info "$check_2_6"
|
2016-04-14 22:25:11 +02:00
|
|
|
info " * Docker daemon not listening on TCP"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2016-09-25 02:42:39 +02:00
|
|
|
|
2015-05-11 06:08:28 +02:00
|
|
|
# 2.7
|
2017-01-23 17:06:10 +01:00
|
|
|
check_2_7="2.7 - Set default ulimit as appropriate"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'default-ulimit' | grep -v '{}' >/dev/null 2>&1; then
|
|
|
|
pass "$check_2_7"
|
|
|
|
elif get_docker_effective_command_line_args '--default-ulimit' | grep "default-ulimit" >/dev/null 2>&1; then
|
2015-05-11 06:08:28 +02:00
|
|
|
pass "$check_2_7"
|
2016-04-14 22:25:11 +02:00
|
|
|
else
|
|
|
|
info "$check_2_7"
|
|
|
|
info " * Default ulimit doesn't appear to be set"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.8
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_8="2.8 - Enable user namespace support"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'userns-remap' | grep -v '""'; then
|
|
|
|
pass "$check_2_8"
|
|
|
|
elif get_docker_effective_command_line_args '--userns-remap' | grep "userns-remap" >/dev/null 2>&1; then
|
2015-05-11 06:08:28 +02:00
|
|
|
pass "$check_2_8"
|
2016-04-14 22:25:11 +02:00
|
|
|
else
|
|
|
|
warn "$check_2_8"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.9
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_9="2.9 - Confirm default cgroup usage"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'cgroup-parent' | grep -v '""'; then
|
|
|
|
warn "$check_2_9"
|
|
|
|
info " * Confirm cgroup usage"
|
|
|
|
elif get_docker_effective_command_line_args '--cgroup-parent' | grep "cgroup-parent" >/dev/null 2>&1; then
|
2017-01-24 13:41:30 +01:00
|
|
|
warn "$check_2_9"
|
2016-04-14 22:25:11 +02:00
|
|
|
info " * Confirm cgroup usage"
|
|
|
|
else
|
|
|
|
pass "$check_2_9"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.10
|
2016-04-14 22:25:11 +02:00
|
|
|
check_2_10="2.10 - Do not change base device size until needed"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'storage-opts' | grep "dm.basesize" >/dev/null 2>&1; then
|
|
|
|
warn "$check_2_10"
|
|
|
|
elif get_docker_effective_command_line_args '--storage-opt' | grep "dm.basesize" >/dev/null 2>&1; then
|
2016-04-14 22:25:11 +02:00
|
|
|
warn "$check_2_10"
|
|
|
|
else
|
2015-05-11 06:08:28 +02:00
|
|
|
pass "$check_2_10"
|
2016-04-14 22:25:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.11
|
|
|
|
check_2_11="2.11 - Use authorization plugin"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]'; then
|
|
|
|
pass "$check_2_11"
|
|
|
|
elif get_docker_effective_command_line_args '--authorization-plugin' | grep "authorization-plugin" >/dev/null 2>&1; then
|
2016-04-14 22:25:11 +02:00
|
|
|
pass "$check_2_11"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2016-04-14 22:25:11 +02:00
|
|
|
warn "$check_2_11"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
2015-06-22 21:36:56 +02:00
|
|
|
|
2016-04-14 22:25:11 +02:00
|
|
|
# 2.12
|
|
|
|
check_2_12="2.12 - Configure centralized and remote logging"
|
2017-02-20 11:21:18 +01:00
|
|
|
if docker info --format '{{ .LoggingDriver }}' | grep 'json-file' >/dev/null 2>&1; then
|
2016-04-14 22:25:11 +02:00
|
|
|
warn "$check_2_12"
|
2017-02-20 11:21:18 +01:00
|
|
|
else
|
|
|
|
pass "$check_2_12"
|
2016-04-14 22:25:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.13
|
|
|
|
check_2_13="2.13 - Disable operations on legacy registry (v1)"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'disable-legacy-registry' | grep 'true' >/dev/null 2>&1; then
|
|
|
|
pass "$check_2_13"
|
|
|
|
elif get_docker_effective_command_line_args '--disable-legacy-registry' | grep "disable-legacy-registry" >/dev/null 2>&1; then
|
2016-04-14 22:25:11 +02:00
|
|
|
pass "$check_2_13"
|
|
|
|
else
|
|
|
|
warn "$check_2_13"
|
|
|
|
fi
|
2016-12-20 16:01:58 +01:00
|
|
|
|
|
|
|
# 2.14
|
|
|
|
check_2_14="2.14 - Enable live restore"
|
2017-01-24 13:41:30 +01:00
|
|
|
if docker info 2>/dev/null | grep -e "Live Restore Enabled:\s*true\s*" >/dev/null 2>&1; then
|
2016-12-20 16:01:58 +01:00
|
|
|
pass "$check_2_14"
|
|
|
|
else
|
2017-02-22 10:11:44 +01:00
|
|
|
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
|
2017-01-23 13:13:48 +01:00
|
|
|
pass "$check_2_14 (Incompatible with swarm mode)"
|
|
|
|
else
|
|
|
|
warn "$check_2_14"
|
|
|
|
fi
|
2016-12-20 16:01:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.15
|
|
|
|
check_2_15="2.15 - Do not enable swarm mode, if not needed"
|
2017-02-22 10:11:44 +01:00
|
|
|
if docker info 2>/dev/null | grep -e "Swarm:*\sinactive\s*" >/dev/null 2>&1; then
|
2016-12-20 16:01:58 +01:00
|
|
|
pass "$check_2_15"
|
|
|
|
else
|
|
|
|
warn "$check_2_15"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.16
|
|
|
|
check_2_16="2.16 - Control the number of manager nodes in a swarm"
|
2017-02-22 10:11:44 +01:00
|
|
|
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
|
2017-01-24 13:41:30 +01:00
|
|
|
managernodes=$(docker node ls | grep -c "Leader")
|
|
|
|
if [ "$managernodes" -le 1 ]; then
|
2017-01-23 13:13:48 +01:00
|
|
|
pass "$check_2_16"
|
|
|
|
else
|
|
|
|
warn "$check_2_16"
|
|
|
|
fi
|
2016-12-20 16:01:58 +01:00
|
|
|
else
|
2017-01-23 13:13:48 +01:00
|
|
|
pass "$check_2_16 (Swarm mode not enabled)"
|
2016-12-20 16:01:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.17
|
|
|
|
check_2_17="2.17 - Bind swarm services to a specific host interface"
|
2017-02-22 10:11:44 +01:00
|
|
|
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
|
2017-02-24 13:19:03 +01:00
|
|
|
netstat -lnt | grep -e '\[::]:2377 ' -e ':::2377' -e '*:2377 ' -e ' 0\.0\.0\.0:2377 ' >/dev/null 2>&1
|
2017-02-22 10:11:44 +01:00
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
pass "$check_2_17"
|
|
|
|
else
|
|
|
|
warn "$check_2_17"
|
|
|
|
fi
|
2016-12-20 16:01:58 +01:00
|
|
|
else
|
2017-02-22 10:11:44 +01:00
|
|
|
pass "$check_2_17 (Swarm mode not enabled)"
|
2016-12-20 16:01:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.18
|
|
|
|
check_2_18="2.18 - Disable Userland Proxy"
|
2017-02-20 11:21:18 +01:00
|
|
|
if get_docker_configuration_file_args 'userland-proxy' | grep false >/dev/null 2>&1; then
|
|
|
|
pass "$check_2_18"
|
|
|
|
elif get_docker_effective_command_line_args '--userland-proxy=false' 2>/dev/null | grep "userland-proxy=false" >/dev/null 2>&1; then
|
2016-12-20 16:01:58 +01:00
|
|
|
pass "$check_2_18"
|
|
|
|
else
|
|
|
|
warn "$check_2_18"
|
|
|
|
fi
|
2017-01-24 13:41:30 +01:00
|
|
|
|
|
|
|
# 2.19
|
|
|
|
check_2_19="2.19 - Encrypt data exchanged between containers on different nodes on the overlay network"
|
|
|
|
if docker network ls --filter driver=overlay --quiet | \
|
|
|
|
xargs docker network inspect --format '{{.Name}} {{ .Options }}' 2>/dev/null | \
|
|
|
|
grep -v 'encrypted:' 2>/dev/null 1>&2; then
|
|
|
|
warn "$check_2_19"
|
|
|
|
for encnet in $(docker network ls --filter driver=overlay --quiet); do
|
|
|
|
if docker network inspect --format '{{.Name}} {{ .Options }}' "$encnet" | \
|
|
|
|
grep -v 'encrypted:' 2>/dev/null 1>&2; then
|
|
|
|
warn " * Unencrypted overlay network: $(docker network inspect --format '{{ .Name }} ({{ .Scope }})' "$encnet")"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
pass "$check_2_19"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.20
|
|
|
|
check_2_20="2.20 - Apply a daemon-wide custom seccomp profile, if needed"
|
|
|
|
if docker info --format '{{ .SecurityOptions }}' | grep 'name=seccomp,profile=default' 2>/dev/null 1>&2; then
|
|
|
|
pass "$check_2_20"
|
|
|
|
else
|
|
|
|
info "$check_2_20"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.21
|
|
|
|
check_2_21="2.21 - Avoid experimental features in production"
|
2017-02-23 17:07:33 +01:00
|
|
|
if docker info 2>/dev/null | grep -e "Experimental:\s*false*" 2>/dev/null 1>&2; then
|
2017-01-24 13:41:30 +01:00
|
|
|
pass "$check_2_21"
|
|
|
|
else
|
|
|
|
warn "$check_2_21"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.22
|
|
|
|
check_2_22="2.22 - Use Docker's secret management commands for managing secrets in a Swarm cluster"
|
|
|
|
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
|
|
|
|
if [ "$(docker secret ls -q | wc -l)" -ge 1 ]; then
|
|
|
|
pass "$check_2_22"
|
|
|
|
else
|
|
|
|
info "$check_2_22"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
pass "$check_2_22 (Swarm mode not enabled)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.23
|
|
|
|
check_2_23="2.23 - Run swarm manager in auto-lock mode"
|
|
|
|
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
|
|
|
|
if ! docker swarm unlock-key 2>/dev/null | grep 'SWMKEY' 2>/dev/null 1>&2; then
|
|
|
|
warn "$check_2_23"
|
|
|
|
else
|
|
|
|
pass "$check_2_23"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
pass "$check_2_23 (Swarm mode not enabled)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 2.24
|
|
|
|
check_2_24="2.24 - Rotate swarm manager auto-lock key periodically"
|
2017-03-23 11:29:58 +01:00
|
|
|
note "$check_2_24"
|