docker-bench-security icon indicating copy to clipboard operation
docker-bench-security copied to clipboard

Problem with check 2.6

Open nbrownuk opened this issue 8 years ago • 3 comments

Running check 2.6, with TLS enabled, can give a warning that TLS is not enabled. It comes about when the TCP socket is defined in a Systemd override, but the TLS flags are defined in the daemon's config file. I think the check assumes everything is defined in either the unit file (or override), or the config file. Often, however, host definitions appear in the Systemd config, whilst the TLS config is placed in the daemon config file. It's perfectly legitimate to split configuration this way, so I guess the check should cater for it?

I haven't tested it thoroughly, but by re-using the majority of the function for check 2.6, the following seems to work:

# 2.6
check_2_6() {
  check_2_6="2.6  - Ensure TLS authentication for Docker daemon is configured"
  totalChecks=$((totalChecks + 1))

  if [ grep -i 'tcp://' "$CONFIG_FILE" 2>/dev/null 1>&2 ] || \
    [ $(get_docker_cumulative_command_line_args '-H' | grep -vE '(unix|fd)://') >/dev/null 2>&1 ]; then
    if [ $(get_docker_configuration_file_args '"tlsverify":' | grep 'true') ] || \
        [ $(get_docker_cumulative_command_line_args '--tlsverify' | grep 'tlsverify') >/dev/null 2>&1 ]; then
      pass "$check_2_6"
      logjson "2.6" "PASS"
      currentScore=$((currentScore + 1))
    elif [ $(get_docker_configuration_file_args '"tls":' | grep 'true') ] || \
      [ $(get_docker_cumulative_command_line_args '--tls' | grep 'tls') >/dev/null 2>&1 ]; then
      warn "$check_2_6"
      warn "     * Docker daemon currently listening on TCP with TLS, but no verification"
      logjson "2.6" "WARN"
      currentScore=$((currentScore - 1))
    else
      warn "$check_2_6"
      warn "     * Docker daemon currently listening on TCP without TLS"
      logjson "2.6" "WARN"
      currentScore=$((currentScore - 1))
    fi
  else
    info "$check_2_6"
    info "     * Docker daemon not listening on TCP"
    logjson "2.6" "INFO"
    currentScore=$((currentScore + 0))
  fi
}

nbrownuk avatar Apr 29 '18 18:04 nbrownuk

Hi @nbrownuk and thanks for reporting this. I'll have a look at the proposed changes and run some test as soon as possible.

konstruktoid avatar Apr 30 '18 10:04 konstruktoid

Hi @konstruktoid is there anything I can do to help move this issue along? Just let me know if I can help.

nbrownuk avatar May 29 '18 14:05 nbrownuk

Hi again @nbrownuk and I'm so sorry for the way too long delay. Things stacked up and I completely forgot about this one.

konstruktoid avatar May 30 '18 07:05 konstruktoid