Executive brief
pgAdmin 4, a popular management tool for PostgreSQL databases, contains a vulnerability in how it handles user-defined scripts for managing master passwords. If an organization uses external login methods like OAuth or Kerberos, a malicious user could craft a username containing special characters to trick the system into running unauthorized commands. This could allow an attacker to take control of the pgAdmin service, potentially leading to the theft of database credentials or disruption of operations.
Technical details
An OS command injection vulnerability exists in pgAdmin 4 (versions 7.2 through 9.16) within the MASTER_PASSWORD_HOOK functionality. The application improperly handled the '%u' placeholder by directly substituting the username into a command string and executing it via 'subprocess.Popen' with 'shell=True'. Because usernames can be sourced from external providers (OAuth, OIDC, Kerberos), an authenticated attacker can provide a username containing shell metacharacters (e.g., backticks, pipes, or semicolons) to execute arbitrary code as the pgAdmin service account. The vulnerability is mitigated in version 9.17 by switching to 'shell=False' and using 'shlex' to properly tokenize arguments before execution.
Affected products
- pgadmin.org pgAdmin 4 7.2 to 9.16
Timeline
- 2026-06-19: other: Initial fix authored
- 2026-07-24: disclosed: Issue reported via GitHub issue tracker
- 2026-07-31: advisory: NVD publication date
- 2026-07-31: patched: Version 9.17 released
References
- https://github.com/pgadmin-org/pgadmin4/blob/master/web/pgadmin/utils/master_password.py
- https://github.com/pgadmin-org/pgadmin4/blob/master/web/config.py
- https://github.com/pgadmin-org/pgadmin4/commit/e7a85767314e7b0fe0b35fe80b9c1af38f48dff6
- https://github.com/pgadmin-org/pgadmin4/commit/ea7e798aac27174d2bacee1d6e136bed76a95e23
- https://github.com/pgadmin-org/pgadmin4/issues/10191