Public bug reported:

On Ubuntu 24.04, a package upgrade that triggered `pam-auth-update`
regenerated `/etc/pam.d/common-auth` and silently discarded a manually
configured `pam_faillock.so preauth` line while keeping the
`pam_faillock.so authfail` line. The regenerated `success=N` jump counts
were computed for a stack without faillock, so **every successful
password authentication jumped to `pam_deny`**. The result: `sudo`, GDM
password login, and polkit all rejected the *correct* password. The
user's password hash was fine — authentication was impossible because of
the PAM stack.

## Environment

- Ubuntu 24.04.5 LTS (noble)
- `libpam-runtime` / `libpam-modules` 1.5.3-5ubuntu5.7
- `libpam-sss` / `sssd` 2.9.4-1.1ubuntu6.9 (upgraded in the triggering 
transaction)
- `sudo` 1.9.15p5-3ubuntu5.24.04.4
- Local account in `/etc/passwd`, NSS: `passwd: files systemd sss`

## Steps to reproduce

1. On Ubuntu 24.04 with SSSD enabled via `pam-auth-update`, add faillock
manually to `/etc/pam.d/common-auth`, adjusting the jump counts so
successful auth skips `authfail` and `pam_deny`:

   ```pam
   auth    required                        pam_faillock.so preauth
   auth    [success=3 default=ignore]      pam_unix.so nullok
   auth    [success=2 default=ignore]      pam_sss.so use_first_pass
   auth    [default=die]                   pam_faillock.so authfail
   auth    requisite                       pam_deny.so
   auth    required                        pam_permit.so
   ```

2. Verify sudo/password login works.
3. Run an upgrade that touches PAM packages, e.g. `apt upgrade -y` upgrading 
`sssd` / `libpam-sss`, which runs `pam-auth-update` in a maintainer script.
4. Try `sudo -k && sudo true` with the correct password.

## Expected result

The correct password authenticates; `common-auth` is either left
untouched or regenerated with a consistent stack.

## Actual result

All password authentication fails. `/var/log/auth.log` shows
`pam_unix(sudo:auth): authentication failure` / `... incorrect password
attempt` even though `passwd` had just reported `password changed for
<user>` and `chage` showed the new date.

## Root cause

`pam-auth-update` rewrote the file and created a backup `common-
auth.pam-old`. The exact diff (old = working, new = broken):

```diff
--- /etc/pam.d/common-auth.pam-old
+++ /etc/pam.d/common-auth
@@ -14,9 +14,8 @@
 # here are the per-package modules (the "Primary" block)
-auth    required                pam_faillock.so preauth
-auth    [success=3 default=ignore]  pam_unix.so nullok
-auth    [success=2 default=ignore]  pam_sss.so use_first_pass
+auth    [success=2 default=ignore]  pam_unix.so nullok
+auth    [success=1 default=ignore]  pam_sss.so use_first_pass
 # here's the fallback if no module succeeds
 auth    [default=die]           pam_faillock.so authfail
 auth    requisite               pam_deny.so
```

- The `preauth` line was removed.
- `pam_unix` and `pam_sss` jump counts were recomputed as if `authfail` were 
not in the stack.
- With `success=2`, a successful `pam_unix` skips `pam_sss` and `authfail` and 
lands on `pam_deny.so` (`requisite`) → authentication is denied. With 
`success=1`, a successful `pam_sss` likewise lands on `pam_deny`.
- `pam_faillock.so authfail` was left in place because it is a manual line; the 
jump counts around it were not adjusted.

### Timeline from the affected machine

- `22:03:45–22:04:03` — `apt upgrade -y` transaction (included 
`sssd`/`libpam-sss`).
- `22:03:56` — both `/etc/pam.d/common-auth` and `common-auth.pam-old` written.
- `22:14` onward — repeated GDM/sudo/polkit password failures.
- `22:25:22` — `passwd[PID]: pam_unix(passwd:chauthtok): password changed for 
<user>` succeeded (proving the hash was correct).
- After restoring `common-auth.pam-old`, `sudo` authentication succeeded 
immediately at `22:49:27`, confirming the PAM stack was the cause.

## Workaround

Restore the pre-regeneration stack (or equivalently re-add `preauth` and
set `success=3` / `success=2`) from a root shell:

```sh
cp /etc/pam.d/common-auth.pam-old /etc/pam.d/common-auth
faillock --user <user> --reset
```

## Suggested fix

1. Ship a `pam_faillock` profile in `/usr/share/pam-configs/` so faillock is a 
first-class, managed module and its `preauth`/`authfail`/`authsucc` lines and 
jump counts survive `pam-auth-update`. (There is currently no such profile; 
`grep -rl faillock /usr/share/pam-configs/` returns nothing.)
2. Alternatively, make `pam-auth-update` detect hand-added lines in the managed 
block, preserve them, and recompute `success=N` jumps against the *actual* 
resulting stack rather than only the registered profiles. If it cannot do that 
safely, it should refuse to rewrite and warn instead of producing a silently 
broken stack.

## Related reports

- Launchpad bug 2075389 — *pam-auth-update lacks flexibility needed to support 
sss + foo-auth-module cleanly* (jump-count/`success=end` problem with extra 
modules).
- Launchpad bug 2101949 — *pam-auth-update --remove sss does not work* 
(common-* regeneration issues).
- AskUbuntu 1444024 — *How to configure pam_faillock in common-?* (notes that 
common-* can be overridden by upgrading other PAM modules such as libpam-sss).
- Launchpad bug 1966416 — faillock `authfail`/`authsucc` placement and 
`pam_deny` interaction.

ProblemType: Bug
DistroRelease: Ubuntu 24.04
Package: libpam-runtime 1.5.3-5ubuntu5.7
ProcVersionSignature: Ubuntu 7.0.0-43.43~24.04.1-generic 7.0.14
Uname: Linux 7.0.0-43-generic x86_64
ApportVersion: 2.28.3-0ubuntu0.1
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Thu Nov 19 23:15:44 2026
InstallationDate: Installed on 2026-10-24 (27 days ago)
InstallationMedia: Ubuntu 24.04.5 LTS "Noble Numbat" - Release amd64 (20260914)
PackageArchitecture: all
ProcEnviron:
 LANG=en_US.UTF-8
 PATH=(custom, user)
 SHELL=/bin/bash
 TERM=xterm-256color
 XDG_RUNTIME_DIR=<set>
SourcePackage: pam
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.default.apport:
 # set this to 0 to disable apport, or to 1 to enable it
 # you can temporarily override this with
 # sudo service apport start force_start=1
 enabled=0
mtime.conffile..etc.default.apport: 2026-10-25T04:35:47.764364

** Affects: pam (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug noble

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2175130

Title:
  pam-auth-update regeneration breaks common-auth when pam_faillock was
  added manually

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/pam/+bug/2175130/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to