{
  "id": "CB-UBU-FS-007",
  "standard": "ubuntu",
  "version": "0.1.0",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-FS-007",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-FS-007.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-FS-007.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-FS-007",
    "title": "Protect the user, group and password database files",
    "finding": {
      "title": "The account database files have weak ownership or permissions",
      "description": "Password hashes can be read for offline cracking, or account files can be changed to add a user or gain root."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "high"
    },
    "assessment": "automated",
    "tags": [
      "permissions",
      "accounts",
      "shadow"
    ],
    "description": "The files that define local accounts, and the backups that the shadow tools keep with a `-`\nsuffix, have the Ubuntu ownership and at most these modes:\n\n| Files | Owner:group | Maximum mode |\n|---|---|---|\n| `/etc/passwd`, `/etc/passwd-`, `/etc/group`, `/etc/group-` | `root:root` | `644` |\n| `/etc/shadow`, `/etc/shadow-`, `/etc/gshadow`, `/etc/gshadow-` | `root:shadow` | `640` |\n| `/etc/shells` | `root:root` | `644` |\n| `/etc/security/opasswd`, `/etc/security/opasswd.old` | `root:root` | `600` |\n\nFiles that do not exist are skipped.\n",
    "rationale": "`passwd` and `group` must stay readable by everyone for name lookups, but only root may change\nthem: write access means creating a UID 0 account. `shadow` and `gshadow` hold password hashes;\non Ubuntu the `shadow` group lets `unix_chkpwd` and screen lockers check a password without\nbeing root, and nobody else may read them. `opasswd` holds the previous password hashes kept by\n`pam_pwhistory`. The `-` backups contain the same data as the live files.\n",
    "impact": "None known: these are the Ubuntu defaults, and the fix only removes extra access.\n",
    "notes": "Ubuntu, like Debian, uses group `shadow` for `shadow` and `gshadow`, not `root` as on other\ndistributions.\nSetting them to `root:root` breaks password checks by `unix_chkpwd` for non-root programs\n(screen lockers, some PAM services).\n",
    "setting": {
      "location": "/etc/passwd, /etc/group, /etc/shadow, /etc/gshadow, /etc/shells, /etc/security/opasswd",
      "default_value": "Compliant on a fresh install",
      "recommended_value": "See the table in the description"
    },
    "audit": {
      "manual": "Run `stat -c '%n %U:%G %a' /etc/passwd* /etc/group* /etc/shadow* /etc/gshadow* /etc/shells /etc/security/opasswd*`\nand compare each line with the table above.\n",
      "checks": [
        {
          "id": "passwd",
          "engine": "file-perms",
          "description": "/etc/passwd and its backup are root:root, mode 644 or stricter.",
          "spec": {
            "path": "/etc/passwd*",
            "owner": "root",
            "group": "root",
            "mode": "0644"
          }
        },
        {
          "id": "group",
          "engine": "file-perms",
          "description": "/etc/group and its backup are root:root, mode 644 or stricter.",
          "spec": {
            "path": "/etc/group*",
            "owner": "root",
            "group": "root",
            "mode": "0644"
          }
        },
        {
          "id": "shadow",
          "engine": "file-perms",
          "description": "/etc/shadow and its backup are root:shadow, mode 640 or stricter.",
          "spec": {
            "path": "/etc/shadow*",
            "owner": "root",
            "group": "shadow",
            "mode": "0640"
          }
        },
        {
          "id": "gshadow",
          "engine": "file-perms",
          "description": "/etc/gshadow and its backup are root:shadow, mode 640 or stricter.",
          "spec": {
            "path": "/etc/gshadow*",
            "owner": "root",
            "group": "shadow",
            "mode": "0640"
          }
        },
        {
          "id": "shells",
          "engine": "file-perms",
          "description": "/etc/shells is root:root, mode 644 or stricter.",
          "spec": {
            "path": "/etc/shells",
            "owner": "root",
            "group": "root",
            "mode": "0644"
          }
        },
        {
          "id": "opasswd",
          "engine": "file-perms",
          "description": "/etc/security/opasswd and its backup are root:root, mode 600 or stricter.",
          "spec": {
            "path": "/etc/security/opasswd*",
            "owner": "root",
            "group": "root",
            "mode": "0600"
          }
        }
      ]
    },
    "remediation": {
      "manual": "```\nchown root:root /etc/passwd /etc/passwd- /etc/group /etc/group- /etc/shells\nchmod u-x,go-wx /etc/passwd /etc/passwd- /etc/group /etc/group- /etc/shells\nchown root:shadow /etc/shadow /etc/shadow- /etc/gshadow /etc/gshadow-\nchmod u-x,g-wx,o-rwx /etc/shadow /etc/shadow- /etc/gshadow /etc/gshadow-\nchown root:root /etc/security/opasswd*\nchmod 600 /etc/security/opasswd*\n```\n",
      "effects": {
        "restart": "none",
        "disruption": "none",
        "lockout_risk": false
      },
      "rollback": "Not needed: the fix only restores the Ubuntu ownership and removes extra permissions.\n",
      "scripts": [
        {
          "id": "passwd",
          "from_check": "passwd"
        },
        {
          "id": "group",
          "from_check": "group"
        },
        {
          "id": "shadow",
          "from_check": "shadow"
        },
        {
          "id": "gshadow",
          "from_check": "gshadow"
        },
        {
          "id": "shells",
          "from_check": "shells"
        },
        {
          "id": "opasswd",
          "from_check": "opasswd"
        }
      ]
    },
    "references": [
      {
        "title": "shadow(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/shadow.5.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "shells(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/shells.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 (R50)",
        "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": "R50",
        "relation": "partial",
        "note": "R50 covers every sensitive file; this control covers the account databases."
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AC-3",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1003.008"
      },
      {
        "framework": "cwe",
        "id": "CWE-732"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-AUTH-028",
        "type": "related"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "verified": [
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "20.04"
        ],
        "environment": "Proxmox VM 2520, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic",
        "notes": "Passes on fresh install; fix not needed (Ubuntu defaults)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM 2522, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic",
        "notes": "Passes on fresh install; fix not needed (Ubuntu defaults)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM 2524, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic",
        "notes": "Passes on fresh install; fix not needed (Ubuntu defaults)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM 2526, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic",
        "notes": "Passes on fresh install; fix not needed (Ubuntu defaults)."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}