public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/proftpd] epel9: Fix some issues in mod_copy (not enabled by default)
@ 2026-11-10 13:05 Paul Howarth
  0 siblings, 0 replies; only message in thread
From: Paul Howarth @ 2026-11-10 13:05 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/proftpd
            Branch : epel9
            Commit : 0412670f5218bff8fc0c1614c845ed2c40adebb0
            Author : Paul Howarth <paul@city-fan.org>
            Date   : 2026-11-10T09:40:22+00:00
            Stats  : +224/-0 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/proftpd/c/0412670f5218bff8fc0c1614c845ed2c40adebb0?branch=epel9

            Log:
            Fix some issues in mod_copy (not enabled by default)

- <Limit READ> configurations were not honored by SITE COPY as they should be
  (GH#2095)
- Fix write restriction bypass via symlink following in mod_copy (GH#2374,
  CVE-2026-119364)

---
diff --git a/proftpd-1.3.9e-gh2095.patch b/proftpd-1.3.9e-gh2095.patch
new file mode 100644
index 0000000..54debae
--- /dev/null
+++ b/proftpd-1.3.9e-gh2095.patch
@@ -0,0 +1,47 @@
+diff --git a/contrib/mod_copy.c b/contrib/mod_copy.c
+index bf725eebae..dd770c029d 100644
+--- a/contrib/mod_copy.c
++++ b/contrib/mod_copy.c
+@@ -571,7 +571,7 @@ MODRET copy_copy(cmd_rec *cmd) {
+     return PR_DECLINED(cmd);
+   }
+ 
+-  if (strncasecmp(cmd->argv[1], "COPY", 5) == 0) {
++  if (strcasecmp(cmd->argv[1], "COPY") == 0) {
+     char *cmd_name, *decoded_path, *from, *to;
+     unsigned char *authenticated;
+ 
+@@ -625,14 +625,31 @@ MODRET copy_copy(cmd_rec *cmd) {
+ 
+     to = dir_canonical_vpath(cmd->tmp_pool, decoded_path);
+ 
++    cmd_name = cmd->argv[0];
++    pr_cmd_set_name(cmd, "SITE_COPY");
++    if (!dir_check(cmd->tmp_pool, cmd, G_READ, from, NULL)) {
++      int xerrno = EPERM;
++
++      pr_cmd_set_name(cmd, cmd_name);
++      pr_log_debug(DEBUG8, "%s %s denied by <Limit> configuration",
++        (char *) cmd->argv[0], from);
++      pr_response_add_err(R_550, "%s: %s", (char *) cmd->argv[2],
++        strerror(xerrno));
++
++      pr_cmd_set_errno(cmd, xerrno);
++      errno = xerrno;
++      return PR_ERROR(cmd);
++    }
++    pr_cmd_set_name(cmd, cmd_name);
++
+     cmd_name = cmd->argv[0];
+     pr_cmd_set_name(cmd, "SITE_COPY");
+     if (!dir_check(cmd->tmp_pool, cmd, G_WRITE, to, NULL)) {
+       int xerrno = EPERM;
+ 
+       pr_cmd_set_name(cmd, cmd_name);
+-      pr_log_debug(DEBUG8, "%s denied by <Limit> configuration",
+-        (char *) cmd->argv[0]);
++      pr_log_debug(DEBUG8, "%s %s denied by <Limit> configuration",
++        (char *) cmd->argv[0], to);
+       pr_response_add_err(R_550, "%s: %s", (char *) cmd->argv[3],
+         strerror(xerrno));
+ 

diff --git a/proftpd-1.3.9e-gh2374.patch b/proftpd-1.3.9e-gh2374.patch
new file mode 100644
index 0000000..53648f5
--- /dev/null
+++ b/proftpd-1.3.9e-gh2374.patch
@@ -0,0 +1,162 @@
+commit 191e11052229004599b00f71400c4ba3f038bbac
+Author: TJ Saunders <tj@castaglia.org>
+Date:   Tue May 19 17:16:11 2026 -0700
+
+    While working on mod_copy, I added a regression test for `<Anonymous>` configurations, and noticed some logging nits, now addressed.
+
+diff --git a/contrib/mod_copy.c b/contrib/mod_copy.c
+index dd770c029..024070911 100644
+--- a/contrib/mod_copy.c
++++ b/contrib/mod_copy.c
+@@ -631,8 +631,8 @@ MODRET copy_copy(cmd_rec *cmd) {
+       int xerrno = EPERM;
+ 
+       pr_cmd_set_name(cmd, cmd_name);
+-      pr_log_debug(DEBUG8, "%s %s denied by <Limit> configuration",
+-        (char *) cmd->argv[0], from);
++      pr_log_debug(DEBUG8, "%s %s %s denied by <Limit> configuration",
++        (char *) cmd->argv[0], (char *) cmd->argv[1], from);
+       pr_response_add_err(R_550, "%s: %s", (char *) cmd->argv[2],
+         strerror(xerrno));
+ 
+@@ -648,8 +648,8 @@ MODRET copy_copy(cmd_rec *cmd) {
+       int xerrno = EPERM;
+ 
+       pr_cmd_set_name(cmd, cmd_name);
+-      pr_log_debug(DEBUG8, "%s %s denied by <Limit> configuration",
+-        (char *) cmd->argv[0], to);
++      pr_log_debug(DEBUG8, "%s %s %s denied by <Limit> configuration",
++        (char *) cmd->argv[0], (char *) cmd->argv[1], to);
+       pr_response_add_err(R_550, "%s: %s", (char *) cmd->argv[3],
+         strerror(xerrno));
+ 
+@@ -697,7 +697,7 @@ MODRET copy_cpfr(cmd_rec *cmd) {
+   }
+ 
+   if (cmd->argc < 3 ||
+-      strncasecmp(cmd->argv[1], "CPFR", 5) != 0) {
++      strcasecmp(cmd->argv[1], "CPFR") != 0) {
+     return PR_DECLINED(cmd);
+   }
+ 
+@@ -743,10 +743,9 @@ MODRET copy_cpfr(cmd_rec *cmd) {
+     int xerrno = EPERM;
+ 
+     pr_cmd_set_name(cmd, cmd_name);
+-    pr_log_debug(DEBUG8, "%s denied by <Limit> configuration",
+-      (char *) cmd->argv[0]);
+-    pr_response_add_err(R_550, "%s: %s", (char *) cmd->argv[3],
+-      strerror(xerrno));
++    pr_log_debug(DEBUG8, "%s %s %s denied by <Limit> configuration",
++      (char *) cmd->argv[0], (char *) cmd->argv[1], path);
++    pr_response_add_err(R_550, "%s: %s", path, strerror(xerrno));
+ 
+     pr_cmd_set_errno(cmd, xerrno);
+     errno = xerrno;
+@@ -806,7 +805,7 @@ MODRET copy_cpfr(cmd_rec *cmd) {
+ 
+ MODRET copy_cpto(cmd_rec *cmd) {
+   register unsigned int i;
+-  const char *from, *to = "";
++  const char *from, *to = "", *resolved_to;
+   char *cmd_name;
+   unsigned char *authenticated = NULL;
+ 
+@@ -815,7 +814,7 @@ MODRET copy_cpto(cmd_rec *cmd) {
+   }
+ 
+   if (cmd->argc < 3 ||
+-      strncasecmp(cmd->argv[1], "CPTO", 5) != 0) {
++      strcasecmp(cmd->argv[1], "CPTO") != 0) {
+     return PR_DECLINED(cmd);
+   }
+ 
+@@ -864,16 +863,16 @@ MODRET copy_cpto(cmd_rec *cmd) {
+     to = pstrcat(cmd->tmp_pool, to, *to ? " " : "", decoded_path, NULL);
+   }
+ 
+-  to = dir_canonical_vpath(cmd->tmp_pool, to);
++  resolved_to = dir_canonical_vpath(cmd->tmp_pool, to);
+ 
+   cmd_name = cmd->argv[0];
+   pr_cmd_set_name(cmd, "SITE_CPTO");
+-  if (!dir_check(cmd->tmp_pool, cmd, G_WRITE, to, NULL)) {
++  if (!dir_check(cmd->tmp_pool, cmd, G_WRITE, resolved_to, NULL)) {
+     int xerrno = EPERM;
+ 
+     pr_cmd_set_name(cmd, cmd_name);
+-    pr_log_debug(DEBUG8, "%s denied by <Limit> configuration",
+-      (char *) cmd->argv[0]);
++    pr_log_debug(DEBUG8, "%s %s %s denied by <Limit> configuration",
++      (char *) cmd->argv[0], (char *) cmd->argv[1], to);
+     pr_response_add_err(R_550, "%s: %s", to, strerror(xerrno));
+ 
+     pr_cmd_set_errno(cmd, xerrno);
+@@ -882,12 +881,12 @@ MODRET copy_cpto(cmd_rec *cmd) {
+   }
+   pr_cmd_set_name(cmd, cmd_name);
+ 
+-  if (copy_paths(cmd->tmp_pool, from, to) < 0) {
++  if (copy_paths(cmd->tmp_pool, from, resolved_to) < 0) {
+     int xerrno = errno;
+     const char *err_code = R_550;
+ 
+     pr_log_debug(DEBUG7, MOD_COPY_VERSION
+-      ": error copying '%s' to '%s': %s", from, to, strerror(xerrno));
++      ": error copying '%s' to '%s': %s", from, resolved_to, strerror(xerrno));
+ 
+     /* Check errno for EDQOUT (or the most appropriate alternative).
+      * (I hate the fact that FTP has a special response code just for
+@@ -912,8 +911,8 @@ MODRET copy_cpto(cmd_rec *cmd) {
+         break;
+     }
+ 
+-    pr_response_add_err(err_code, "%s: %s", (char *) cmd->argv[1],
+-      strerror(xerrno));
++    pr_response_add_err(err_code, "%s %s: %s", (char *) cmd->argv[0],
++      (char *) cmd->argv[1], strerror(xerrno));
+ 
+     pr_cmd_set_errno(cmd, xerrno);
+     errno = xerrno;
+From c41691f8981f98081fcb8a535c3c21b06a3f04af Mon Sep 17 00:00:00 2001
+From: TJ Saunders <tj@castaglia.org>
+Date: Sat, 17 Oct 2026 13:12:56 -0700
+Subject: [PATCH] Issue #2374: Resolve the destination path in order to handle
+ any potential symlinks, and use the resolved path for <Limit> checks.
+
+---
+ contrib/mod_copy.c | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/contrib/mod_copy.c b/contrib/mod_copy.c
+index 51d62107e5..70f704f39a 100644
+--- a/contrib/mod_copy.c
++++ b/contrib/mod_copy.c
+@@ -593,7 +593,12 @@ MODRET copy_copy(cmd_rec *cmd) {
+       return PR_ERROR(cmd);
+     }
+ 
+-    to = dir_canonical_vpath(cmd->tmp_pool, decoded_path);
++    pr_fs_clear_cache2(decoded_path);
++    to = dir_realpath(cmd->tmp_pool, decoded_path);
++    if (to == NULL) {
++      /* Try using dir_best_path(), as xfer_pre_stor() does. */
++      to = dir_best_path(cmd->tmp_pool, decoded_path);
++    }
+ 
+     cmd_name = cmd->argv[0];
+     pr_cmd_set_name(cmd, "SITE_COPY");
+@@ -833,7 +838,12 @@ MODRET copy_cpto(cmd_rec *cmd) {
+     to = pstrcat(cmd->tmp_pool, to, *to ? " " : "", decoded_path, NULL);
+   }
+ 
+-  resolved_to = dir_canonical_vpath(cmd->tmp_pool, to);
++  pr_fs_clear_cache2(to);
++  resolved_to = dir_realpath(cmd->tmp_pool, to);
++  if (resolved_to == NULL) {
++    /* Try using dir_best_path(), as xfer_pre_stor() does. */
++    resolved_to = dir_best_path(cmd->tmp_pool, to);
++  }
+ 
+   cmd_name = cmd->argv[0];
+   pr_cmd_set_name(cmd, "SITE_CPTO");

diff --git a/proftpd.spec b/proftpd.spec
index e508eb2..3d07539 100644
--- a/proftpd.spec
+++ b/proftpd.spec
@@ -79,6 +79,8 @@ Patch26:		https://github.com/user-attachments/files/30205410/mod_sftp-1.3.8d-iss
 Patch27:		https://github.com/proftpd/proftpd/commit/baf4b792.patch
 Patch28:		https://github.com/user-attachments/files/30205541/mod_sftp-1.3.8d-issue2190.patch
 Patch29:		mod_sftp-1.3.8d-issue1959.patch
+Patch30:		proftpd-1.3.9e-gh2095.patch
+Patch31:		proftpd-1.3.9e-gh2374.patch
 
 BuildRequires:		coreutils
 BuildRequires:		gcc
@@ -336,6 +338,14 @@ sed -i -e '/^[[:space:]]*TLSCipherSuite[[:space:]]*PROFILE=SYSTEM$/d' mod_tls.co
 # https://bugzilla.redhat.com/show_bug.cgi?id=2563077
 %patch -P 29 -p1
 
+# <Limit READ> configurations were not honored by SITE COPY as they should be
+# https://github.com/proftpd/proftpd/issues/2095
+%patch -P 30 -p1 -b .gh2095
+
+# Fix write restriction bypass via symlink following in mod_copy (CVE-2026-119364)
+# https://github.com/proftpd/proftpd/issues/2374
+%patch -P 31 -p1 -b .gh2374
+
 # Tweak logrotate script for systemd compatibility (#802178)
 %if (0%{?rhel} && 0%{?rhel} <= 7) || (0%{?fedora} && 0%{?fedora} <= 23)
 sed -i -e '/killall/s/test.*/systemctl reload proftpd.service/' \
@@ -586,6 +596,11 @@ fi
 * Thu Oct 29 2026 Paul Howarth <paul@city-fan.org> - 1.3.8d-5
 - Fix file descriptor leak in mod_sftp when reading OpenSSH-format SFTPHostKey
   file (rhbz#2563077, https://github.com/proftpd/proftpd/issues/1959)
+- Fix some issues in mod_copy (not enabled by default)
+  - <Limit READ> configurations were not honored by SITE COPY as they should be
+    (GH#2095)
+  - Fix write restriction bypass via symlink following in mod_copy (GH#2374,
+    CVE-2026-119364)
 
 * Wed Jul 22 2026 Paul Howarth <paul@city-fan.org> - 1.3.8d-4
 - Address another avenue for SQL injection, via custom SQLUserInfo queries

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-10 13:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 13:05 [rpms/proftpd] epel9: Fix some issues in mod_copy (not enabled by default) Paul Howarth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox