Ubuntu · Accounts & authentication

Require a password for every sudo rule

When it fails: Some sudo rules run commands without asking for a password. Anyone who takes over such an account, or just an unlocked session, gets root without knowing any secret.

CB-UBU-AUTH-006highactiveautomatedprofile server-hardenedprofile desktop-hardened

As released in v0.1.1 (beta). Current state.

Description

A sudo rule tagged NOPASSWD: runs commands without asking the user for their password.

Ubuntu cloud images get a NOPASSWD:ALL rule for the default user from cloud-init, in /etc/sudoers.d/90-cloud-init-users. Set a password for that user before removing the rule. The rule syntax is the same for sudo-rs, the sudo of Ubuntu 26.04.

Rationale

The password prompt is the last barrier between a stolen session or a compromised process running as an administrator and full control of the system. Without it, privilege escalation needs no secret at all.

Impact

Automation that relies on password-less sudo (configuration management, deployment accounts) needs another approach: a dedicated account restricted to precise commands, run from a controlled host, or root access through SSH keys for that tool only.

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

Run grep -r NOPASSWD /etc/sudoers /etc/sudoers.d/. There must be no match.

Automated: every check must pass. Scanners report each check by its id.

sudoers

No NOPASSWD tag in /etc/sudoers.

path: /etc/sudoers
pattern: ^[^#]*NOPASSWD
expect: no_match

sudoers-d

No NOPASSWD tag in /etc/sudoers.d/.

path: /etc/sudoers.d/*
pattern: ^[^#]*NOPASSWD
expect: no_match

Remediation

  1. Make sure every user concerned has a password (passwd <user>) and can still run sudo -v.
  2. Edit the files with visudo (or visudo -f /etc/sudoers.d/<file>) and remove NOPASSWD: from each rule.

Rollback

Add the NOPASSWD: tag back with visudo.

References

Mappings

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

Threats mitigated

People and lifecycle

Authors
Verified2026-10-19 by Sn0wAlice on 20.04, Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic. Fails on the cloud image (cloud-init NOPASSWD rule) as expected; manual fix.
Verified2026-10-19 by Sn0wAlice on 22.04, Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic. Fails on the cloud image (cloud-init NOPASSWD rule) as expected; manual fix.
Verified2026-10-19 by Sn0wAlice on 24.04, Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic. Fails on the cloud image (cloud-init NOPASSWD rule) as expected; manual fix.
Verified2026-10-19 by Sn0wAlice on 26.04, Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic. Fails on the cloud image (cloud-init NOPASSWD rule) as expected; manual fix.
Introduced inv0.1.0
Created, updated2026-10-19, 2026-10-19
Translationsfr