Record summary

CVE-2026-17566 has a selected CVSS score of 9.4 (critical); EIP currently links 1 repository PoC.

Description

pgAdmin 4's Import/Export Data tool builds a psql \copy (...) command line by interpolating a user-supplied SQL query into a Jinja template and passing the rendered line to psql via --command. To stop an attacker from breaking out of the (...) wrapper, create_import_export_job() (route POST /import_export/job/<sid>, gated only by the ordinary, commonly-granted tools_import_export_data permission) validated the query with a hand-written parenthesis-balance checker, _is_query_parens_balanced(). That checker always treated a backslash before a single quote (\') as escaping the quote, i.e. as if standard_conforming_strings were off. PostgreSQL has defaulted standard_conforming_strings to on since 9.1 (2010), the default on every PostgreSQL version pgAdmin 4 currently supports (13-18); under that default psql's own \copy tokenizer treats \ as an ordinary character, so a single quote immediately after it closes the string literal. A query such as SELECT 'a\') TO PROGRAM 'echo pwned' x' was therefore accepted as "balanced" by pgAdmin's checker (which believed the ) was still inside the string), while psql, run through the actual rendered command line, closes the string at that point and treats the following ) as the end of the wrapping \copy (...) subquery, exposing an attacker-chosen TO PROGRAM '<command>' clause that psql executes via popen() -- independent of a subsequent syntax error later on the same line. This is the same class of bug as CVE-2025-12762/CVE-2025-13780 (RCE via psql meta-command/COPY injection during PLAIN-format dump restore), reached through an independently written defense in a different module (Import/Export Data rather than Restore) that had its own, different logic bug (inverted backslash-escape semantics rather than a BOM-defeated regex anchor). The fix rejects any backslash inside a single-quoted string in the query outright, rather than picking one of the two possible psql interpretations. This is intentionally conservative: because the correct interpretation of \ depends on the target server's standard_conforming_strings setting, which the checker cannot reliably know at validation time, refusing the query is safer than guessing. This issue affects pgAdmin 4: from the introduction of _is_query_parens_balanced() before 9.18.

Description source: CVE List

Exploitation context

Available material

Repository PoCs
1

CISA SSVC decision

ExploitationNone
AutomatableNo
Technical impactTotal

CISA Coordinator · SSVC 2.0.3 · Evaluated Jul 31, 2026 · Source: CVE List

Affected products and versions

1
ProductSourceVersion rangeStatus

Default status: unaffected

CVE ListBefore 9.18affected

Proofs of concept

1

Repository PoCs

GitHubHackSpeak/CVE-2026-17566Repository PoCby HackSpeakStars: 1Exploit3 files

13.2 KiB

GitHub

PoC details
Analysisdeepseek-v4-pro:cloud ·

Technical assessment

Python script that authenticates to pgAdmin 4, enumerates servers, and sends a crafted POST request to /import_export/job/<sid> with a malicious SQL query designed to exploit CVE-2026-17566. The payload injects a TO PROGRAM clause into a psql \copy command, aiming for remote code execution on the pgAdmin host.

Backdoor review

No backdoor observed in reviewed code

The PoC implements the documented CVE-2026-17566 exploit path: login, enumerate servers, and POST a crafted query to /import_export/job/<sid> to trigger RCE via psql TO PROGRAM injection. No concealed backdoor, unrelated payload, or deceptive behavior was observed. The code is a straightforward exploit script with no hidden functionality.

ClassificationExploit
Model confidence95%
AuthenticationRequired
Languagespython
Target softwarepgAdmin 4
Attack typesOS command injectionremote code execution
Evidence & reasoningClassification basis · observed behavior · safety review
Technical evidence

Classification basis and observed behavior

Classification basis

The Python script actively performs the steps required to exploit CVE-2026-17566: it authenticates, performs reconnaissance, constructs a payload that injects an OS command into a psql \copy command, and sends it to the vulnerable endpoint. This is code intended to exercise a vulnerability, not merely detect it.

pgadmin4_rce_poc.py:1-221README.md:1-3

Requirements

  • Authenticated low-privilege pgAdmin user with tools_import_export_data permissionREADME.md:26
  • Network access to a pgAdmin 4 instance < 9.18README.md:27-28

Observed behavior

  • Logs into pgAdmin by fetching /login for a CSRF token and posting credentialspgadmin4_rce_poc.py:67-95
  • Enumerates available database servers via GET /browser/serverspgadmin4_rce_poc.py:98-112
  • Constructs a malicious SQL query containing a TO PROGRAM clause to execute an arbitrary OS commandpgadmin4_rce_poc.py:115-128
  • Sends the crafted payload via POST /import_export/job/<sid> to trigger the vulnerabilitypgadmin4_rce_poc.py:131-155
Safety-review evidence

Behaviors behind the backdoor verdict

Observables

Exploit Mechanism
Payload withheldThe build_query method constructs a payload that exploits the parenthesis-balance checker's misinterpretation of backslash-escaped quotes, enabling command execution via psql's popen().pgadmin4_rce_poc.py:116-128
Command Execution
Payload withheldThe script accepts --command or --reverse arguments and passes them to the trigger method, which sends the exploit payload to the vulnerable endpoint.pgadmin4_rce_poc.py:165-187pgadmin4_rce_poc.py:131-155
Authentication Flow
Payload withheldThe login method performs a GET /login to extract the _form_token, then POSTs credentials. This is normal exploit behavior for authenticated RCE.pgadmin4_rce_poc.py:67-95
Review boundaries

What the analysis did not establish

  • The author states the script is 'NOT TESTED against a live instance' and 'request body field names may need minor adjustment' (pgadmin4_rce_poc.py lines 14-16).
  • One file (total 3) is omitted from the evidence packet; its content is not available for analysis.
  • One file (LICENSE) was present in the repository but not included as text content; it is a standard MIT license file and unlikely to contain executable behavior.
  • The PoC author states the script was not tested against a live instance; the review assesses only the supplied code, not its runtime behavior.
Model interpretation

This review is limited to the supplied PoC code and context. It does not assert that the code works or is safe to execute.

Research & analysis

1
Advisory analysispgAdmin Development TeamSource: EIP research review

Version 9.17 — pgAdmin 4 9.17 documentation

The pgAdmin 4 v9.17 release notes document an OS command injection vulnerability in the Import/Export Data tool. A query-based export can pass a crafted query string past the \copy(...) parenthesis-balance guard by exploiting a backslash-escape mismatch with psql's default standard_conforming_strings=on behaviour, exposing a live TO PROGRAM clause for arbitrary command execution. The vulnerability was reported by Arpit Jain and is fixed in version 9.17. The same release also addresses six other vulnerabilities: SQL injection in Index Statistics and Publications/Subscriptions views (CVE-2026-17346, incomplete fix for CVE-2026-12044), OS command injection in MASTER_PASSWORD_HOOK (CVE-2026-17347), unauthenticated route access via missing @pga_login_required decorator (CVE-2026-17348, incomplete fix for CVE-2026-12046), credential leakage via adhoc server connection cloning (CVE-2026-17349), tool-permission bypass (CVE-2026-17350), and AI Assistant read-only transaction guard bypass (CVE-2026-17351, incomplete fix for CVE-2026-12045).

Root causeTechnical detailMitigation
https://www.pgadmin.org/docs/pgadmin4/9.17/release_notes_9_17.html
Research notes
  • Root cause
    The OS command injection in the Import/Export Data tool occurs because a query-based export can pass a crafted query string past the \copy(...) parenthesis-balance guard by exploiting a backslash-escape mismatch with psql's default standard_conforming_strings=on behaviour, exposing a live TO PROGRAM clause for arbitrary command execution.
  • Technical detail
    The vulnerability involves a lexer/parser differential between the application's parenthesis-balance guard and psql's actual string interpretation under standard_conforming_strings=on, allowing a TO PROGRAM clause to be smuggled past the guard.
  • Mitigation
    Fixed in pgAdmin 4 version 9.17. The release also addresses six other vulnerabilities including incomplete fixes for CVE-2026-12044, CVE-2026-12045, and CVE-2026-12046.
Supporting sources

References

3