Skip to main content
Mallory
HighPublic exploitVulnerability

CVE-2019-9193: PostgreSQL COPY PROGRAM Command Execution (Disputed)

Published Apr 1, 2019 · Updated 9 days ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 daysNo mention activity in the last 30 days.
CVSS7.2High · v3
EPSS92.3%100th percentile
CISA KEVNoNot listed
In the wildReported4 exploitation records in Mallory
Vendor
Postgresql
IdentifiersCVE-2019-9193CWE-250

CVE-2019-9193 identifies disputed command-execution behavior in PostgreSQL 9.3 through 11.2 involving COPY TO/FROM PROGRAM. This feature intentionally permits database superusers and users with the pg_execute_server_program role, where available, to execute operating-system commands as the account running the database server on Windows, Linux, and macOS. PostgreSQL maintainers consider the CVE erroneous because these privileges explicitly authorize server-side command execution, and database superusers already have equivalent capabilities through other mechanisms. The behavior does not bypass authentication or cross an intended security boundary. The pg_read_server_files and pg_write_server_files roles alone do not authorize COPY PROGRAM.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

Impact, mitigation & remediation

What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.

Impact

What an attacker gets, and what they’ve been doing with it.

Abuse of an appropriately privileged database session permits arbitrary command execution with the operating-system permissions of the PostgreSQL service account. Potential consequences include access to or modification of resources available to that account, data exfiltration, malware deployment, and service disruption. Observed abuse includes cryptominer deployment and system-information collection. This behavior does not inherently grant operating-system administrator or root privileges, and PostgreSQL is designed not to run as an operating-system superuser.

Mitigation

If you can’t patch tonight, do this now.

Restrict database network access to authorized clients, enforce secure authentication, and never grant superuser access to remote or otherwise untrusted users. Apply least privilege to application database roles and restrict unnecessary network access from database servers. Monitor PostgreSQL spawning unexpected shells, interpreters, or network utilities, while baselining legitimate administrative and extension-related activity.

Remediation

Patch, then assume compromise.

No upstream PostgreSQL security fix is identified because maintainers consider this intended privileged functionality rather than a vulnerability. Correct excessive database privileges by removing superuser status and unnecessary pg_execute_server_program membership from application accounts and untrusted users. Do not treat upgrading beyond PostgreSQL 11.2 as disabling or fixing COPY PROGRAM.

Public exploits

Exploits

9 exploits validated by Mallory's analysis. Hidden: 2 rejected by Mallory's analysis as not a working exploit; 2 not yet analyzed, such as Exploit-DB entries.

View more in app →
postgres_copy_from_program_cmd_exec.rbThis repository contains a single Metasploit module: 'PostgreSQL COPY FROM PROGRAM Command Execution'. The module exploits a feature in PostgreSQL 9.3 and above that allows superusers (or users with the 'pg_execute_server_program' privilege) to execute arbitrary system commands via the SQL 'COPY FROM PROGRAM' statement. The exploit works by creating a temporary table, then issuing a 'COPY FROM PROGRAM' command with attacker-supplied payloads, such as reverse shells or arbitrary commands. The module supports multiple platforms (Linux, Windows, OSX) and can deliver payloads appropriate to each. The exploit requires valid credentials and sufficient privileges on the target PostgreSQL server, which must be accessible over the network. The code is weaponized, as it is part of the Metasploit framework and supports customizable payloads. The only endpoint is the PostgreSQL server itself, typically accessed over TCP (default port 5432).Disclosed Mar 20, 2019 · Framework: metasploit · ruby · networkWeaponizedcve-2019-9193This repository contains a Python exploit script (portgres_rce.py) targeting CVE-2019-9193, a vulnerability in PostgreSQL that allows code execution via the 'COPY FROM PROGRAM' feature when used by a superuser or a user in the 'pg_execute_server_program' group. The exploit works by connecting to a vulnerable PostgreSQL server and executing a Perl one-liner to establish a reverse shell from the server to the attacker's machine. The attacker is prompted for the target (RHOST, RPORT) and their own (LHOST, LPORT) connection details. The script sets up a listener on the attacker's machine and, upon successful exploitation, provides an interactive shell for arbitrary command execution on the server. The repository is minimal, with only one code file, and is focused solely on this exploit. No detection or fake code is present.wkjung0624 · Disclosed Feb 12, 2020 · python · networkOperationalCVE-2019-9193This repository contains a Python proof-of-concept exploit for CVE-2019-9193, targeting PostgreSQL versions 9.3 through 12.3. The exploit leverages the 'COPY ... FROM PROGRAM' SQL command, which allows an authenticated user to execute arbitrary system commands on the database server. The main script, 'cve-2019-9193.py', accepts command-line arguments for the target IP, port, database name, user credentials, and the system command to execute. Upon successful authentication, it checks the PostgreSQL version and, if a command is provided, creates a temporary table, executes the command via the vulnerable SQL feature, retrieves the output, and cleans up. The exploit requires valid database credentials and network access to the PostgreSQL server. The README provides context, references, and usage examples. No hardcoded external endpoints are present; the script is designed to be run by an attacker who specifies the target. The repository is structured simply, with one exploit script and a README.b4keSn4ke · Disclosed Mar 29, 2022 · python · networkOperationalCVE-2019-9193---Postgresql---RCEThis repository contains a Python exploit script (CVE-2019-9193.py) and a README.md for CVE-2019-9193, a vulnerability in PostgreSQL versions 9.3 through 11.7 that allows authenticated remote code execution. The exploit connects to a target PostgreSQL server using user-supplied credentials and executes arbitrary system commands via the 'COPY FROM PROGRAM' SQL feature, retrieving the output. The script checks the PostgreSQL version to ensure it is vulnerable, then creates a temporary table, executes the command, fetches the output, and cleans up. The README provides usage instructions and example output. The exploit requires network access to the PostgreSQL server and valid credentials. The main attack vector is network-based, targeting the PostgreSQL service (default port 5432). No hardcoded external URLs or IPs are present beyond the default localhost/127.0.0.1 examples.Cheryanika · Disclosed Dec 1, 2025 · python · networkOperationalCVE-2019-9193-Postgresql-RCERepository contains a single Python exploit script (CVE-2019-9193.py) and a short README with usage examples. The script uses psycopg2 to authenticate to a remote PostgreSQL instance (defaults: 127.0.0.1:5432, database template1, user/password postgres/postgres), checks the server version via `SELECT version()`, and if a `-c/--command` is provided, achieves OS command execution by creating a randomly named table and invoking `COPY <table> FROM PROGRAM '<command>'`, then selecting and printing the resulting output. It attempts cleanup by dropping the created table, including in an exception path. Overall purpose: authenticated RCE against PostgreSQL instances where `COPY ... FROM PROGRAM` is usable, with command output retrieval and basic operational flow (connect → version check → execute → cleanup).CybersRMUTL · Disclosed Jan 21, 2026 · python · networkOperationalvulhub-postgres-cve-2019-9193This repository is a deliberately vulnerable PostgreSQL training environment with a working manual SQL demonstration, rather than a standalone exploit client. The English and Chinese guides in app/ document COPY FROM PROGRAM executing the hardcoded id command and retrieving its stdout through cmd_exec. Execution requires privileged database authentication and occurs as the database server's OS user, not necessarily root. CVE-2019-9193 is disputed because this is an intended privileged PostgreSQL capability; the supplied weak postgres/postgres credentials make it directly usable in the lab. The guides describe versions 9.3 through 11, while the deployed version is specifically 10.7. The 32 files comprise documentation and metadata, two Dockerfiles, five shell scripts, seven Terraform modules, a Ruby Vagrantfile, deployment manifests, and CI workflows. The 15-code-file count covers standalone scripts, Terraform, Ruby, and Dockerfiles; SQL is embedded in Markdown. isoloom.yml is the canonical environment specification. app/ vendors the upstream walkthrough and Compose environment; base/ retains the upstream image recipe; build/postgres/ adds the default password to the published Vulhub image. .isoloom/ contains generated Docker, Kubernetes, local-VM, Proxmox, and six cloud-provider deployment outputs. Isoloom is deployment tooling, not an exploit framework. checks/protocol.sh validates only a PostgreSQL SSLRequest response. Generated checks test TCP availability and expected failure of outbound HTTP to 1.1.1.1; none validates COPY command execution. Docker isolation removes the database's default route, and Kubernetes uses egress policies permitting namespace-local traffic and DNS. These restrictions can prevent external reverse shells. The vendored Compose file publishes port 5432 without the generated isolation controls; Kubernetes publishes a LoadBalancer with broad database ingress. Cloud deployments restrict inbound ports 22 and 5432 to allowed_cidr. GitHub workflows validate generated infrastructure, start and test the lab, and register approved deployments through secret-configured endpoints. Destructive commands present in CI and provisioning clean runner software or replace the lab directory; they are not evidence of a fake exploit. No reverse-shell implementation, persistence, exfiltration, or fixed attacker callback endpoint is supplied. Analysis was static. The analyzed repository URL, revision, and archive size were not provided; empty strings and zero represent unavailable metadata. The upstream Vulhub commit recorded in UPSTREAM.md identifies vendored source, not the analyzed repository revision.CyberCTF · Disclosed Oct 8, 2026 · bash · ruby · networkOperationalCVE-2019-9193-exploitThis standalone repository contains three files: README.md documents the tool in Turkish, psql-cmd.py implements the command-line exploit, and requirement.txt declares psycopg2-binary. The Python entry point authenticates to PostgreSQL, enables autocommit, checks the is_superuser setting, and executes a reverse-shell command using COPY (SELECT '') TO PROGRAM. A non-superuser result only produces a warning; execution continues because another granted permission may authorize server-program execution. The operator can select Bash, Perl, Python, or PowerShell payloads. Automatic mode attempts server-side execution of 'which perl', then 'which python3', and otherwise falls back to Bash. These probes already require command-execution privileges; failures can indicate permission or environment problems rather than just missing runtimes. Payload single quotes are doubled before embedding the command in SQL. The script closes its database cursor and connection in a finally block. There is no listener implementation, persistence, credential harvesting, or bundled exploit framework. Although labeled CVE-2019-9193 and PostgreSQL 9.3–11.2, the code itself identifies the issue as disputed/by design. It uses an intentionally privileged PostgreSQL feature rather than demonstrating an authentication bypass or privilege escalation. The stated version range is not enforced or validated, and feature availability is not inherently limited to that range. Linux/Unix payloads are the automatic default; Windows support requires explicitly selecting PowerShell. Notable limitations include synchronous SQL execution that can remain blocked while the shell runs, no independent callback verification, and a documentation mismatch: README.md refers to requirements.txt, but the supplied dependency file is requirement.txt. The random-string helper and sys import are unused. No fixed external IP addresses, domains, or URLs appear in the code. Repository URL, revision, and archive size were not provided; empty metadata strings and size_bytes=0 represent unavailable values, not a measured empty archive.Exript · Disclosed Nov 17, 2026 · python · networkOperationalCVE-2019-9193This repository contains a single Python exploit script (GenPostgresRCEExploit.py) targeting CVE-2019-9193, an authenticated remote code execution vulnerability in PostgreSQL versions 9.3 through 11.7. The exploit requires valid credentials to connect to the target PostgreSQL server and leverages the 'COPY ... FROM PROGRAM' SQL command to execute arbitrary system commands on the server. The script checks the server version for vulnerability, connects using user-supplied parameters (IP, port, database, username, password), and executes a user-specified command, returning its output. The repository also includes a README in both English and Russian, a requirements.txt specifying the psycopg2 library, and an MIT license. The exploit is a proof-of-concept and is not weaponized, but demonstrates the core vulnerability and its impact.geniuszly · Disclosed Oct 6, 2024 · python · networkPoCCVE-2019-9193This repository contains a single Python exploit script (GenPostgresRCEExploit.py) targeting CVE-2019-9193, an authenticated remote code execution vulnerability in PostgreSQL versions 9.3 through 11.7. The exploit requires valid credentials to connect to the target PostgreSQL server and leverages the 'COPY ... FROM PROGRAM' SQL command to execute arbitrary system commands on the server. The script first checks the PostgreSQL version to ensure it is vulnerable, then creates a temporary table, executes the user-supplied command, retrieves the output, and cleans up the temporary table. The repository also includes a README.md with detailed usage instructions and examples, a requirements.txt specifying the psycopg2 dependency, and an MIT license file. The exploit is a proof-of-concept and does not include advanced payloads or automation for post-exploitation. The main attack vector is network-based, requiring access to the PostgreSQL service (default port 5432) and valid authentication credentials.jhnhnck · Disclosed Mar 20, 2025 · python · networkPoC
Exposure surface

Affected products & vendors

Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.

VendorProductType
PostgresqlPostgresqlapplication
FAQ

Frequently asked questions

Is CVE-2019-9193 exploited in the wild?
Yes. As of Nov 19, 2026, Mallory has reports of exploitation in the wild.
Is there a public exploit for CVE-2019-9193?
Yes. Mallory tracks 9 public exploits or proofs of concept for CVE-2019-9193, the earliest disclosed Mar 20, 2019.
Is there a patch for CVE-2019-9193?
No upstream PostgreSQL security fix is identified because maintainers consider this intended privileged functionality rather than a vulnerability. Correct excessive database privileges by removing superuser status and unnecessary pg_execute_server_program membership from application accounts and untrusted users.
What products are affected by CVE-2019-9193?
Postgresql.
How severe is CVE-2019-9193?
CVE-2019-9193 has a CVSS v3 score of 7.2 (High) and an EPSS score of 92.3% (100th percentile) as of Nov 19, 2026.
Activity feed

Recent activity

8 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.

View more in app →
imda singaporeNews · Oct 12, 2026PostgreSQL COPY PROGRAM functionality permits operating-system command execution by users with appropriate database privileges. VAULT PANDA chained this capability with CVE-2026-72898 to execute a script that collected system information, tested connectivity, and attempted DNS- and HTTP-based exfiltration. The advisory explicitly notes that PostgreSQL maintainers and CrowdStrike consider this intended privileged functionality rather than a security vulnerability. Recommended mitigation is to remove unnecessary superuser privileges and the pg_execute_server_program role from Metabase database accounts.Read more ↗splunk researchNews · Jul 17, 2026Detection: Linux Suspicious Child Process of PostgreSQL | Splunk Security ContentA PostgreSQL remote code execution issue referenced in the context of abuse of COPY TO/FROM PROGRAM, enabling attacker-controlled command execution via the database process.Read more ↗starlog blogNews · May 15, 2026PayloadsAllTheThings: The 77,000-Star Security Knowledge Base That Changed How Pentesters Work | StarlogPresented as a command-execution vulnerability in PostgreSQL 9.3–11.2, illustrated using COPY FROM PROGRAM to execute the 'id' command. It appears as an example in an article about the PayloadsAllTheThings knowledge base, rather than as the article's primary subject.Read more ↗zscaler threat labzNews · Jan 1, 2026Malware Analysis of the DreamBus Botnet | Zscaler BlogA disputed PostgreSQL arbitrary code execution issue involving pg_execute_server_program privileges, used by DreamBus after successful PostgreSQL authentication.Read more ↗
+4 more in the timeline. Sign up to see them
Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Mallory platform

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidence2Every report linking this CVE to a named adversary.
Associated malware5Malware families linked to this CVE, with evidence and IOCs.
Detection signaturesYARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activityCommunity discussion across Reddit, Mastodon, and other social sources.