Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CACXwg9Bo11W14JV9+utLgiFxbC1ZqD1HLvBaB1O_RDxGthZHAA@mail.gmail.com>
Date: Thu, 19 Nov 2026 08:59:24 -0800
From: Andrey Vasilevsky <anvanster@...il.com>
To: oss-security@...ts.openwall.com
Subject: CVE-2026-124749: pam-mysql: inverted PAM_DISALLOW_NULL_AUTHTOK gives
 a pre-auth authentication bypass

Hello,

pam-MySQL (libpam-mysql, src:pam-mysql) inverts
PAM_DISALLOW_NULL_AUTHTOK at both pam_sm_authenticate call sites, so
an application that asks PAM to refuse passwordless accounts gets
the permissive behaviour instead. On a stock sshd, an
unauthenticated network client authenticates as any account whose
stored password column is SQL NULL, using any password. The supplied
password is never compared on that branch.

CVE-2026-124749, assigned by Red Hat off the distros posting.

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H = 9.8. A reading that
prices the schema precondition into AC gives 8.1 and I would not
argue with it. See the note on the 1.0 line below, where that
precondition largely disappears.

THE DEFECT, against v0.8.2

- pam_mysql.c:3611, parameter 4, is documented "Whether null
authentication tokens should be disallowed".
- pam_mysql.c:3874, else branch: vresult = null_inhibited
- pam_mysql.c:3877: vresult == 0 -> PAM_MYSQL_ERR_SUCCESS
- pam_mysql.c:4708 and :4799 pass !(flags &
PAM_DISALLOW_NULL_AUTHTOK), which is 0 exactly when the
application set the flag.

The password comparison is nested inside "if (row[0] != NULL)" at
:3689, so on the NULL branch no comparison happens at all. Any
password works, including none.

The two pam_sm_chauthtok call sites pass a literal 0 and are
correct. That sibling contrast is what makes this a slip rather than
an intended convention.

WHY A DEFAULT sshd IS THE VECTOR, AND WHY THAT IS THE STING

OpenSSH sets PAM_DISALLOW_NULL_AUTHTOK precisely when
PermitEmptyPasswords is no, which is the default. So the inversion
is reached by the safe configuration and not by the unsafe one: an
administrator who has done nothing wrong gets the permissive path,
and one who has set PermitEmptyPasswords yes does not.

That is also why the obvious workaround is wrong. See MITIGATION
below.

AFFECTED, AND THE 1.0 LINE IS WORSE

Every released version carries it, including the newest upstream
commit, which dates from 2024-03-14.

0.8.x: Debian 11/12/13/14/sid, Ubuntu 18.04/20.04/22.04, Devuan,
PureOS, Pardus, Deepin, Kali, FreeBSD, Gentoo, Liguros.

1.0.0 betas: Fedora 39-44 and rawhide (beta1), Nix 6 channels
(beta2), Mageia 10 and Rosa (beta1), ALT (1.0.0).

On 0.8.x the exploitable schema is a nullable password column. On
the 1.0 line an empty stored password is exploitable too, because
the guard there is "if (row[0] && row0len)" at
src/authenticate.c:104, which routes an empty stored password into
the same inverted branch at :127.

So the NOT NULL DEFAULT '' schema that protects an operator on 0.8.x
is the exploitable one on the 1.0 line, and that is the schema a
careful author writes. PostfixAdmin declares mailbox.password and
admin.password as varchar(255) NOT NULL default ''. Froxlor declares
ftp_users.password as varchar(255) NOT NULL with no default. Both
shapes are shipped, current schemas.

On the distributions carrying the 1.0 betas the schema dependency is
therefore largely absent, and AC:L with 9.8 is unambiguous there.

MEASURED OVER A REAL sshd

Each arm reads 0.8.2-Debian / 1.0.0-beta3 / beta3-plus-polarity-fix.

- NULL stored, wrong password: SUCCESS / SUCCESS / DENY
- empty stored, wrong password: DENY / SUCCESS / DENY
- control, real stored, correct password: SUCCESS / SUCCESS /
SUCCESS
- control, real stored, wrong password: DENY / DENY / DENY

"Wrong password" above means a wrong, non-empty password.

THE FIX THAT IS SHIPPING, WHICH IS NOT MINE

Ship this one. It is Ferenc Wagner's, and it is better than the
patch I originally proposed.

old: vresult = null_inhibited;
new: vresult = !ctx->nullok || null_inhibited;

plus the polarity correction at both pam_sm_authenticate call sites:

old: !(flags & PAM_DISALLOW_NULL_AUTHTOK));
new: !!(flags & PAM_DISALLOW_NULL_AUTHTOK));

and a new nullok boolean, default off, registered in both the
module-argument and the config-file option tables.

The reasoning, which changed my mind about my own patch: before the
fix, an application calling with flags=0 does not authenticate a
NULL-password account. Correcting the polarity alone would start
authenticating one. That is a behaviour change to make in a stable
security update, even though it is what the flag is documented to
mean. nullok is the same name and the same semantics pam_unix and
pam_ldap already use, so an operator who needs the permissive
behaviour has an obvious way to ask for it.

NULL stored password, any supplied password, reading before /
polarity-fix-only / shipping-fix:

- called with flags=0: DENY / SUCCESS / DENY, and SUCCESS under the
shipping fix only when nullok is enabled
- called with PAM_DISALLOW_NULL_AUTHTOK: SUCCESS / DENY / DENY

My own patches are in the distros archive and are a fallback, not a
recommendation. The 0.8.x one additionally routes an empty stored
password into the null branch, so it denies that case by default
where the shipping fix leaves 0.8.x behaviour unchanged. On 0.8.x
its three hunks have to land together: applying the empty-string
hunk without the polarity hunks would make NOT NULL DEFAULT ''
columns exploitable in the way the 1.0 line already is.

For the 1.0 line the polarity correction is two characters, the same
"!!" at src/authenticate.c:287 and :378. No empty-string hunk is
wanted there, because the guard already routes both cases to one
branch.

MITIGATION IF YOU CANNOT PATCH YET

Do not set PermitEmptyPasswords yes. It does suppress this defect,
because it clears the flag and a cleared flag denies a NULL row, but
it also disables OpenSSH's own empty-password guard at
auth-passwd.c:93-94, which opens the empty-stored-password case
instead. It trades one bypass for another.

The supportable mitigation is to stop storing credential-less rows
in any table used for authentication: purge them, then add NOT NULL
with no empty-string default.

One consequence worth stating plainly for operators who are relying,
knowingly or not, on the inverted behaviour to refuse NULL rows
through an application that permits null tokens. Those deployments
become more exposed after a polarity-only fix, not less. The
shipping fix avoids that, because nullok defaults off and a NULL
stored password is refused regardless of the flag. Either way the
real remediation is the rows, not the flag.

HOW TO CHECK WHETHER YOU WERE EXPLOITED

The caveat first, because it is the important part: OpenSSH's log
cannot distinguish a bypass from a legitimate login. Both produce
the same line.

Accepted password for nullpw from 127.0.0.1 port 39024 ssh2
Accepted password for normalpw from 127.0.0.1 port 39034 ssh2

The first is a bypass of an account whose stored password was NULL.
The second is a genuine login. Nothing in either line marks the
difference.

So the discriminator has to come from the database. Any accepted
password login for an account whose stored password was NULL or ''
is necessarily a bypass, because no password could legitimately have
matched. Start from the credential-less rows:

SELECT username FROM users WHERE password IS NULL OR password='';

and correlate those names against "Accepted password for" lines in
the auth log.

Two things make a naive check miss:

1. Current database state does not prove historical state. A column
populated since the login makes the account look safe today. The
binary log or a backup from the period is the only reliable
source where it matters.

2. pam_mysql's own audit table is off by default, and when enabled
it contains a spelling error that defeats the obvious grep.
log.enabled defaults to 0 at pam_mysql.c:2897 and is gated at
:4331, so a default deployment records nothing there at all. With
log.enabled=1 the table does capture the bypass, but the failure
string is misspelled AUTHENTICATION FALURE, so a query for
FAILURE returns nothing.

There is a weak secondary signal in that table: the bypass produced
a single SUCCESS (FIRST_PASS) row with no preceding failure, where
the genuine login produced a failure then a success, because the
first pass tried a token that did not match. I would not build
detection on that alone, since it depends on the calling
application's pass behaviour, but it is worth knowing when reading
an existing table.

STATUS

Upstream is Nigel Cunningham. He confirmed the defect and approved a
fix on 2026-10-26, held the commits for the coordinated date, and
pushed them to master at 16:37 UTC today, after the lift. Two
commits carry it: 6e2c52eb "CVE Fix", which is the "!!" correction
at both pam_sm_authenticate call sites, and 46175520 "Add nullok
option.", which brings the null branch to "vresult = !ctx->nullok ||
null_inhibited", the same shape Debian is shipping. Master is the
1.0 line. The v0.8.x branch has not been updated and its head still
dates from 2021, so for the 0.8 line the fix is at present the
distribution patch rather than an upstream commit. He also enabled
private vulnerability reporting on the repository after my report,
so there is now a private channel where there was none.

Debian's maintainer is Ferenc Wagner. The trixie security upload
carries the fix, the nullok documentation and the CVE reference, and
went to security-master on 2026-11-17. Bookworm is Debian LTS rather
than stable security, so its update goes through the LTS process and
has not been uploaded yet; bookworm users are still exposed as I
write this. Bookworm is 0.8.2-2 against trixie's 0.8.2-2.1, the same
upstream version with the same patch series, so the fix applies
there unchanged.

Debian's upload also extends the package's autopkgtest to cover NULL
and empty stored passwords under both flag values, which is the
regression test this defect should have had from the start.

I have not checked the other affected distributions. The 1.0-line
ones have no fixed release: today's master commits carry no tag, and
the newest tag is still 1.0.0-beta3. Fedora, Nix, Mageia, Rosa and
ALT ship those betas, where the exploitable schema is the common
one, and the two-character polarity correction above applies to them
directly.

TIMELINE

- 2026-10-23 found, reproduced end to end on Debian trixie
- 2026-10-24 reported privately to upstream and to Debian
- 2026-10-26 upstream confirmed and approved a fix
- 2026-11-08 posted to distros, embargo opened
- 2026-11-09 CVE-2026-124749 assigned by Red Hat
- 2026-11-17 Debian trixie upload to security-master
- 2026-11-19 14:00 UTC embargo lift; upstream pushed to master at
16:37 UTC; this posting

One correction to that timeline rather than leave it to be noticed.
I told upstream and Debian on 10-24 that I proposed 2026-11-07 as
the disclosure date, then failed to open the distros thread in time
for that date to mean anything, so it passed unused and the embargo
clock started on 11-08 instead. Nothing was published and nothing
leaked; the coordination sat in a private thread two weeks longer
than it should have, and that was my fault rather than anyone
else's.

CREDIT

Nigel Cunningham, upstream, for confirming quickly and then sitting
on finished patches for eleven days while I sorted out a gap that
was mine. Ferenc Wagner, Debian, for the fix that is actually
shipping and for the regression test. Salvatore Bonaccorso and the
Debian Security Team for the coordination. Rafael Pandini of Red Hat
Product Security for the CVE assignment.

A full write-up, both of my patches, and a container-based
reproducer that installs the distribution package and compiles
nothing of the module are available on request.

I used AI assistance to find and write up this issue. Every code
citation and every measured arm was verified by hand.

Thank you,

Andrey Vasilevsky

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.