{"id":"MSF-multi--postgres--postgres_copy_from_program_cmd_exec","name":"PostgreSQL COPY FROM PROGRAM Command Execution","description":"Installations running Postgres 9.3 and above have functionality which allows for the superuser and users with 'pg_execute_server_program' to pipe to and from an external program using COPY. This allows arbitrary command execution as though you have console access. This module attempts to create a new table, then execute system commands in the context of copying the command output into the table. This module should work on all Postgres systems running version 9.3 and above. For Linux & OSX systems, target 1 is used with cmd payloads such as: cmd/unix/reverse_perl For Windows Systems, target 2 is used with powershell payloads such as: cmd/windows/powershell_reverse_tcp Alternativly target 3 can be used to execute generic commands, such as a web_delivery meterpreter powershell payload or other customised command.","cves":["CVE-2019-9193"],"author":"Jacob Wilkin","published":"2019-03-20","platform":"Linux,OSX,Unix,Windows,Windows","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/multi/postgres/postgres_copy_from_program_cmd_exec.rb","path":"modules/exploits/multi/postgres/postgres_copy_from_program_cmd_exec.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"postgres_copy_from_program_cmd_exec.rb","vulnerabilities":[{"id":"CVE-2019-9193","state":"PUBLISHED","title":null,"titleSource":null,"description":"In PostgreSQL 9.3 through 11.2, the \"COPY TO/FROM PROGRAM\" function allows superusers and users in the 'pg_execute_server_program' group to execute arbitrary code in the context of the database's operating system user. This functionality is enabled by default and can be abused to run arbitrary operating system commands on Windows, Linux, and macOS. NOTE: Third parties claim/state this is not an issue because PostgreSQL functionality for ‘COPY TO/FROM PROGRAM’ is acting as intended. References state that in PostgreSQL, a superuser can execute commands as the server user without using the ‘COPY FROM PROGRAM’.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2019-9193","cvss":{"version":"3.0","baseScore":7.2,"severity":"high","vectorString":"CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2019-9193"},"updatedAt":"2024-11-15T15:13:38.845Z","retrievedAt":"2026-11-25T20:02:30.397Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-multi--postgres--postgres_copy_from_program_cmd_exec.png?v=2","url":"https://exploitbin.com/exploits/MSF-multi--postgres--postgres_copy_from_program_cmd_exec","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--postgres--postgres_copy_from_program_cmd_exec/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--postgres--postgres_copy_from_program_cmd_exec/code","licenseUrl":"https://exploitbin.com/sources#metasploit"}