Version in base suite: 0.8.2-2.1 Base version: pam-mysql_0.8.2-2.1 Target version: pam-mysql_0.8.2-2.1+deb13u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/p/pam-mysql/pam-mysql_0.8.2-2.1.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/p/pam-mysql/pam-mysql_0.8.2-2.1+deb13u1.dsc changelog | 18 + gbp.conf | 2 patches/Avoid-segfault-on-invalid-SSHA-hash-value.patch | 27 ++ patches/SECURITY-correct-PAM_DISALLOW_NULL_AUTHTOK-implementation.patch | 109 ++++++++ patches/series | 2 tests/auth | 122 +++++----- 6 files changed, 225 insertions(+), 55 deletions(-) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmpqr2taieq/pam-mysql_0.8.2-2.1.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmpqr2taieq/pam-mysql_0.8.2-2.1+deb13u1.dsc: no acceptable signature found diff -Nru pam-mysql-0.8.2/debian/changelog pam-mysql-0.8.2/debian/changelog --- pam-mysql-0.8.2/debian/changelog 2024-05-25 08:11:54.000000000 +0000 +++ pam-mysql-0.8.2/debian/changelog 2026-11-17 19:33:58.000000000 +0000 @@ -1,3 +1,21 @@ +pam-mysql (0.8.2-2.1+deb13u1) trixie-security; urgency=high + + * [0067138] New patch: SECURITY: correct PAM_DISALLOW_NULL_AUTHTOK + implementation (CVE-2026-124749). + If an application called PAM with PAM_DISALLOW_NULL_AUTHTOK, users + with a NULL password were authenticated by the pam_mysql module, + contrary to the PAM specification. This bug is now fixed. If the + flag was not passed, users with a NULL password were not + authenticated. This is now relaxed: if the freshly introduced + "nullok" option is enabled in the configuration or on the module + command line, users with a NULL password are authenticated unless the + caller forbids this via the PAM_DISALLOW_NULL_AUTHTOK flag. + Reported-by: Andrey Vasilevsky + * [b09da8b] New patch: Avoid segfault on invalid SSHA hash value + * [070edde] Extend autopkgtest for empty and NULL stored passwords + + -- Ferenc Wágner Tue, 17 Nov 2026 20:33:58 +0100 + pam-mysql (0.8.2-2.1) unstable; urgency=medium * Non-maintainer upload. diff -Nru pam-mysql-0.8.2/debian/gbp.conf pam-mysql-0.8.2/debian/gbp.conf --- pam-mysql-0.8.2/debian/gbp.conf 2023-01-29 21:53:21.000000000 +0000 +++ pam-mysql-0.8.2/debian/gbp.conf 2026-11-17 17:26:38.000000000 +0000 @@ -1,5 +1,5 @@ [DEFAULT] -debian-branch = debian/master +debian-branch = debian/trixie upstream-branch = upstream/latest pristine-tar = True diff -Nru pam-mysql-0.8.2/debian/patches/Avoid-segfault-on-invalid-SSHA-hash-value.patch pam-mysql-0.8.2/debian/patches/Avoid-segfault-on-invalid-SSHA-hash-value.patch --- pam-mysql-0.8.2/debian/patches/Avoid-segfault-on-invalid-SSHA-hash-value.patch 1970-01-01 00:00:00.000000000 +0000 +++ pam-mysql-0.8.2/debian/patches/Avoid-segfault-on-invalid-SSHA-hash-value.patch 2026-11-17 19:33:30.000000000 +0000 @@ -0,0 +1,27 @@ +From: =?utf-8?q?Ferenc_W=C3=A1gner?= +Date: Thu, 5 Nov 2026 14:42:36 +0100 +Subject: Avoid segfault on invalid SSHA hash value + +When the database entry was too short, salt_length suffered unsigned +underflow and wrapped to a huge positive value, resulting in a +segmentation fault at the dynamic allocation on the next line. +--- + pam_mysql.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/pam_mysql.c b/pam_mysql.c +index 20f6377..2f52c54 100644 +--- a/pam_mysql.c ++++ b/pam_mysql.c +@@ -3849,6 +3849,11 @@ static pam_mysql_err_t pam_mysql_check_passwd(pam_mysql_ctx_t *ctx, + unsigned char* hash; + size_t sha1_size; + Base64Decode(row[0], &hash, &sha1_size); ++ if (sha1_size <= 20) { ++ syslog(LOG_AUTHPRIV | LOG_WARNING, PAM_MYSQL_LOG_PREFIX "wrong SSHA hash format"); ++ err = PAM_MYSQL_ERR_MISMATCH; ++ goto out; ++ } + size_t salt_length = sha1_size - 20; + unsigned char salt[salt_length]; + memcpy(salt, &(hash[20]), salt_length); diff -Nru pam-mysql-0.8.2/debian/patches/SECURITY-correct-PAM_DISALLOW_NULL_AUTHTOK-implementation.patch pam-mysql-0.8.2/debian/patches/SECURITY-correct-PAM_DISALLOW_NULL_AUTHTOK-implementation.patch --- pam-mysql-0.8.2/debian/patches/SECURITY-correct-PAM_DISALLOW_NULL_AUTHTOK-implementation.patch 1970-01-01 00:00:00.000000000 +0000 +++ pam-mysql-0.8.2/debian/patches/SECURITY-correct-PAM_DISALLOW_NULL_AUTHTOK-implementation.patch 2026-11-17 19:33:30.000000000 +0000 @@ -0,0 +1,109 @@ +From: =?utf-8?q?Ferenc_W=C3=A1gner?= +Date: Wed, 4 Nov 2026 01:29:34 +0100 +Subject: SECURITY: correct PAM_DISALLOW_NULL_AUTHTOK implementation + (CVE-2026-124749) + +If an application called PAM with PAM_DISALLOW_NULL_AUTHTOK, users +with a NULL password were authenticated by the pam_mysql module, +contrary to the PAM specification. This bug is now fixed. If the +flag was not passed, users with a NULL password were not +authenticated. This is now relaxed: if the freshly introduced +"nullok" option is enabled in the configuration or on the module +command line, users with a NULL password are authenticated unless the +caller forbids this via the PAM_DISALLOW_NULL_AUTHTOK flag. + +Reported-by: Andrey Vasilevsky +--- + README | 8 ++++++++ + pam_mysql.c | 10 +++++++--- + 2 files changed, 15 insertions(+), 3 deletions(-) + +diff --git a/README b/README +index 99073f2..3e9d7f0 100644 +--- a/README ++++ b/README +@@ -224,6 +224,7 @@ config_file + - users.use_md5 (md5) + - users.where_clause (where) + - users.disconnect_every_operation (disconnect_every_op) *1 ++ - nullok (nullok) + - verbose (verbose) + - log.enabled (sqllog) + - log.table (logtable) +@@ -262,6 +263,13 @@ try_first_pass (true) + + This is available since 0.7pre2. + ++nullok (false) ++ ++ If false, users with a NULL password field are not authenticated. ++ If true, and the calling application did not specify the ++ PAM_DISALLOW_NULL_AUTHTOK flag, users with a NULL password field ++ are authenticated irrespective of the input password. ++ + disconnect_every_op (false) + + By default, pam_mysql keeps connection to the MySQL database until the +diff --git a/pam_mysql.c b/pam_mysql.c +index 11b5349..20f6377 100644 +--- a/pam_mysql.c ++++ b/pam_mysql.c +@@ -271,6 +271,7 @@ typedef struct _pam_mysql_ctx_t { + int verbose; + int use_first_pass; + int try_first_pass; ++ int nullok; + int disconnect_every_op; + char *logtable; + char *logmsgcolumn; +@@ -1524,6 +1525,7 @@ static pam_mysql_option_t options[] = { + PAM_MYSQL_DEF_OPTION(use_323_passwd, &pam_mysql_boolean_opt_accr), + PAM_MYSQL_DEF_OPTION(use_first_pass, &pam_mysql_boolean_opt_accr), + PAM_MYSQL_DEF_OPTION(try_first_pass, &pam_mysql_boolean_opt_accr), ++ PAM_MYSQL_DEF_OPTION(nullok, &pam_mysql_boolean_opt_accr), + PAM_MYSQL_DEF_OPTION(disconnect_every_op, &pam_mysql_boolean_opt_accr), + PAM_MYSQL_DEF_OPTION2(debug, verbose, &pam_mysql_boolean_opt_accr), + { NULL, 0, 0, NULL } +@@ -2585,6 +2587,7 @@ static pam_mysql_option_t pam_mysql_entry_handler_options[] = { + PAM_MYSQL_DEF_OPTION2(log.time_column, logtimecolumn, &pam_mysql_string_opt_accr), + PAM_MYSQL_DEF_OPTION2(users.use_323_password, use_323_passwd, &pam_mysql_boolean_opt_accr), + PAM_MYSQL_DEF_OPTION2(users.disconnect_every_operation, disconnect_every_op, &pam_mysql_boolean_opt_accr), ++ PAM_MYSQL_DEF_OPTION(nullok, &pam_mysql_boolean_opt_accr), + { NULL, 0, 0, NULL } + }; + +@@ -2913,6 +2916,7 @@ static pam_mysql_err_t pam_mysql_init_ctx(pam_mysql_ctx_t *ctx) + ctx->verbose = 0; + ctx->use_first_pass = 0; + ctx->try_first_pass = 1; ++ ctx->nullok = 0; + ctx->disconnect_every_op = 0; + ctx->logtable = NULL; + ctx->logmsgcolumn = NULL; +@@ -3899,7 +3903,7 @@ static pam_mysql_err_t pam_mysql_check_passwd(pam_mysql_ctx_t *ctx, + } + } + } else { +- vresult = null_inhibited; ++ vresult = !ctx->nullok || null_inhibited; + } + + if (vresult == 0) { +@@ -4741,7 +4745,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t * pamh, int flags, + } + + err = pam_mysql_check_passwd(ctx, user, passwd, +- !(flags & PAM_DISALLOW_NULL_AUTHTOK)); ++ !!(flags & PAM_DISALLOW_NULL_AUTHTOK)); + + if (err == PAM_MYSQL_ERR_SUCCESS) { + pam_mysql_sql_log(ctx, "AUTHENTICATION SUCCESS (FIRST_PASS)", user, rhost); +@@ -4832,7 +4836,7 @@ askpass: + } + + err = pam_mysql_check_passwd(ctx, user, passwd, +- !(flags & PAM_DISALLOW_NULL_AUTHTOK)); ++ !!(flags & PAM_DISALLOW_NULL_AUTHTOK)); + + if (err == PAM_MYSQL_ERR_SUCCESS) { + pam_mysql_sql_log(ctx, "AUTHENTICATION SUCCESS", user, rhost); diff -Nru pam-mysql-0.8.2/debian/patches/series pam-mysql-0.8.2/debian/patches/series --- pam-mysql-0.8.2/debian/patches/series 2023-01-30 12:08:26.000000000 +0000 +++ pam-mysql-0.8.2/debian/patches/series 2026-11-17 19:33:30.000000000 +0000 @@ -6,3 +6,5 @@ Get-compat_make_scrambled_password_323-compile.patch The-bundled-crypto-routines-check-WORDS_BIGENDIAN.patch Update-README.patch +SECURITY-correct-PAM_DISALLOW_NULL_AUTHTOK-implementation.patch +Avoid-segfault-on-invalid-SSHA-hash-value.patch diff -Nru pam-mysql-0.8.2/debian/tests/auth pam-mysql-0.8.2/debian/tests/auth --- pam-mysql-0.8.2/debian/tests/auth 2023-01-30 17:28:57.000000000 +0000 +++ pam-mysql-0.8.2/debian/tests/auth 2026-11-17 19:33:30.000000000 +0000 @@ -1,19 +1,19 @@ #!/usr/bin/python3 import PAM +import functools +from pathlib import Path import subprocess import sys -config = { - 'db': 'pam', - 'db_user': 'pam', - 'db_password': 'pampasswd', - 'db_table': 'users', - 'user_column': 'username', - 'password_column': 'password', - 'pam_service': 'pamtest', - 'config_file': '/etc/pam-mysql.conf' -} +db = 'pam' +db_user = 'pam' +db_password = 'pampasswd' +db_table = 'users' +user_column = 'username' +password_column = 'password' +pam_service = 'pamtest' +config_file = Path('/etc/pam-mysql.conf') # The hashes here aren't derived on-the-fly from the password, because # they simulate database field values, which don't change with any @@ -33,33 +33,31 @@ 'sha256' : { 'crypt': 9, 'hash': 'df6555b9bdcb7fbe4fe0f8986a446e6c6f5dbacdca4a36ff288041cd59b4fb5f' }, # printf foopwd | sha256sum } -mysql = subprocess.Popen('mysql', stdin=subprocess.PIPE, text=True) -mysql.communicate('''\ +with subprocess.Popen('mysql', stdin=subprocess.PIPE, text=True) as mysql_client: + users = ','.join(f"('{k}','{v['hash']}')" for k,v in passwords.items()) + maxlen = max(len(rec['hash']) for rec in passwords.values()) + mysql_client.communicate(f'''\ DROP DATABASE IF EXISTS {db}; CREATE DATABASE {db}; USE {db}; CREATE TABLE {db_table} ( {user_column} VARCHAR (10) NOT NULL, - {password_column} VARCHAR ({maxlen}) NOT NULL + {password_column} VARCHAR ({maxlen}) ); INSERT INTO {db_table} ({user_column}, {password_column}) - VALUES {users}; + VALUES ('null', NULL), ('empty', ''), {users}; DROP USER IF EXISTS {db_user}@localhost; CREATE USER {db_user}@localhost IDENTIFIED BY '{db_password}'; GRANT SELECT ON {db}.{db_table} TO {db_user}@localhost; -'''.format(users = ','.join(f"('{k}','{v['hash']}')" for k,v in passwords.items()), - maxlen = max(len(rec['hash']) for rec in passwords.values()), - **config)) - -pam_conf = open('/etc/pam.d/{pam_service}'.format(**config), 'w') -pam_conf.write('''\ -auth required pam_mysql.so config_file={config_file} -'''.format(**config)) -pam_conf.close() - -def write_config_file(conf): - pam_mysql_conf = open(config['config_file'], 'w') - pam_mysql_conf.write('''\ +''') + assert mysql_client.returncode == 0 + +Path(f'/etc/pam.d/{pam_service}').write_text(f'auth required pam_mysql.so config_file={config_file}\n') + +def write_config_file(conf, nullok): + crypt = conf['crypt'] + with open(config_file, 'w') as pam_mysql_conf: + pam_mysql_conf.write(f'''\ users.host = localhost users.database = {db} users.db_user = {db_user} @@ -68,12 +66,14 @@ users.user_column = {user_column} users.password_column = {password_column} users.password_crypt = {crypt} -'''.format(**config, crypt = conf['crypt'])) - if 'md5' in conf: - pam_mysql_conf.write(f'users.use_md5 = {conf["md5"]}\n') - elif '323' in conf: - pam_mysql_conf.write(f'users.use_323_password = {conf["323"]}\n') - pam_mysql_conf.close() +''') + if 'md5' in conf: + pam_mysql_conf.write(f'users.use_md5 = {conf["md5"]}\n') + elif '323' in conf: + pam_mysql_conf.write(f'users.use_323_password = {conf["323"]}\n') + if nullok: + pam_mysql_conf.write('nullok = yes\n') + print(f'Module configured for password_crypt = {crypt}, nullok = {nullok}', flush=True) def pam_conv(auth, query_list, userData): if query_list != [('Password:', PAM.PAM_PROMPT_ECHO_OFF)]: @@ -81,12 +81,12 @@ return None return [(userData,0)] -def good_auth(user, password): +def authenticate(user, password, flags): p = PAM.pam() - p.start(config['pam_service'], user, pam_conv) + p.start(pam_service, user, pam_conv) p.setUserData(password) try: - p.authenticate() + p.authenticate(flags) except PAM.error as err: if err.args == ('Authentication failure', 7): return False @@ -95,22 +95,36 @@ else: return True -successes = 0 -failures = 0 -for user, conf in passwords.items(): - write_config_file(conf) - if good_auth(user, 'foopwd'): - print(f'OK: {user}: correct password accepted') - successes += 1 - else: - print(f'FAIL: {user}: correct password refused') - failures += 1 - if good_auth(user, 'wrong_password'): - print(f'FAIL: {user}: incorrect password accepted') - failures += 1 - else: - print(f'OK: {user}: incorrect password refused') - successes += 1 +def check_and_log(user, password, flags, qualifier, expectation): + accepted = authenticate(user, password, flags) + success = accepted == expectation + print( + f'{"OK" if success else "FAIL"}: {user}: {qualifier} password {"accepted" if accepted else "refused"} under flags {flags}', + flush=True, + ) + return success + +def check_scenarios(crypt, nullok): + for flags in (0, PAM.PAM_DISALLOW_NULL_AUTHTOK): + yield check_and_log(crypt, 'foopwd', flags, 'correct', True) + yield check_and_log(crypt, 'wrong_password', flags, 'invalid', False) + yield check_and_log(crypt, '', flags, 'empty', False) + yield check_and_log('empty', '', flags, 'empty', crypt == 'plain') + yield check_and_log('empty', 'any_password', flags, 'nonempty', False) + yield check_and_log('null', '', flags, 'empty', nullok and flags == 0) + yield check_and_log('null', 'any_password', flags, 'nonempty', nullok and flags == 0) + +def check_configs(): + for crypt, conf in passwords.items(): + for nullok in (False, True): + write_config_file(conf, nullok) + yield from check_scenarios(crypt, nullok) + +checks, successes = functools.reduce( + lambda c, result: (c[0] + 1, c[1] + int(result)), + check_configs(), + (0, 0) +) -print(f'Summary: {successes} successes and {failures} failures') -sys.exit(0 if failures == 0 else 1) +print(f'SUMMARY: ran {checks} tests; {successes} succeeded, {checks - successes} failed') +sys.exit(0 if checks == successes else 1)