CVE-2025-61385

9.6 CRITICAL

📋 TL;DR

CVE-2025-61385 is a SQL injection vulnerability in the pg8000 Python PostgreSQL adapter. Attackers can execute arbitrary SQL commands by passing specially crafted Python lists to the pg8000.native.literal function. This affects applications using pg8000 1.31.4 that process untrusted input through this function.

💻 Affected Systems

Products:
  • pg8000
Versions: 1.31.4
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications that use the pg8000.native.literal function with untrusted input. Applications using proper parameterized queries may not be vulnerable.

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise including data theft, data destruction, privilege escalation, and potential remote code execution on the database server.

🟠

Likely Case

Unauthorized data access, data manipulation, and potential privilege escalation within the database.

🟢

If Mitigated

Limited impact if input validation and parameterized queries are properly implemented elsewhere in the application.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires the attacker to control input passed to the vulnerable function. Public proof-of-concept exists in the vulnerability research repository.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.31.5 or later

Vendor Advisory: https://codeberg.org/tlocke/pg8000/commit/8663c746b02286c32f19c385f0e2e5da9e4fa140

Restart Required: No

Instructions:

1. Update pg8000 using pip: pip install --upgrade pg8000
2. Verify version is 1.31.5 or later
3. No application restart required for Python applications, but restart if using in long-running processes

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation and sanitization for all inputs passed to pg8000.native.literal function

Use Parameterized Queries

all

Replace direct use of pg8000.native.literal with proper parameterized queries throughout the application

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for all user inputs
  • Use web application firewalls (WAF) with SQL injection protection rules

🔍 How to Verify

Check if Vulnerable:

Check if application uses pg8000 version 1.31.4 and calls pg8000.native.literal with user-controlled input

Check Version:

python -c "import pg8000; print(pg8000.__version__)"

Verify Fix Applied:

Verify pg8000 version is 1.31.5 or later and test that SQL injection attempts are properly blocked

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL query patterns
  • Multiple failed login attempts from single source
  • Unexpected database schema changes

Network Indicators:

  • SQL syntax in application layer traffic
  • Unusual database connection patterns

SIEM Query:

source="application_logs" AND ("pg8000.native.literal" OR "SQL syntax error") AND severity=HIGH

🔗 References

📤 Share & Export