pgAdmin 4 CVE-2026-17566: Command Injection Flaw


pgAdmin 4 CVE-2026-17566: Critical Command Injection via Import/Export

The pgAdmin 4 CVE-2026-17566 command injection vulnerability is a CVSS 9.9 critical flaw in the standard PostgreSQL management tool’s Import/Export Data feature. It lets any authenticated user with a commonly granted permission execute arbitrary operating system commands on the database server by exploiting a mismatch between pgAdmin’s input validation and PostgreSQL’s actual string-parsing behavior. Patched in pgAdmin 4 v9.17 (released July 31, 2026), this vulnerability demonstrates how subtle differences in escaping semantics between two components can open a path to full server compromise.

How This Was Researched

This analysis was compiled from primary security advisories, source code commits, and official documentation. Sources include the GitHub Issue #10213 that reported the bug, the fix commit on GitHub, and the GitHub Security Advisory GHSA-3h25-h4m7-gr36. The official pgAdmin 4 v9.17 release notes and the NVD entry for CVE-2026-17566 were consulted for CVSS scoring and timeline. We focused solely on this specific command injection path through the Import/Export module and did not cover the other six vulnerabilities addressed in the same release. Last researched: August 2026.

What is the root cause of the pgAdmin 4 CVE-2026-17566 command injection vulnerability?

The root cause is a logic flaw in pgAdmin 4’s _is_query_parens_balanced() function, which validates SQL queries before passing them to psql as part of the Import/Export Data tool. The function incorrectly assumed that a backslash before a single quote (\') escapes the quote, as if PostgreSQL’s standard_conforming_strings setting were OFF. This created a parsing discrepancy that an attacker can exploit to break out of the intended query wrapper and inject a TO PROGRAM clause that psql executes via popen(), according to the NVD vulnerability record.

How does PostgreSQL’s default string setting enable the vulnerability?

PostgreSQL has defaulted standard_conforming_strings to ON since version 9.1, meaning backslashes inside string literals are treated as ordinary characters, not escape sequences. This is the default on every PostgreSQL version pgAdmin 4 supports (13 through 18). Under this default, psql’s own tokenizer treats a backslash as a literal character, so a single quote immediately following it closes the string literal rather than being “escaped” by it. This discrepancy between pgAdmin’s checker and psql’s actual parsing behavior is what creates the injection opening, as documented in the PostgreSQL client configuration reference.

What is the practical exploit scenario for CVE-2026-17566?

An attacker crafts a SQL query that passes pgAdmin’s flawed balance check but is parsed differently by psql. The exploit example from the GitHub advisory is SELECT 'a\') TO PROGRAM 'echo pwned' x'. The _is_query_parens_balanced() function sees \' and treats the quote as escaped, deeming the overall string balanced. However, psql sees the backslash as a literal character and interprets the following single quote as the string terminator. The string 'a\' is considered complete, causing psql to treat ) TO PROGRAM 'echo pwned' x' as a meta-command. The TO PROGRAM clause executes the specified shell command via popen(), achieving remote code execution with the privileges of the server process.

Which users are affected and what is the impact?

This vulnerability affects any authenticated user of a pgAdmin 4 instance who holds the tools_import_export_data permission — a role commonly granted to developers and database administrators for routine data operations. No administrator privileges are required, meaning low-privilege users can escalate to full OS command execution on the server. Successful exploitation leads to arbitrary code execution, data exfiltration, or lateral movement within the network. The CISA SSVC assessment for this CVE rates the technical impact as “Total” (complete system compromise), though exploitation is not automatable and has not been confirmed in the wild as of publication. For broader vulnerability context, browse our CVE database.

How was the vulnerability fixed in pgAdmin 4?

The fix, introduced in pgAdmin 4 v9.17 (released July 31, 2026), takes a conservative approach: the updated validation logic now outright rejects any query containing a backslash inside a single-quoted string. This aligns the validation with PostgreSQL’s modern standard_conforming_strings=ON default and eliminates the parsing discrepancy that enabled the bypass. The fix commit intentionally refuses the query rather than guessing which interpretation psql will use, because the correct behavior depends on a server setting the checker cannot reliably know at validation time. Administrators must upgrade to pgAdmin 4 version 9.17 or later.

CVE-2026-17566 at a glance

Field Value
CVE ID CVE-2026-17566
CVSS v3.1 9.9 (Critical)
CVSS v4.0 9.4 (Critical)
CWE CWE-78 (OS Command Injection), CWE-115 (Misinterpretation of Input)
Affected Component Import/Export Data tool (_is_query_parens_balanced())
Affected Versions pgAdmin 4 < 9.17
Fixed Version pgAdmin 4 v9.17 (July 31, 2026)
Privileges Required Low (tools_import_export_data permission)
Exploitation in the Wild Not confirmed as of publication
CNA PostgreSQL

The CVSS v3.1 vector string is CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H, meaning the attack is network-reachable, requires low complexity, needs only low privileges, involves no user interaction, and changes scope (the compromised server process escapes the pgAdmin security boundary). The CVSS v4.0 vector from the CNA adds the SC/SI/SA components, all rated High, confirming full impact across security categories.

How does CVE-2026-17566 compare to other recent pgAdmin vulnerabilities?

This vulnerability is part of a recurring pattern of command injection flaws in pgAdmin’s integration with psql meta-commands. It belongs to the same class of bug as CVE-2025-12762 and CVE-2025-13780, which allowed remote code execution via psql meta-command injection during PLAIN-format dump restore. While the entry point differs — this CVE reaches the vulnerability through the Import/Export Data module rather than the backup/restore tool — the underlying mechanism is identical: unsafe interpolation of user input into a command passed to psql. This pattern suggests that any pgAdmin feature that shells out to psql with user-controlled arguments deserves careful auditing. For a related analysis, see our FortiSandbox command injection deep-dive, which covers a similar CWE-78 flaw in a different product.

The other six vulnerabilities fixed in pgAdmin 4 v9.17

CVE-2026-17566 was the headline issue, but the v9.17 release patched six additional vulnerabilities across the same codebase. The most severe companion flaw is CVE-2026-17349 (CVSS 9.6), which affects the pgAdmin 4 Workspaces feature and allows authenticated users to clone and inherit sensitive database credentials from other users, leading to unauthorized access to databases they should not reach. CVE-2026-17351 (CVSS 9.0) enables a read-only transaction bypass in the AI Assistant feature via a disagreement between the sqlparse library and PostgreSQL’s own lexer — an incomplete fix for the earlier CVE-2026-12045.

The remaining issues include CVE-2026-17346 (CVSS 8.8), which allows cross-session command execution; CVE-2026-17347 (CVSS 7.5), an OS command injection via the MASTER_PASSWORD_HOOK setting introduced in pgAdmin 7.2 that passes usernames into an external command string; and two lower-severity fixes (CVE-2026-17348 and CVE-2026-17350) that were patched together with the main release. All seven vulnerabilities share a common theme: they exploit the trust pgAdmin places in authenticated users and in its own command-construction logic. This batch reinforces that database management interfaces are high-value targets and should receive the same hardening scrutiny as the databases they administer, per the pgAdmin security advisory.

Disclosure timeline

Date Event
July 31, 2026 pgAdmin 4 v9.17 released with fix for CVE-2026-17566
July 31, 2026 NVD publishes CVE-2026-17566 record (CVSS 3.1: 9.9, CVSS 4.0: 9.4)
July 31, 2026 GitHub Security Advisory GHSA-3h25-h4m7-gr36 published
August 1, 2026 CISA-ADP adds SSVC assessment (exploitation: none, automatable: no, technical impact: total)
August 1, 2026 This analysis published

How to detect potential exploitation attempts

Detecting exploitation of CVE-2026-17566 requires monitoring both pgAdmin’s application logs and the underlying PostgreSQL server logs. On the pgAdmin side, look for POST requests to the /import_export/job/<sid> endpoint that include unusual SQL query parameters — specifically queries containing backslash-quote sequences (\') or TO PROGRAM clauses, which are the signature of the injection payload. The pgAdmin application log typically resides under the pgAdmin log directory and records all Import/Export job submissions with the associated SQL query text.

On the PostgreSQL side, enable query logging and search for \copy commands that include a TO PROGRAM clause originating from pgAdmin-initiated sessions. Under normal usage, the Import/Export tool should never generate a TO PROGRAM directive, so its presence is a strong indicator of exploitation. Additionally, monitor the host operating system for unexpected child processes spawned by the pgAdmin server process — specifically popen()-initiated shell commands that execute utilities like echo, bash, curl, wget, or nc from the pgAdmin service account.

For teams using SIEM platforms, create an alert rule that correlates pgAdmin Import/Export API calls with subsequent process creation events on the database server. The CISA SSVC assessment for this CVE notes that exploitation is not automatable, meaning an attacker must interact with the interface manually — this leaves a session trail that forensic analysis can reconstruct.

What remediation steps should administrators take?

Administrators should upgrade pgAdmin 4 to version 9.17 or later immediately, as this is the only complete fix. As a defense-in-depth measure while scheduling the upgrade, database administrators should audit which users hold the tools_import_export_data permission and restrict it to only those who genuinely need it. Monitor PostgreSQL logs for unusual queries containing TO PROGRAM clauses or backslash sequences in string literals, which could indicate exploitation attempts. Review pgAdmin user roles for accounts that may have been provisioned with more permissions than required. Aligning these practices with established security frameworks ensures a systematic approach to vulnerability management and privilege reduction.

FAQ

What is the CVSS score for CVE-2026-17566?

CVE-2026-17566 carries a CVSS v3.1 base score of 9.9 (Critical), reflecting that the attack requires only low privileges (tools_import_export_data), needs no user interaction, is network-accessible, and results in complete compromise of confidentiality, integrity, and availability. The CVSS v4.0 score from the CNA is 9.4. Both ratings place it firmly in the critical severity tier, according to the NVD entry.

Do I need to worry if my pgAdmin 4 instance is not internet-facing?

Yes. The vulnerability requires authenticated access to the pgAdmin interface, not internet exposure. An internal attacker, a compromised user account, or a malicious insider with the tools_import_export_data permission can exploit it regardless of network position. The potential impact — full OS command execution on the server — justifies patching even for internal-only deployments, as it can be a critical step in an internal attack chain.

Besides updating, what can I do to mitigate CVE-2026-17566?

The primary and definitive mitigation is upgrading pgAdmin 4 to version 9.17 or later. As a temporary measure, restrict the tools_import_export_data permission to only users who absolutely require it, reducing the attack surface. Audit pgAdmin user roles for overprivileged accounts and monitor PostgreSQL query logs for suspicious patterns containing TO PROGRAM or unusual backslash sequences. These measures reduce risk but do not eliminate the vulnerability — only the patch does.