[Git][debian-proftpd-team/proftpd][master] 2 commits: Add patches for Issue #2503 / Issue #2505.

Hilmar Preuße (@hilmar) gitlab at salsa.debian.org
Tue Nov 24 21:56:38 GMT 2026



Hilmar Preuße pushed to branch master at Debian ProFTPD Team / proftpd


Commits:
fc373579 by Hilmar Preuße at 2026-11-24T22:17:54+01:00
Add patches for Issue #2503 / Issue #2505.

- - - - -
dfd8403d by Hilmar Preuße at 2026-11-24T22:55:12+01:00
Finalize for upload.

- - - - -


4 changed files:

- debian/changelog
- + debian/patches/6fcb94dc5e9951d48fe5c9a5fdbf39bed594e487.diff
- + debian/patches/95b21506fefd06d2059e506ea26f6a71cea89d1d.diff
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,10 +1,11 @@
-proftpd-dfsg (1.3.9f~dfsg-1) UNRELEASED; urgency=medium
+proftpd-dfsg (1.3.9f~dfsg-1) unstable; urgency=medium
 
   * New upstream release, disable obsolete patches.
-    - add post release patches for Issue #2497 / Issue #2492 / Issue #2484.
+    - add post release patches for Issue #2497 / Issue #2492 / Issue #2484 /
+      Issue #2503 / Issue #2505.
   * Display tests/api-tests.log compressed / base64 in case of test failure.
 
- -- Hilmar Preuße <hille42 at debian.org>  Thu, 12 Nov 2026 23:54:51 +0100
+ -- Hilmar Preuße <hille42 at debian.org>  Tue, 24 Nov 2026 22:54:51 +0100
 
 proftpd-dfsg (1.3.9e~dfsg-3) unstable; urgency=high
 


=====================================
debian/patches/6fcb94dc5e9951d48fe5c9a5fdbf39bed594e487.diff
=====================================
@@ -0,0 +1,222 @@
+From 6fcb94dc5e9951d48fe5c9a5fdbf39bed594e487 Mon Sep 17 00:00:00 2001
+From: TJ Saunders <tj at castaglia.org>
+Date: Mon, 23 Nov 2026 13:56:43 -0800
+Subject: [PATCH] Issue #2503: Ensure that when mod_auth_otp and mod_sql check
+ credentials, they are checking credentials for which they themselves are
+ responsible.
+
+---
+ contrib/mod_auth_otp/mod_auth_otp.c | 78 +++++++++++++++++++++++++++++
+ contrib/mod_sql.c                   | 35 +++++++++++--
+ 2 files changed, 108 insertions(+), 5 deletions(-)
+
+--- proftpd.orig/contrib/mod_auth_otp/mod_auth_otp.c
++++ proftpd/contrib/mod_auth_otp/mod_auth_otp.c
+@@ -42,6 +42,11 @@
+ 
+ #define AUTH_OTP_VERIFICATION_CODE_PROMPT	"Verification code: "
+ 
++/* We currently hardcode the assumption that generated and valid OTPs
++ * are 6 digits.
++ */
++#define AUTH_OTP_CODE_LEN			6
++
+ /* From src/response.c */
+ extern pr_response_t *resp_list;
+ 
+@@ -56,6 +61,7 @@
+ static struct auth_otp_db *dbh = NULL;
+ static config_rec *auth_otp_db_config = NULL;
+ static int auth_otp_auth_code = PR_AUTH_NOPWD;
++static int auth_otp_found_user_entry = FALSE;
+ 
+ /* Necessary prototypes */
+ static int auth_otp_sess_init(void);
+@@ -399,6 +405,8 @@
+         strerror(xerrno));
+     }
+ 
++    auth_otp_found_user_entry = FALSE;
++
+     /* If there was no entry found in the table (errno = ENOENT), should we
+      * returned ERROR or DECLINED?
+      *
+@@ -427,6 +435,8 @@
+     return 0;
+   }
+ 
++  auth_otp_found_user_entry = TRUE;
++
+   res = check_otp_code(p, user, user_otp, secret, secret_len, counter);
+   if (res == 0) {
+     pr_memscrub((char *) secret, secret_len);
+@@ -615,7 +625,9 @@
+ }
+ 
+ MODRET auth_otp_chkpass(cmd_rec *cmd) {
++  register unsigned int i;
+   const char *real_otp, *user, *user_otp;
++  size_t otp_len = 0;
+ 
+   if (auth_otp_engine == FALSE) {
+     return PR_DECLINED(cmd);
+@@ -631,6 +643,58 @@
+     return PR_DECLINED(cmd);
+   }
+ 
++  /* We should only be comparing OTP codes, and not any other kind of text;
++   * other auth modules can handle other text; see Issue #2503.
++   */
++  otp_len = strlen(user_otp);
++  if (otp_len != AUTH_OTP_CODE_LEN) {
++    pr_trace_msg(trace_channel, 19,
++      "client provided non-OTP credential (%lu bytes rather than expected 6), "
++      "declining", (unsigned long) otp_len);
++    return PR_DECLINED(cmd);
++  }
++
++  /* Perhps the client provided a 6 byte credential; we need to ensure that
++   * it is comprised of all digits for it to be a potential OTP code.
++   */
++  for (i = 0; i < otp_len; i++) {
++    if (!PR_ISDIGIT(user_otp[i])) {
++      pr_trace_msg(trace_channel, 19, "%s",
++        "client provided non-OTP credential (found non-digit character), "
++        "declining");
++      return PR_DECLINED(cmd);
++    }
++  }
++
++  otp_len = strlen(real_otp);
++  if (otp_len != AUTH_OTP_CODE_LEN) {
++    pr_trace_msg(trace_channel, 21, "%s",
++      "actual credential is non-OTP text, declining");
++    return PR_DECLINED(cmd);
++  }
++
++  /* Perhps the real credentil is 6 bytes; we need to ensure that it is
++   * comprised of all digits for it to be a potential OTP code.
++   */
++  for (i = 0; i < otp_len; i++) {
++    if (!PR_ISDIGIT(user_otp[i])) {
++      pr_trace_msg(trace_channel, 21, "%s",
++        "actual credential is non-OTP text, declining");
++      return PR_DECLINED(cmd);
++    }
++  }
++
++  /* One final check: make sure we found an entry for the user in the
++   * AuthOTPTable.  If we did, then the actual credential is mostly likely
++   * one we provisioned.  Otherwise, it still could be something from some
++   * other auth source, and we don't want to be handling it (Issue #2503).
++   */
++  if (auth_otp_found_user_entry == FALSE) {
++    pr_trace_msg(trace_channel, 21, "%s",
++      "no entry found for user in table, declining");
++    return PR_DECLINED(cmd);
++  }
++
+   if (strcmp(real_otp, user_otp) == 0) {
+     return PR_HANDLED(cmd);
+   }
+@@ -889,6 +953,15 @@
+   return PR_DECLINED(cmd);
+ }
+ 
++MODRET auth_otp_reset_found(cmd_rec *cmd) {
++  if (auth_otp_engine == FALSE) {
++    return PR_DECLINED(cmd);
++  }
++
++  auth_otp_found_user_entry = FALSE;
++  return PR_DECLINED(cmd);
++}
++
+ /* Event listeners
+  */
+ 
+@@ -1108,6 +1181,11 @@
+   { POST_CMD,		C_USER, G_NONE,	auth_otp_post_user,	FALSE, FALSE },
+   { POST_CMD,		C_PASS, G_NONE,	auth_otp_post_pass,	FALSE, FALSE },
+   { POST_CMD_ERR,	C_PASS, G_NONE,	auth_otp_post_pass,	FALSE, FALSE },
++
++  { PRE_CMD,		C_PASS,	G_NONE,	auth_otp_reset_found,	FALSE, FALSE },
++  { POST_CMD,		C_PASS,	G_NONE,	auth_otp_reset_found,	FALSE, FALSE },
++  { POST_CMD_ERR,	C_PASS,	G_NONE,	auth_otp_reset_found,	FALSE, FALSE },
++
+   { 0, NULL },
+ };
+ 
+--- proftpd.orig/contrib/mod_sql.c
++++ proftpd/contrib/mod_sql.c
+@@ -141,6 +141,7 @@
+ static cmdtable *sql_set_backend(const char *name);
+ 
+ static pool *sql_pool = NULL;
++static int sql_found_user_entry = FALSE;
+ static const char *trace_channel = "sql";
+ 
+ /*
+@@ -1180,6 +1181,13 @@
+     return PR_ERROR_INT(cmd, PR_AUTH_BADPWD);
+   }
+ 
++  if (sql_found_user_entry == FALSE) {
++    /* If we didn't find a user entry, we should not be handling these
++     * credentials (Issue #2503).
++     */
++    return PR_DECLINED(cmd);
++  }
++
+   if (strcmp(plaintext, ciphertext) == 0) {
+     return PR_HANDLED(cmd);
+   }
+@@ -2826,6 +2834,15 @@
+   return PR_DECLINED(cmd);
+ }
+ 
++MODRET sql_reset_found(cmd_rec *cmd) {
++  if (cmap.engine == 0) {
++    return PR_DECLINED(cmd);
++  }
++
++  sql_found_user_entry = FALSE;
++  return PR_DECLINED(cmd);
++}
++
+ static int resolve_numeric_val(cmd_rec *cmd, const char *val) {
+   int idx = -1;
+   unsigned int n;
+@@ -4318,12 +4335,16 @@
+   lpw.pw_gid = -1;
+   lpw.pw_name = cmd->argv[0];
+ 
+-  if ((pw = sql_getpasswd(cmd, &lpw)) &&
+-      !pr_auth_check(cmd->tmp_pool, pw->pw_passwd, cmd->argv[0],
++  pw = sql_getpasswd(cmd, &lpw);
++  if (pw != NULL) {
++    sql_found_user_entry = TRUE;
++
++    if (!pr_auth_check(cmd->tmp_pool, pw->pw_passwd, cmd->argv[0],
+         cmd->argv[1])) {
+-    sql_log(DEBUG_FUNC, "%s", "<<< cmd_auth");
+-    session.auth_mech = "mod_sql.c";
+-    return PR_HANDLED(cmd);
++      sql_log(DEBUG_FUNC, "%s", "<<< cmd_auth");
++      session.auth_mech = "mod_sql.c";
++      return PR_HANDLED(cmd);
++    }
+   }
+ 
+   sql_log(DEBUG_FUNC, "%s", "<<< cmd_auth");
+@@ -6906,6 +6927,10 @@
+   { LOG_CMD,		C_ANY,	G_NONE,	log_master,	FALSE,	FALSE },
+   { LOG_CMD_ERR,	C_ANY,	G_NONE,	err_master,	FALSE,	FALSE },
+ 
++  { PRE_CMD,		C_PASS,	G_NONE, sql_reset_found, FALSE,	FALSE },
++  { POST_CMD,		C_PASS,	G_NONE, sql_reset_found, FALSE,	FALSE },
++  { POST_CMD_ERR,	C_PASS,	G_NONE, sql_reset_found, FALSE,	FALSE },
++
+   /* Module hooks */
+   { HOOK,	"sql_change",		G_NONE,	sql_change,	FALSE, FALSE },
+   { HOOK,	"sql_cleanup",		G_NONE, sql_cleanup,	FALSE, FALSE },


=====================================
debian/patches/95b21506fefd06d2059e506ea26f6a71cea89d1d.diff
=====================================
@@ -0,0 +1,123 @@
+From 95b21506fefd06d2059e506ea26f6a71cea89d1d Mon Sep 17 00:00:00 2001
+From: TJ Saunders <tj at castaglia.org>
+Date: Tue, 24 Nov 2026 11:16:25 -0800
+Subject: [PATCH] Issue #2505: Address the `CreateHome` regression by
+ performing the `rename(2)` with privileges as needed.
+
+---
+ include/fsio.h   |  5 +++--
+ src/fsio.c       | 13 +++++++++++--
+ src/mkhome.c     |  1 +
+ tests/api/fsio.c | 38 ++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 53 insertions(+), 4 deletions(-)
+
+diff --git a/include/fsio.h b/include/fsio.h
+index 018e8b274..a942aed56 100644
+--- a/include/fsio.h
++++ b/include/fsio.h
+@@ -266,8 +266,9 @@ int pr_fsio_rename(const char *, const char *);
+ int pr_fsio_smkdir(pool *, const char *, mode_t, uid_t, gid_t);
+ int pr_fsio_smkdir2(pool *, const char *, mode_t, uid_t, gid_t, int);
+ /* smkdir flags */
+-#define PR_FSIO_SMKDIR_FL_IGNORE_UMASK	0x001
+-#define PR_FSIO_SMKDIR_FL_NO_ROOT_PRIVS	0x002
++#define PR_FSIO_SMKDIR_FL_IGNORE_UMASK		0x001
++#define PR_FSIO_SMKDIR_FL_NO_ROOT_PRIVS		0x002
++#define PR_FSIO_SMKDIR_FL_RENAME_WITH_PRIVS	0x004
+ 
+ int pr_fsio_unlink(const char *);
+ pr_fh_t *pr_fsio_open(const char *, int);
+diff --git a/src/fsio.c b/src/fsio.c
+index 8a0d9bd65..0234ca74f 100644
+--- a/src/fsio.c
++++ b/src/fsio.c
+@@ -4698,10 +4698,19 @@ int pr_fsio_smkdir2(pool *p, const char *path, mode_t mode, uid_t uid,
+     /* Use rename(2) to move the temporary directory into place at the
+      * target path.
+      */
++
++    if (flags & PR_FSIO_SMKDIR_FL_RENAME_WITH_PRIVS) {
++      PRIVS_ROOT
++    }
++
+     res = rename(tmpl_path, path);
+-    if (res < 0) {
+-      xerrno = errno;
++    xerrno = errno;
+ 
++    if (flags & PR_FSIO_SMKDIR_FL_RENAME_WITH_PRIVS) {
++      PRIVS_RELINQUISH
++    }
++
++    if (res < 0) {
+       pr_log_pri(PR_LOG_INFO, "renaming '%s' to '%s' failed: %s", tmpl_path,
+         path, strerror(xerrno));
+ 
+diff --git a/src/mkhome.c b/src/mkhome.c
+index fbd8c62a3..30a06b1c2 100644
+--- a/src/mkhome.c
++++ b/src/mkhome.c
+@@ -314,6 +314,7 @@ int create_home(pool *p, const char *home, const char *user, uid_t uid,
+     PRIVS_USER
+ 
+   } else {
++    smkdir_flags |= PR_FSIO_SMKDIR_FL_RENAME_WITH_PRIVS;
+     PRIVS_ROOT
+   }
+ 
+diff --git a/tests/api/fsio.c b/tests/api/fsio.c
+index 376798e47..0f2b22dc7 100644
+--- a/tests/api/fsio.c
++++ b/tests/api/fsio.c
+@@ -5156,6 +5156,43 @@ START_TEST (fsio_smkdir2_no_root_privs_test) {
+ }
+ END_TEST
+ 
++START_TEST (fsio_smkdir2_rename_with_privs_test) {
++  int res, flags;
++  const char *path;
++  mode_t mode = 0755;
++  uid_t uid = getuid();
++  gid_t gid = getgid();
++
++  flags = PR_FSIO_SMKDIR_FL_RENAME_WITH_PRIVS;
++  path = fsio_testdir_path;
++  res = pr_fsio_smkdir2(p, path, mode, uid, gid, flags);
++  ck_assert_msg(res == 0, "Failed to securely create '%s': %s",
++    fsio_testdir_path, strerror(errno));
++  (void) pr_fsio_rmdir(fsio_testdir_path);
++
++#if defined(HAVE_MKDTEMP)
++  res = pr_fsio_set_use_mkdtemp(FALSE);
++  ck_assert_msg(res == TRUE, "Expected TRUE, got %d", res);
++
++  res = pr_fsio_smkdir2(p, path, mode, uid, gid, flags);
++  ck_assert_msg(res == 0, "Failed to securely create '%s': %s",
++    fsio_testdir_path, strerror(errno));
++  (void) pr_fsio_rmdir(fsio_testdir_path);
++
++  res = pr_fsio_set_use_mkdtemp(TRUE);
++  ck_assert_msg(res == FALSE, "Expected FALSE, got %d", res);
++#else
++  res = pr_fsio_set_use_mkdtemp(TRUE);
++  ck_assert_msg(res == FALSE, "Expected FALSE, got %d", res);
++
++  res = pr_fsio_set_use_mkdtemp(FALSE);
++  ck_assert_msg(res == FALSE, "Expected FALSE, got %d", res);
++#endif /* HAVE_MKDTEMP */
++
++  (void) pr_fsio_rmdir(fsio_testdir_path);
++}
++END_TEST
++
+ START_TEST (fsio_getpipebuf_test) {
+   char *res;
+   int fd = -1;
+@@ -5502,6 +5539,7 @@ Suite *tests_get_fsio_suite(void) {
+   tcase_add_test(testcase, fsio_smkdir_test);
+   tcase_add_test(testcase, fsio_smkdir2_ignore_umask_test);
+   tcase_add_test(testcase, fsio_smkdir2_no_root_privs_test);
++  tcase_add_test(testcase, fsio_smkdir2_rename_with_privs_test);
+   tcase_add_test(testcase, fsio_getpipebuf_test);
+   tcase_add_test(testcase, fsio_gets_test);
+   tcase_add_test(testcase, fsio_getline_test);


=====================================
debian/patches/series
=====================================
@@ -23,3 +23,5 @@ d1fd858b50894388089a1d275c635bcef17f98a2.diff
 f1ce424cab3d2a9054698e1eede9217c26fc2296.diff
 1c801766517a854b76ae90fa9db5d093db7b60fb.diff
 18535936b37b4b789e37242b4433d069df4689a7.diff
+6fcb94dc5e9951d48fe5c9a5fdbf39bed594e487.diff
+95b21506fefd06d2059e506ea26f6a71cea89d1d.diff



View it on GitLab: https://salsa.debian.org/debian-proftpd-team/proftpd/-/compare/fc4c31ab1f420355b97c4ffdfc5d2ed7afd09b35...dfd8403d97eeb4c6cd661fa78ff02eda1ed058a5

-- 
View it on GitLab: https://salsa.debian.org/debian-proftpd-team/proftpd/-/compare/fc4c31ab1f420355b97c4ffdfc5d2ed7afd09b35...dfd8403d97eeb4c6cd661fa78ff02eda1ed058a5
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help




More information about the Pkg-proftpd-maintainers mailing list