---
title: Empty password authentication allowed
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Infrastructure as Code (IaC)
  Security > IaC Security Rules > Empty password authentication allowed
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Empty password authentication allowed

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**Id:** `dockercompose-empty-password-allowed` 

**Platform:** DockerCompose

**Severity:** High

**Category:** Access Control

#### Learn More{% #learn-more %}

- [Provider Reference](https://hub.docker.com/_/mysql)

### Description{% #description %}

Enabling empty-password authentication lets clients access a service without a password, exposing application data and administrative functions to unauthorized users. Remove the setting that allows empty passwords and configure a non-empty password through Docker secrets or an environment reference. When no root password is supplied or generated, MySQL and MariaDB permit passwordless initialization for any non-empty value of their allow-empty-password settings, including `"false"`, `"no"`, and `"0"`.

## Compliant Code Examples{% #compliant-code-examples %}

```yaml
services:
  no_switch:
    image: mysql:8
  generic_disabled:
    image: bitnami/mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: "no"
  generic_false:
    image: bitnami/mysql:8
    environment:
      - ALLOW_EMPTY_PASSWORD=false
  generic_zero:
    image: bitnami/mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: 0
  empty:
    image: mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: ""
      MYSQL_ALLOW_EMPTY_PASSWORD: ""
      MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: ""
  list_empty:
    image: mariadb:11
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=
      - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=
      - ALLOW_EMPTY_PASSWORD
  unknown_value:
    image: mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD}
      MYSQL_ALLOW_EMPTY_PASSWORD: ${MYSQL_ALLOW_EMPTY_PASSWORD?required}
  random_password:
    image: mariadb:11
    environment:
      - MARIADB_RANDOM_ROOT_PASSWORD=1
  credential:
    image: mysql:8
    environment:
      MYSQL_ROOT_PASSWORD: secret123
  unrelated_key:
    image: example/app:1
    environment:
      DISALLOW_EMPTY_PASSWORD: "yes"
      ALLOW_EMPTY_PASSWORD_FILE: /run/secrets/password
```

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```yaml
services:
  generic_yes:
    image: bitnami/mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: "yes"
  generic_list_true:
    image: bitnami/mysql:8
    environment:
      - ALLOW_EMPTY_PASSWORD=true
  generic_bool:
    image: bitnami/mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: true
  generic_numeric:
    image: bitnami/mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: 1
  mysql_yes:
    image: mysql:8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
  mysql_false_is_nonempty:
    image: mysql:8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: "false"
  mysql_list_zero_is_nonempty:
    image: mysql:8
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=0
  mariadb_yes:
    image: mariadb:11
    environment:
      MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: "yes"
  mariadb_list_compat:
    image: mariadb:11
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=1
  mariadb_no_is_nonempty:
    image: mariadb:11
    environment:
      MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: "no"
  uppercase_key:
    image: bitnami/mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: "YES"
  literal_default:
    image: bitnami/mysql:8
    environment:
      ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
  enabled_alternate:
    image: bitnami/mysql:8
    environment:
      - ALLOW_EMPTY_PASSWORD=${EMPTY_PASSWORD:+yes}
  mysql_nonempty_alternate:
    image: mysql:8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: ${EMPTY_PASSWORD:+no}
  mysql_literal_dollar:
    image: mysql:8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: "$$"
  mysql_literal_prefix:
    image: mysql:8
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=prefix${UNKNOWN}
```
