{
  "id": "CB-UBU-SVC-020",
  "standard": "ubuntu",
  "version": "main",
  "url": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-SVC-020",
  "json": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-SVC-020.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-SVC-020.yml",
  "profiles_effective": [
    "core",
    "server",
    "server-hardened",
    "desktop",
    "desktop-hardened"
  ],
  "license": "Text CC BY 4.0, code Apache-2.0",
  "attribution": "CIRSEC Baselines, https://baselines.cirsec.org",
  "control": {
    "id": "CB-UBU-SVC-020",
    "title": "Encrypt SSSD LDAP connections and verify the server certificate",
    "finding": {
      "title": "SSSD talks to the LDAP directory without TLS or without checking the server certificate",
      "description": "Directory traffic, including password binds, can be read or the directory server impersonated."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "high"
    },
    "assessment": "automated",
    "tags": [
      "sssd",
      "ldap",
      "tls",
      "authentication"
    ],
    "applicability": {
      "facts": [
        "sssd-ldap"
      ]
    },
    "description": "When SSSD uses an LDAP directory (`id_provider`, `auth_provider` or `chpass_provider` set to\n`ldap` in `/etc/sssd/sssd.conf` or `/etc/sssd/conf.d/*.conf`), its connections must be\nprotected by TLS:\n\n- either every `ldap_uri` uses `ldaps://`, or `ldap_id_use_start_tls = true`;\n- `ldap_tls_reqcert` must not be `never`, `allow` or `try`. The SSSD default, `hard` (same as\n  `demand`), rejects a server whose certificate cannot be verified.\n",
    "rationale": "With the LDAP provider, SSSD checks passwords by binding to the directory with them. Without\nTLS the passwords and the account data cross the network in clear text; without certificate\nverification an attacker on the path can impersonate the directory and accept any password.\n",
    "impact": "The directory server must present a certificate signed by a CA the client trusts\n(`ldap_tls_cacert` or the system store). Logins fail if TLS cannot be established.\n",
    "notes": "The check reads every SSSD configuration file as a whole, not domain by domain: with several\ndomains, one weak setting fails the control. Without `ldap_uri`, SSSD finds servers through DNS\nSRV records and uses plain `ldap://`, so StartTLS is then required. The control does not apply\nwhen `sssd-ldap` is not installed, or when no domain uses the LDAP provider.\n",
    "audit": {
      "manual": "In `/etc/sssd/sssd.conf` and `/etc/sssd/conf.d/*.conf`, for each domain with an `ldap`\nprovider:\n1. every `ldap_uri` starts with `ldaps://`, or `ldap_id_use_start_tls = true`;\n2. `ldap_tls_reqcert` is absent, `demand` or `hard`.\n",
      "checks": [
        {
          "id": "ldap-tls",
          "engine": "shell",
          "description": "LDAP domains use TLS and require a valid server certificate.",
          "spec": {
            "script": "cfg=$(cat /etc/sssd/sssd.conf /etc/sssd/conf.d/*.conf 2>/dev/null | sed 's/[#;].*//')\n[ -n \"$cfg\" ] || { echo \"no SSSD configuration\"; exit 2; }\np() {\n  printf '%s\\n' \"$cfg\" | grep -Ei \"^[[:space:]]*$1[[:space:]]*=\" |\n    sed 's/^[^=]*=[[:space:]]*//; s/[[:space:]]*$//'\n}\np '(id|auth|chpass)_provider' | grep -qix ldap || { echo \"no domain uses the LDAP provider\"; exit 2; }\nrc=0\nr=$(p ldap_tls_reqcert | tail -n 1 | tr 'A-Z' 'a-z')\ncase $r in never | allow | try) echo \"ldap_tls_reqcert = $r\"; rc=1 ;; esac\ntls=$(p ldap_id_use_start_tls | tail -n 1 | tr 'A-Z' 'a-z')\nuris=$(p ldap_uri | paste -sd, -)\nif [ \"$tls\" != true ] && { [ -z \"$uris\" ] || printf '%s' \"$uris\" | grep -qi 'ldap://'; }; then\n  echo \"LDAP without TLS: ldap_uri = ${uris:-DNS SRV}, ldap_id_use_start_tls = ${tls:-false}\"\n  rc=1\nfi\n[ \"$rc\" = 0 ] && echo \"TLS in use, ldap_tls_reqcert = ${r:-hard (default)}\"\nexit \"$rc\"\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "In each LDAP domain section of the SSSD configuration:\n```\nldap_uri = ldaps://ldap.example.org\nldap_tls_reqcert = demand\nldap_tls_cacert = /etc/ssl/certs/ca-certificates.crt\n```\nor keep `ldap://` URIs and add `ldap_id_use_start_tls = true`. Then run\n`systemctl restart sssd` and check a login on a test session before closing yours.\n",
      "rollback": "Restore the previous SSSD configuration and run `systemctl restart sssd`.\n"
    },
    "references": [
      {
        "title": "sssd-ldap(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/sssd-ldap.5.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "ANSSI-BP-028 v2.0 - Recommandations de configuration d'un système GNU/Linux (R67)",
        "url": "https://messervices.cyber.gouv.fr/documents-guides/fr_np_linux_configuration-v2.0.pdf",
        "publisher": "ANSSI",
        "kind": "guide",
        "accessed": "2026-10-19"
      }
    ],
    "mappings": [
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R67",
        "relation": "partial",
        "note": "R67 asks to protect remote PAM authentication; this control covers SSSD with an LDAP directory."
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "SC-8",
        "relation": "related"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "IA-5(2)",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1557"
      },
      {
        "framework": "mitre-attack",
        "id": "T1040"
      },
      {
        "framework": "cwe",
        "id": "CWE-295"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "verified": [
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "20.04"
        ],
        "environment": "Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic",
        "notes": "Not applicable on the stock image; with sssd-ldap and an ldap:// domain with ldap_tls_reqcert = never the check fails, passes with ldaps:// and demand (manual fix)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic",
        "notes": "Not applicable on the stock image; with sssd-ldap and an ldap:// domain with ldap_tls_reqcert = never the check fails, passes with ldaps:// and demand (manual fix)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic",
        "notes": "Not applicable on the stock image; with sssd-ldap and an ldap:// domain with ldap_tls_reqcert = never the check fails, passes with ldaps:// and demand (manual fix)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic",
        "notes": "Not applicable on the stock image; with sssd-ldap and an ldap:// domain with ldap_tls_reqcert = never the check fails, passes with ldaps:// and demand (manual fix)."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}