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.
Originally disclosed on GitHub Security Lab
The pwpgsqlconnect function does not properly sanitize SQL queries, leading to SQLi via the pgsql config file.
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.