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 bysudoeditfor editing files.
Ubuntu's /etc/sudoers gives full rights to the sudo group and to the legacy admin group,
which does not exist on new installations; remove that line if nothing uses it. sudo-rs, the
sudo of Ubuntu 26.04, supports NOEXEC: (enforced with seccomp) and sudoedit, and only
accepts * as a standalone last argument meaning "any further arguments".
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: A sudo command is installed (sudo or sudo-rs) 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:
- rules target a dedicated group (
%group), not individual users; - no command list contains
!(negation); - commands are given with absolute paths and explicit arguments, without bare
*; - editors, pagers and interpreters are not allowed, or carry
NOEXEC:; file edits usesudoedit; - commands that do not need root run as a dedicated user.
Remediation
- Create a group per administrative role and use
%groupin rules. - Replace
ALLand negated lists with explicit commands and arguments. - Replace
vi /etc/filestyle rules withsudoedit /etc/file, and addNOEXEC:to rules for programs that can run other programs. - Validate with
visudo -cbefore closing the root session used for the change.
References
- sudoers(5), Ubuntu manual pages Canonical, vendor-doc, accessed 2026-10-19
- ANSSI-BP-028 v2.0 - Recommandations de configuration d'un système GNU/Linux (R38 to R44) ANSSI, guide, accessed 2026-10-19
Mappings
| Framework | ID | Relation |
|---|---|---|
| ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0 | R38 | equivalent |
| ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0 | R40 | equivalent |
| ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0 | R41 | equivalent |
| ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0 | R42 | equivalent |
| ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0 | R43 | equivalent |
| ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0 | R44 | equivalent |
| NIST SP 800-53 Rev. 55.1.1 | AC-6 | related |
How this control relates to the other framework's: equivalent, stricter, looser, partial or related.
Threats mitigated
| Taxonomy | ID |
|---|---|
| MITRE ATT&CK | T1548.003 |
People and lifecycle
| Authors |
|
| Introduced in | v0.1.0 |
| Created, updated | 2026-10-19, 2026-10-19 |
| Translations | fr |