{
  "id": "CB-UBU-AUTH-009",
  "standard": "ubuntu",
  "version": "0.1.0",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUTH-009",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUTH-009.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUTH-009.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-009",
    "title": "Write sudo rules with least privilege",
    "finding": {
      "title": "sudo rules give broader rights than the tasks need",
      "description": "Rules with negations, wildcards, shells or editors let users escape to a full root shell."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "manual",
    "tags": [
      "sudo",
      "privilege-escalation",
      "least-privilege"
    ],
    "applicability": {
      "facts": [
        "sudo"
      ]
    },
    "description": "Good sudo rules grant precise commands to a dedicated group:\n\n- administrators are members of a group dedicated to sudo, and rules name that group;\n- commands run as an unprivileged target user whenever root is not needed (`(appuser)`);\n- rules list full command paths with their arguments, and no negations (`!`), since\n  negations are easy to bypass by copying or renaming the binary;\n- programs that can start other programs (editors, pagers, interpreters) get `NOEXEC`, or are\n  replaced by `sudoedit` for editing files.\n",
    "rationale": "Many programs can spawn a shell: an editor launched as root, `less`, `find -exec`, or a\nscripting language. A rule that allows them is effectively `ALL`. Negated rules and wildcards\nlook restrictive but are bypassed with a renamed copy or an extra argument.\n",
    "impact": "Rewriting broad rules takes an inventory of what each administrator really needs. Users who\nedit files as root switch to `sudoedit`.\n",
    "notes": "Ubuntu's `/etc/sudoers` gives full rights to the `sudo` group and to the legacy `admin` group,\nwhich does not exist on new installations; remove that line if nothing uses it. sudo-rs, the\n`sudo` of Ubuntu 26.04, supports `NOEXEC:` (enforced with seccomp) and `sudoedit`, and only\naccepts `*` as a standalone last argument meaning \"any further arguments\".\n",
    "audit": {
      "manual": "Read every rule with `sudo -ll -U <user>` for each member of an administrative group, and\n`/etc/sudoers` plus `/etc/sudoers.d/`. Check that:\n1. rules target a dedicated group (`%group`), not individual users;\n2. no command list contains `!` (negation);\n3. commands are given with absolute paths and explicit arguments, without bare `*`;\n4. editors, pagers and interpreters are not allowed, or carry `NOEXEC:`; file edits use `sudoedit`;\n5. commands that do not need root run as a dedicated user.\n"
    },
    "remediation": {
      "manual": "1. Create a group per administrative role and use `%group` in rules.\n2. Replace `ALL` and negated lists with explicit commands and arguments.\n3. Replace `vi /etc/file` style rules with `sudoedit /etc/file`, and add `NOEXEC:` to rules\n   for programs that can run other programs.\n4. Validate with `visudo -c` before closing the root session used for the change.\n"
    },
    "references": [
      {
        "title": "sudoers(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/sudoers.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 (R38 to R44)",
        "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": "R38",
        "relation": "equivalent"
      },
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R40",
        "relation": "equivalent"
      },
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R41",
        "relation": "equivalent"
      },
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R42",
        "relation": "equivalent"
      },
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R43",
        "relation": "equivalent"
      },
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R44",
        "relation": "equivalent"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AC-6",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1548.003"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}