{
  "id": "CB-UBU-AUTH-027",
  "standard": "ubuntu",
  "version": "0.1.2",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-AUTH-027",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-AUTH-027.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-AUTH-027.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-AUTH-027",
    "title": "Keep the user and group databases consistent",
    "finding": {
      "title": "User and group files contain duplicates or dangling references",
      "description": "Duplicate IDs or names give two accounts the same rights and break accountability."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "automated",
    "tags": [
      "accounts",
      "integrity"
    ],
    "description": "The account databases (`/etc/passwd`, `/etc/shadow`, `/etc/group`, `/etc/gshadow`) must be\nconsistent: each user and group name and each UID and GID is unique, every primary group of a\nuser exists, and every `passwd` entry has a `shadow` entry. `pwck -r` and `grpck -r` check\nthese rules without changing anything.\n",
    "rationale": "Two accounts with the same UID are the same user for the kernel: files, processes and logs\ncannot tell them apart. Duplicates and dangling entries are often the trace of a manual edit\nor of an attacker adding an account.\n",
    "impact": "None. The check is read-only; fixes need a human decision.\n",
    "audit": {
      "manual": "1. Run `pwck -r` and `grpck -r`. They must report nothing, apart from missing home\n   directories of system accounts (`lp`, `news`, `www-data`...), which Ubuntu does not create.\n2. `cut -d: -f3 /etc/passwd | sort | uniq -d` and `cut -d: -f3 /etc/group | sort | uniq -d`\n   print nothing.\n",
      "checks": [
        {
          "id": "pwck",
          "engine": "shell",
          "spec": {
            "script": "out=$(pwck -r 2>&1 | grep -v -e \"directory '.*' does not exist\" -e '^pwck: no changes$')\necho \"${out:-pwck: no problem (missing system homes ignored)}\"\n[ -z \"$out\" ]\n"
          }
        },
        {
          "id": "grpck",
          "engine": "shell",
          "spec": {
            "script": "out=$(grpck -r 2>&1); rc=$?\necho \"${out:-grpck: no problem}\"\n[ \"$rc\" -eq 0 ]\n"
          }
        },
        {
          "id": "duplicate-ids",
          "engine": "shell",
          "spec": {
            "script": "u=$(cut -d: -f3 /etc/passwd | sort | uniq -d | tr '\\n' ' ')\ng=$(cut -d: -f3 /etc/group | sort | uniq -d | tr '\\n' ' ')\necho \"duplicate UIDs: ${u:-none}; duplicate GIDs: ${g:-none}\"\n[ -z \"$u$g\" ]\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "Investigate each reported entry: a duplicate UID 0 or an unknown account may be malicious.\nFix with `usermod`, `groupmod`, `userdel` and `groupdel`, or interactively with `pwck` and\n`grpck` (without `-r`).\n"
    },
    "references": [
      {
        "title": "pwck(8), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man8/pwck.8.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "grpck(8), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man8/grpck.8.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      }
    ],
    "mappings": [
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "IA-2",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1136.001"
      }
    ],
    "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": "Passes on a fresh install; profiles core and server-hardened."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic",
        "notes": "Passes on a fresh install; profiles core and server-hardened."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic",
        "notes": "Passes on a fresh install; profiles core and server-hardened."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic",
        "notes": "Passes on a fresh install; profiles core and server-hardened."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}