/

CVE-2026-42167

Severity:

HIGH RISK

(8.1)

SQL Injection in ProFTPD mod_sql

CVE-2026-42167

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Remote Code Execution via SQL Injection

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

ProFTPD's mod_sql module before 1.3.10rc1 is vulnerable to SQL injection when USER commands are logged using expansions like %U and the username is written directly into SQL queries.

In environments where the SQL backend supports command execution (such as COPY TO PROGRAM), a remote attacker can supply a crafted FTP username that leads to arbitrary command execution on the server during logging.

Affected context

The vulnerability manifests in ProFTPD deployments that:

  • Use mod_sql for logging or accounting, and
  • Log USER requests with dynamic expansions (e.g., %U for username) into SQL-backed tables, and
  • Employ a SQL backend or configuration that permits server-side command execution (e.g., SQL dialects/features such as COPY TO PROGRAM or similar mechanisms).

It is particularly relevant when the SQL statements used for logging are constructed through string concatenation or unparameterized templates that embed user-controlled data.

Exploit preconditions

  • Attack surface: Remote, over the FTP control channel (USER command).
  • Required access: Ability to connect to the FTP service and send arbitrary USER values (no valid credentials required).
  • Trigger point: Processing and logging of the USER command when mod_sql formats an SQL statement using expansions like %U.
  • Why exploitation is possible: The username is interpolated directly into SQL log statements without proper parameterization or escaping. If the SQL backend or schema allows statements that can trigger OS-level commands, injected SQL fragments from the username can cause arbitrary command execution during the logging operation.

Why this happens

The root cause is the unsafe construction of SQL statements from untrusted input within the logging path of mod_sql.

Specifically, ProFTPD is configured to log FTP USER commands using expansion variables (such as %U) that are substituted directly into SQL strings. Instead of using prepared statements or parameter binding, the implementation relies on string concatenation, allowing crafted usernames to break out of the intended value context and inject arbitrary SQL.

This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where user-controlled data is embedded in SQL commands without adequate sanitization or parameterization, and is exacerbated here by SQL dialect features that enable command execution from within SQL queries.

Potential impact

  • Remote execution of arbitrary OS commands on the ProFTPD host (when supported by the SQL backend).
  • Full compromise of the FTP server process and potentially the underlying operating system account.
  • Unauthorized access to or modification of data in the SQL backend (e.g., credential records, audit logs).
  • Tampering with or erasure of audit trails and FTP activity logs.
  • Use of the compromised FTP server as a foothold for lateral movement within the network.

General mitigation guidance

Effective mitigation focuses on eliminating SQL injection in logging paths and limiting what the SQL backend is allowed to do:

  • Use parameterized queries or prepared statements for all mod_sql interactions, including logging and accounting operations, so that username data is always bound as a value, not concatenated into query text.
  • Avoid constructing SQL from formatted strings containing expansions like %U directly in query templates; instead, feed such values into bound parameters.
  • Configure the SQL backend to disable or restrict features that allow command execution from SQL (e.g., COPY TO PROGRAM, external procedures, or similar capabilities) where not strictly required.
  • Apply principle of least privilege to the database user used by ProFTPD, granting only the minimal set of permissions necessary for logging and authentication operations.
  • Treat all log-related data paths as untrusted input and subject them to the same security controls as primary application data, including input validation and escaping where parameterization is not possible.

How teams detect issues like this

Organizations can identify and monitor for this class of vulnerability through:

  • Static analysis and configuration review of ProFTPD and mod_sql configuration files, looking for logging or SQL templates that interpolate expansions like %U directly into query strings.
  • Code review of custom modules or patches that interface ProFTPD with SQL backends, ensuring that all variables derived from FTP commands are passed through parameterized queries.
  • Database-side policy and monitoring, including:
  • Searching for queries that contain dynamic fragments derived from usernames or FTP commands.
  • Identifying and alerting on use of high-risk SQL constructs (e.g., COPY TO PROGRAM, external command execution functions) from the ProFTPD database account.
  • Integration of automated security scanners or rule-based linters that flag string-based SQL construction patterns in server configuration and source code repositories.

Sources

SourceLink
proftpd.orgproftpd.org/docs/RELEASE_NOTES-1.3.10rc1
github.comgithub.com/ZeroPathAI/proftpd-CVE-2026-42167-poc
github.comgithub.com/proftpd/proftpd/issues/2052
openwall.comopenwall.com/lists/oss-security/2026/05/01/4
zeropath.comzeropath.com/blog/proftpd-cve-2026-42167-auth-bypass-privesc-rce
openwall.comopenwall.com/lists/oss-security/2026/05/01/13
openwall.comopenwall.com/lists/oss-security/2026/05/01/4

Frequently asked

questions

Yes. An attacker can exploit the issue remotely by connecting to the FTP service and sending a crafted USER command, provided the vulnerable logging configuration and SQL backend capabilities are in place.

Not necessarily. In many configurations, the USER command is processed and logged before authentication is completed, so the attacker may not need valid credentials to trigger the vulnerable logging path.

The most robust fix is to ensure that all interactions between ProFTPD's mod_sql and the database use parameterized queries or prepared statements, removing any direct string concatenation of values like usernames into SQL commands. Complement this by limiting the database account's permissions and disabling database features that can execute OS-level commands.

Adopt a development and configuration standard that prohibits dynamic SQL construction from untrusted input, applies parameterization everywhere, and treats logging and auditing paths as security-critical. Incorporate regular code and configuration reviews, plus automated checks, to detect unsafe SQL usage and risky database features before deployment.

Find out what's already
exploitable in your codebase.