Debian GNU/Linux · Accounts & authentication

Write sudo rules with least privilege

When it fails: sudo rules give broader rights than the tasks need. Rules with negations, wildcards, shells or editors let users escape to a full root shell.

CB-DEB-AUTH-009mediumactivemanualprofile core

Description

Good sudo rules grant precise commands to a dedicated group:

  • administrators are members of a group dedicated to sudo, and rules name that group;
  • commands run as an unprivileged target user whenever root is not needed ((appuser));
  • rules list full command paths with their arguments, and no negations (!), since negations are easy to bypass by copying or renaming the binary;
  • programs that can start other programs (editors, pagers, interpreters) get NOEXEC, or are replaced by sudoedit for editing files.

Rationale

Many programs can spawn a shell: an editor launched as root, less, find -exec, or a scripting language. A rule that allows them is effectively ALL. Negated rules and wildcards look restrictive but are bypassed with a renamed copy or an extra argument.

Impact

Rewriting broad rules takes an inventory of what each administrator really needs. Users who edit files as root switch to sudoedit.

Applies when

Detected: when: sudo is installed A scanner reports the control not applicable when one is false.

Audit

Read every rule with sudo -ll -U <user> for each member of an administrative group, and /etc/sudoers plus /etc/sudoers.d/. Check that:

  1. rules target a dedicated group (%group), not individual users;
  2. no command list contains ! (negation);
  3. commands are given with absolute paths and explicit arguments, without bare *;
  4. editors, pagers and interpreters are not allowed, or carry NOEXEC:; file edits use sudoedit;
  5. commands that do not need root run as a dedicated user.

Remediation

  1. Create a group per administrative role and use %group in rules.
  2. Replace ALL and negated lists with explicit commands and arguments.
  3. Replace vi /etc/file style rules with sudoedit /etc/file, and add NOEXEC: to rules for programs that can run other programs.
  4. Validate with visudo -c before closing the root session used for the change.

References

Mappings

How this control relates to the other framework's: equivalent, stricter, looser, partial or related.

Threats mitigated

People and lifecycle

Authors
Introduced inv0.1.0
Created, updated2026-10-18, 2026-10-18
Translationsfr