Skip to content
SQL injection Advisory Intermediate

GHSL-2020-031: SQL injection in PureFTPd

The pw_pgsql_connect function in PureFTPd fails to properly sanitise SQL queries, allowing SQL injection through the pgsql configuration file. An attacker could inject SQL code into the query via the config file.

antonio-morales Follow

Originally disclosed on GitHub Security Lab

The pwpgsqlconnect function does not properly sanitize SQL queries, leading to SQLi via the pgsql config file.

antonio-morales, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code fails to escape special characters in the connection parameters and reintroduces a single quote when handling a backslash, so the constructed connection string is not properly sanitised.

Impact

This issue may lead to a local SQLi via the pgsql config file.

What the attacker needed

Ability to edit the pgsql config file

The fix

The switch-case statement should be corrected and properly escaped strings should be used in the snprintf call; the text says fixes were reviewed and verified.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

SQL injection is when user input is inserted into a database query without proper cleaning, letting an attacker change the query's meaning. Here, the input comes from a configuration file, so someone who can edit that file could run their own SQL commands.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by antonio-morales

View all

45 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.