Bug 2563077 - proftpd: mod_sftp leaks an fd per SFTPHostKey on every reload (upstream #1959)
Summary: proftpd: mod_sftp leaks an fd per SFTPHostKey on every reload (upstream #1959)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: proftpd
Version: epel9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Paul Howarth
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2026-10-28 17:57 UTC by Gary T. Giesen
Modified: 2026-11-19 01:25 UTC (History)
2 users (show)

Fixed In Version: proftpd-1.3.8d-5.el9
Clone Of:
Environment:
Last Closed: 2026-11-19 01:25:25 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Backport of the upstream #1959 fix to 1.3.8d (387 bytes, patch)
2026-10-28 17:57 UTC, Gary T. Giesen
no flags Details | Diff

Description Gary T. Giesen 2026-10-28 17:57:02 UTC
Description of problem:
get_passphrase() in contrib/mod_sftp/keys.c opens each SFTPHostKey file every time the configuration is parsed. For PEM keys the fd is closed by fclose(), but for OpenSSH-format keys it is never closed. The EL9 OpenSSH host keys (/etc/ssh/ssh_host_*_key) are all OpenSSH format, so a config that uses them leaks one fd per host key on every reload.

This is upstream https://github.com/proftpd/proftpd/issues/1959, fixed in 1.3.9a (df5928e9 on the 1.3.9 branch, 53019a37 on master). It was not backported to 1.3.8, so proftpd-1.3.8d-4.el9 still leaks. EPEL 10.1 has 1.3.9a and is fixed.

When the master reaches its fd limit (1024 by default) the next reload fails with "Too many open files", and since restart_daemon() exits with status 0 when the config can't be re-read, systemd treats it as a clean stop and Restart=on-failure doesn't bring it back. We hit this on several EL9 servers that were reloaded every 6 hours by a certbot cron job: each one stopped roughly 84 days after it was started.

Version-Release number of selected component (if applicable):
proftpd-1.3.8d-4.el9 (also seen with 1.3.8d-1.el9)

How reproducible:
Always

Steps to Reproduce:
1. Enable mod_sftp with:
     SFTPHostKey /etc/ssh/ssh_host_ecdsa_key
     SFTPHostKey /etc/ssh/ssh_host_ed25519_key
     SFTPHostKey /etc/ssh/ssh_host_rsa_key
2. systemctl start proftpd
3. ls -l /proc/$(cat /run/proftpd/proftpd.pid)/fd | grep -c ssh_host
4. systemctl reload proftpd a few times and repeat step 3

Actual results:
The count goes up by 3 on every reload.

Expected results:
It stays the same.

Additional info:
The upstream commit doesn't apply to 1.3.8d as-is. In 1.3.9 the PEM path reads the key through a BIO, so upstream closes the fd unconditionally; in 1.3.8d the PEM path wraps the fd with fdopen(), and fclose() already closes it. The attached patch closes the fd only when there is no FILE handle, i.e. for OpenSSH-format keys.

I rebuilt proftpd-1.3.8d-4.el9 with it added as Patch29 on AlmaLinux 9 (%check api-tests passed) and ran the same test against both builds, with an extra PEM-format ECDSA P-384 key configured so both code paths were exercised:

  1.3.8d-4.el9:           master fds 9 -> 39 after 10 reloads (host key fds 3 -> 33)
  1.3.8d-4.el9 + patch:   master fds 6 -> 6 after 10 reloads (host key fds 0 -> 0)

With both builds, after the 10 reloads an SFTP login and upload worked with HostKeyAlgorithms restricted to each of ssh-ed25519, ecdsa-sha2-nistp256, rsa-sha2-512 and ecdsa-sha2-nistp384 (the PEM key), and FTPS still negotiated TLS 1.3.

Comment 1 Gary T. Giesen 2026-10-28 17:57:03 UTC
Created attachment 2162390 [details]
Backport of the upstream #1959 fix to 1.3.8d

Comment 2 Fedora Update System 2026-11-10 16:02:43 UTC
FEDORA-EPEL-2026-4b9f963588 (proftpd-1.3.8d-5.el9) has been submitted as an update to Fedora EPEL 9.
https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2026-4b9f963588

Comment 3 Paul Howarth 2026-11-10 16:10:09 UTC
This update includes your patch (thanks) plus some other upstream fixes for a few CVEs, one of which is in mod_sftp, so it would be good to confirm that sftp still works OK for you.

Comment 4 Fedora Update System 2026-11-11 02:27:31 UTC
FEDORA-EPEL-2026-4b9f963588 has been pushed to the Fedora EPEL 9 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2026-4b9f963588

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Gary T. Giesen 2026-11-11 07:07:10 UTC
Tested in AlmaLinux 9.8 containers against 1.3.8d-4.el9, using the configuration
from our production servers: mod_sftp with mod_sftp_pam, the three OpenSSH-format
host keys from /etc/ssh plus an extra PEM ECDSA P-384 key, and mod_tls.

- fd leak (bug 2563077): with -5 the master stays at 6 fds after 10 SIGHUPs; with
  -4 it goes from 9 to 39.
- SFTP upload and download with matching checksums using each of ssh-ed25519,
  ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 (the PEM key), rsa-sha2-512 and
  rsa-sha2-256, with keyboard-interactive (PAM) and password auth. SCP (scp -O) and
  FTPS (TLS 1.3) also work. All of it was run again after the reloads with the same
  results.
- copy-file (CVE-2026-119147): copy-file into a directory under <Limit WRITE>
  DenyAll succeeds with -4 and is refused with -5. copy-file to a writable location
  still works.

We don't load mod_copy or mod_rewrite, so I haven't tested those fixes.

Thanks for including the patch.

Comment 6 Paul Howarth 2026-11-11 08:19:31 UTC
Thanks so much for your thorough testing!

Comment 7 Fedora Update System 2026-11-19 01:25:25 UTC
FEDORA-EPEL-2026-4b9f963588 (proftpd-1.3.8d-5.el9) has been pushed to the Fedora EPEL 9 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.