ProFTPD mod_sql contains an SQL escaping bypass in the SQLLog formatting pipeline. Values that start and end with a single quote and contain no internal single quotes can be treated as already escaped. When a vulnerable SQLNamedQuery wraps attacker-controlled variables such as %U in single quotes, an unauthenticated FTP USER value can break out of the logging INSERT and inject stacked SQL statements. This module targets vulnerable ProFTPD 1.3.0 through 1.3.9 deployments using mod_sql with mod_sql_postgres and a vulnerable SQLLog / SQLNamedQuery configuration. This module uses the pre-auth USER trigger commonly exposed by SQLLog ERR_* and executes operating system commands on the PostgreSQL host through COPY TO PROGRAM. Commands are base64 encoded before injection so the FTP USER payload contains no internal single quotes and satisfies the vulnerable is_escaped_text() heuristic. The exploit first resolves the target FTP service from the selected host and service metadata, configures a curl-based agent download method, and checks that the FTP banner is reachable. It then generates a short command sequence to download, chmod, and execute the agent from the PostgreSQL host. Each command is wrapped in a base64-decoding shell launcher, embedded into a stacked SQL COPY TO PROGRAM payload, and sent through an unauthenticated FTP USER command. After sending the payload sequence, the module waits for the deployed agent connection and reports the final remote code execution result. The attack requires the ProFTPD database role to be able to execute PostgreSQL COPY TO PROGRAM, and curl must be available on the PostgreSQL host for the connection types (HTTPS Channel and Connect From connection) for the agent download. The deployed agent will run with the privileges of the PostgreSQL server process.
CVE Link
Exploit Platform
Exploit Type
Product Name